From patchwork Tue Sep 17 10:20:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1986362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VzPbZObf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7Hr26RW7z1y1t for ; Tue, 17 Sep 2024 20:21:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 749BE8132F; Tue, 17 Sep 2024 10:21:20 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id u5vLz3rdjh9n; Tue, 17 Sep 2024 10:21:17 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org ED2CB80ED2 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VzPbZObf Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id ED2CB80ED2; Tue, 17 Sep 2024 10:21:15 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D5C3FC0012; Tue, 17 Sep 2024 10:21:15 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id EC642C0011 for ; Tue, 17 Sep 2024 10:21:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CE8C7423A1 for ; Tue, 17 Sep 2024 10:21:13 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id TebnkbgzbdQ7 for ; Tue, 17 Sep 2024 10:21:12 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=lorenzo.bianconi@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 820E94239C Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 820E94239C Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VzPbZObf Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 820E94239C for ; Tue, 17 Sep 2024 10:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726568471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=E2n4YAkNeksAe3ix6D9Ksp9/syD0xRO/nzr9DDfOLNY=; b=VzPbZObfkhrMGLrR61gEd+OqhkCBoszw+SjWKSYDdQ2c+ZXWxBRHIwk9zFxQaBI5d43o7Q H01pYdfNyQfccB+QamBheYZMPMCLJKtsO9f0MrISsSxkFBgCB2Dcb/t1m/foVfrmW+yNAg 63BVI5sYIr7G58kXFkoD7HOoy2kwkiI= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-8MoLzXm8O36IYJ7yEkn8vA-1; Tue, 17 Sep 2024 06:21:10 -0400 X-MC-Unique: 8MoLzXm8O36IYJ7yEkn8vA-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7a9bb56da15so945077285a.1 for ; Tue, 17 Sep 2024 03:21:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726568469; x=1727173269; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=E2n4YAkNeksAe3ix6D9Ksp9/syD0xRO/nzr9DDfOLNY=; b=t/0HkkGlb5lB0tPzsma27n40/bgzwW3hcEyMtNXIoW04zF5r2z+vaZZWux3ULn6UKm Y4WsmD+p70oGyPx+r6+cSVxHlSEjBKdjjPhh2wQQsXtdOdqb0Z0Krl8DhTzyFyHqXCaD BCitWc32WF91Nk9pIxnU/TfiAUgoa8Do7i96WH0xcj24+f/KipbJgENbsDeMyPuJbKuh GCI7g4WVh+adGhFG0xb2r0f0LPmD7RKJVpGWPOmETzki/TG/doeowTtiwxYL3CcmfA1d RpQLpsu/+J1U2qqyZAPwqZk+XqzcHotCZdFBg/zoOA/Hai1wT8QIRjmo+8kU4jWQFxVj 8PQw== X-Gm-Message-State: AOJu0Yzb3EXeTVU2kC2iDlfcLHtDnD6jR0yLpxkTsY1VsmZJciIQdCta HnYu7Eo68XUgSV0e6KKpOALkwQOelPI1tE+CJ44bTdNYOLbGH3Jxxk/383sFCA5LCAfjFNhaQ6g J9ru1k96GUG/+72HS5wMl0KFJYaGptnOOX/9uASEWziMDJKsW9J9zBZHyVuvfb1jsDB/TH1TD8A NAZOol/+fXVi8kmhUoc71ZzN8NyBr0qqXj/G6NAsYVwnaFwFKfIw== X-Received: by 2002:a05:620a:29c8:b0:7a9:bd5b:eb61 with SMTP id af79cd13be357-7a9e5f18b29mr2458900985a.27.1726568469349; Tue, 17 Sep 2024 03:21:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0Qd9Xy2WxrYgQg59dtLYK7uW4GdfPAorYHFdh/X3apyKBa3/g9gFsL8MmZXdv3gdTFqQWPg== X-Received: by 2002:a05:620a:29c8:b0:7a9:bd5b:eb61 with SMTP id af79cd13be357-7a9e5f18b29mr2458898185a.27.1726568468775; Tue, 17 Sep 2024 03:21:08 -0700 (PDT) Received: from localhost (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7ab3eb57823sm339470685a.89.2024.09.17.03.21.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2024 03:21:08 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Tue, 17 Sep 2024 12:20:59 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] ipam: Do not report error for static assigned IPs. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Do not report error in ipam_insert_ip routine for addresses staticatically assigned to ovn logical {swith,router} ports since they have precedence on addressed dynamically assigned by ipam. Reported-at: https://issues.redhat.com/browse/FDP-752 Signed-off-by: Lorenzo Bianconi Acked-by: Mark Michelson --- northd/ipam.c | 6 +++--- northd/ipam.h | 2 +- northd/northd.c | 13 +++++++------ northd/test-ipam.c | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/northd/ipam.c b/northd/ipam.c index 4448a7607..04fa357a5 100644 --- a/northd/ipam.c +++ b/northd/ipam.c @@ -48,7 +48,7 @@ destroy_ipam_info(struct ipam_info *info) } bool -ipam_insert_ip(struct ipam_info *info, uint32_t ip) +ipam_insert_ip(struct ipam_info *info, uint32_t ip, bool dynamic) { if (!info->allocated_ipv4s) { return true; @@ -56,8 +56,8 @@ ipam_insert_ip(struct ipam_info *info, uint32_t ip) if (ip >= info->start_ipv4 && ip < (info->start_ipv4 + info->total_ipv4s)) { - if (bitmap_is_set(info->allocated_ipv4s, - ip - info->start_ipv4)) { + if (dynamic && bitmap_is_set(info->allocated_ipv4s, + ip - info->start_ipv4)) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); VLOG_WARN_RL(&rl, "%s: Duplicate IP set: " IP_FMT, info->id, IP_ARGS(htonl(ip))); diff --git a/northd/ipam.h b/northd/ipam.h index 447412769..6240f9ab7 100644 --- a/northd/ipam.h +++ b/northd/ipam.h @@ -22,7 +22,7 @@ void init_ipam_info(struct ipam_info *info, const struct smap *config, void destroy_ipam_info(struct ipam_info *info); -bool ipam_insert_ip(struct ipam_info *info, uint32_t ip); +bool ipam_insert_ip(struct ipam_info *info, uint32_t ip, bool dynamic); uint32_t ipam_get_unused_ip(struct ipam_info *info); diff --git a/northd/northd.c b/northd/northd.c index a267cd5f8..95c3f0e07 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -1464,13 +1464,13 @@ ovn_port_get_peer(const struct hmap *lr_ports, struct ovn_port *op) } static void -ipam_insert_ip_for_datapath(struct ovn_datapath *od, uint32_t ip) +ipam_insert_ip_for_datapath(struct ovn_datapath *od, uint32_t ip, bool dynamic) { if (!od) { return; } - ipam_insert_ip(&od->ipam_info, ip); + ipam_insert_ip(&od->ipam_info, ip, dynamic); } static void @@ -1487,7 +1487,7 @@ ipam_insert_lsp_addresses(struct ovn_datapath *od, for (size_t j = 0; j < laddrs->n_ipv4_addrs; j++) { uint32_t ip = ntohl(laddrs->ipv4_addrs[j].addr); - ipam_insert_ip_for_datapath(od, ip); + ipam_insert_ip_for_datapath(od, ip, false); } } @@ -1519,7 +1519,7 @@ ipam_add_port_addresses(struct ovn_datapath *od, struct ovn_port *op) * about a duplicate IP address. */ if (ip != op->peer->od->ipam_info.start_ipv4) { - ipam_insert_ip_for_datapath(op->peer->od, ip); + ipam_insert_ip_for_datapath(op->peer->od, ip, false); } } } @@ -1744,7 +1744,8 @@ update_unchanged_dynamic_addresses(struct dynamic_address_update *update) } if (update->ipv4 == NONE && update->current_addresses.n_ipv4_addrs) { ipam_insert_ip_for_datapath(update->op->od, - ntohl(update->current_addresses.ipv4_addrs[0].addr)); + ntohl(update->current_addresses.ipv4_addrs[0].addr), + true); } } @@ -1872,7 +1873,7 @@ update_dynamic_addresses(struct dynamic_address_update *update) ipam_insert_mac(&mac, true); if (ip4) { - ipam_insert_ip_for_datapath(update->od, ntohl(ip4)); + ipam_insert_ip_for_datapath(update->od, ntohl(ip4), true); ds_put_format(&new_addr, " "IP_FMT, IP_ARGS(ip4)); } if (!IN6_ARE_ADDR_EQUAL(&ip6, &in6addr_any)) { diff --git a/northd/test-ipam.c b/northd/test-ipam.c index c449599e3..3b6ad1891 100644 --- a/northd/test-ipam.c +++ b/northd/test-ipam.c @@ -44,7 +44,7 @@ test_ipam_get_unused_ip(struct ovs_cmdl_context *ctx) uint32_t next_ip = ipam_get_unused_ip(&info); ds_put_format(&output, IP_FMT "\n", IP_ARGS(htonl(next_ip))); if (next_ip) { - ovs_assert(ipam_insert_ip(&info, next_ip)); + ovs_assert(ipam_insert_ip(&info, next_ip, true)); } }