From patchwork Fri Oct 2 17:31:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1375980 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: 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=ade5Ls+j; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C2xrN5wldz9s1t for ; Sat, 3 Oct 2020 03:32:04 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id D2F68204B7; Fri, 2 Oct 2020 17:32:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jIyx9Dp14-Tg; Fri, 2 Oct 2020 17:32:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 6B38D20406; Fri, 2 Oct 2020 17:32:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 483FAC0889; Fri, 2 Oct 2020 17:32:00 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id EBC4BC0051 for ; Fri, 2 Oct 2020 17:31:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id BA94B20485 for ; Fri, 2 Oct 2020 17:31:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ln0L-a+SGRSC for ; Fri, 2 Oct 2020 17:31:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by silver.osuosl.org (Postfix) with ESMTPS id 24A3420406 for ; Fri, 2 Oct 2020 17:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601659914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T3dlliP8MkqBYfCiX26lmIsutPdFcRAGIMjvYrzWPXg=; b=ade5Ls+jT5ZBHBlMYyJ63nQTW59C1z8SzNBZCT2cfQ5MZfTBliLOIIgaXEqDDytJf128Xo sVWJUVdl9R5BQSSJfeFQx/Yc8jCBq/mupy5en2EGC8YPs+LiIFpoGlqN5Cq7p01naLiPiW V+pozaeHIlK2SqA8cpy70yA6k6qOCCg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-558-pXTlzN-zOKi0lcg5GBr4Xw-1; Fri, 02 Oct 2020 13:31:36 -0400 X-MC-Unique: pXTlzN-zOKi0lcg5GBr4Xw-1 Received: by mail-wr1-f70.google.com with SMTP id r16so793525wrm.18 for ; Fri, 02 Oct 2020 10:31:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=T3dlliP8MkqBYfCiX26lmIsutPdFcRAGIMjvYrzWPXg=; b=W1I91/fpA9oM4MrbtTw67vzyJxah4GXjpgbdAxqO4GSff/51zrliI0LPkRkxm84Cd9 cPmXsFJJooDqyXG5bTYpsguOoC5c/+/ZZQ7dJ+X4297cb1ZqXXqhHXinNGJa2yfFOo6q M/Dp2sY316HPX3BY8mPFc1E4WRoYbQtPGNclDmdOhQjvd9wv8AkyTqwAmrAqfwZSeUTa hZJlQlEGYsBDSR+0mIWpso/XSVHOsMgHdlMEk9yZ27ZCVpm6iWk4lfA2J+ZTfuCm9DuU mB0vn0L3DdvLrbxKks8s4NcwCpRsg1JV5/gbs2D+aTLKepmGZFQT5XFjeUuhacRZqG23 VnYA== X-Gm-Message-State: AOAM531RWBDXihJPeig86NNPDaCDJz9TC0uFiSGyPFZZ6AuhdNWnaI3r oWv2qYSSXZZGIBsb0aYTBDfH49T/LkzrQB1kuvfMZOs6kDm08q6ijdn9S3QT3V0ovm+bTBn61zv hIOliAf/jjKpF4Z8PGA== X-Received: by 2002:adf:dd51:: with SMTP id u17mr4218368wrm.355.1601659894549; Fri, 02 Oct 2020 10:31:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOAr/p2txOu9esvA7x221wDUnihAgX1wNqLACRTm79VP7mPiWi8SQYd66Vc1ix5UTP23Q/RQ== X-Received: by 2002:adf:dd51:: with SMTP id u17mr4218345wrm.355.1601659894274; Fri, 02 Oct 2020 10:31:34 -0700 (PDT) Received: from lore-desk.redhat.com ([176.207.245.61]) by smtp.gmail.com with ESMTPSA id 13sm1987720wmk.30.2020.10.02.10.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 10:31:33 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Fri, 2 Oct 2020 19:31:28 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 ovn] northd: properly reconfigure ipam when subnet is changed X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Reconfigure dynamic assigned addresses if subnet is modified removing IP out of configured netmask if present Signed-off-by: Lorenzo Bianconi Acked-by: Mark Michelson --- Changes since v1: - do not remove invalid address in ipam_get_unused_ip() --- northd/ovn-northd.c | 2 +- tests/ovn.at | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 91da31941..afc9b4e91 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -1793,7 +1793,7 @@ dynamic_ip4_changed(const char *lsp_addrs, } uint32_t index = ip4 - ipam->start_ipv4; - if (index > ipam->total_ipv4s || + if (index >= ipam->total_ipv4s - 1 || bitmap_is_set(ipam->allocated_ipv4s, index)) { /* Previously assigned dynamic IPv4 address can no longer be used. * It's either outside the subnet, conflicts with an excluded IP, diff --git a/tests/ovn.at b/tests/ovn.at index 7769b69ed..f1041bf0b 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -7473,6 +7473,20 @@ AT_CHECK([ovn-nbctl get Logical-Switch-Port p103 dynamic_addresses], [0], ["22:33:44:55:66:77 172.16.1.250" ]) +ovn-nbctl ls-add sw12 +for i in $(seq 0 1); do + for j in $(seq 1 99); do + idx=$((i*100+j)) + ovn-nbctl lsp-add sw12 sw12-p${idx} -- \ + lsp-set-addresses sw12-p${idx} "00:00:00:00:$i:$j dynamic" + done +done +ovn-nbctl set Logical-Switch sw12 other_config:subnet=192.10.2.0/24 +ovn-nbctl set Logical-Switch sw12 other_config:subnet=192.10.2.0/25 +AT_CHECK([ovn-nbctl list Logical-Switch-Port | grep -q 192.10.2.127], [1]) +AT_CHECK([ovn-nbctl list Logical-Switch-Port | grep -q 192.10.2.128], [1]) +AT_CHECK([ovn-nbctl list Logical-Switch-Port | grep -q 192.10.2.180], [1]) + as ovn-sb OVS_APP_EXIT_AND_WAIT([ovsdb-server])