From patchwork Tue Sep 20 00:04:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1679822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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=SaGm2S4W; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MWhd60jVQz1yp7 for ; Tue, 20 Sep 2022 10:05:14 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 55135403BE; Tue, 20 Sep 2022 00:05:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 55135403BE Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SaGm2S4W X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xG6VH_slVZw5; Tue, 20 Sep 2022 00:05:09 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 8AD044028D; Tue, 20 Sep 2022 00:05:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8AD044028D Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 522F2C0032; Tue, 20 Sep 2022 00:05:08 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id AA12CC0032 for ; Tue, 20 Sep 2022 00:05:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 767BC40291 for ; Tue, 20 Sep 2022 00:05:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 767BC40291 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T1dRRcRyz_6m for ; Tue, 20 Sep 2022 00:05:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org BEEAE400C5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id BEEAE400C5 for ; Tue, 20 Sep 2022 00:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663632303; 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: in-reply-to:in-reply-to:references:references; bh=J4CnnBYIy/swtG6e3jyh0xpZXkVg62rv3/GbKlfT/Oc=; b=SaGm2S4WHhZeLCFMUY3sC243587ZW8CM7wSa4H9IyMsHfIETipYZHpE5EqcnHgZnaDU5fB jB8hiSyyBpcdQ0ByB8aXNC7T/mdy1ajJTGhZybcLVo0YA8QIy9RVgr3Fr6aXeDV5M4OMly 00xrxZvssUqqbJ2rfDh2BmlHcS9Qko0= 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_128_GCM_SHA256) id us-mta-85-agV3RwgHMHakgQzGUqFSmw-1; Mon, 19 Sep 2022 20:05:02 -0400 X-MC-Unique: agV3RwgHMHakgQzGUqFSmw-1 Received: by mail-qk1-f199.google.com with SMTP id x22-20020a05620a259600b006b552a69231so586204qko.18 for ; Mon, 19 Sep 2022 17:05:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=J4CnnBYIy/swtG6e3jyh0xpZXkVg62rv3/GbKlfT/Oc=; b=Vu9hGve7TV7k60InzVRxZ358JZPqjys/EtFJKVJ/JbZ/48pHe+/THFiBWgb+/r5YR6 2QllCp6On5dVffmpKmWruai3aOx9NhRF2nBve4uy4TL91+wuPKdHe1IKYubRYb8++es2 EDWs9+lAM2ve0EfdVEk+X+p1cwliYKlRwoaXQOpT6wBsk20BnyXrI8l/NIxcQ//Y0uE2 77vR3OJ0UarbHQ2jUjJwIXDRX6qiVRlioo+/9uNe8U2ZFAgJzoxSROpNbbj3jw1kmN0d PTLXmtXgC5CPghKqOB9GAZUHB4dpJYLsbXyhcVo3Gjc00JoNT5vN2OW7WNNf+LlH3L4F irYw== X-Gm-Message-State: ACrzQf3zNBSinyo9CnraLAyAEPYPB6Kyfr5u8HhHPl/njha8FYrF+0rX Nrzj1OQvyofgQxGcWbaP7TePbaGox9DXuD4Z7B6B9SYp29RrNbUrBaqU8dqJOihV2805cDdigId 4RLrq5HEKC91UfEnh6KRlZ5w3WU9UMIvcjhS2uCQd+cWDR+zULz4sz2Ttxuxp2kr2 X-Received: by 2002:ac8:5c91:0:b0:35b:bc2d:527 with SMTP id r17-20020ac85c91000000b0035bbc2d0527mr17233599qta.674.1663632301681; Mon, 19 Sep 2022 17:05:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6IrK6lGYcMLEUfLwfMLibjPkRq98V9o2ENk3GZ9OgY/LUadUv51+Anxj6vXKUN6sNKsTsopg== X-Received: by 2002:ac8:5c91:0:b0:35b:bc2d:527 with SMTP id r17-20020ac85c91000000b0035bbc2d0527mr17233545qta.674.1663632300996; Mon, 19 Sep 2022 17:05:00 -0700 (PDT) Received: from fedora34.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a454c00b006aedb35d8a1sm14621611qkp.74.2022.09.19.17.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 17:04:59 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 20 Sep 2022 00:04:48 +0000 Message-Id: <20220920000453.357057-2-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920000453.357057-1-ihrachys@redhat.com> References: <20220920000453.357057-1-ihrachys@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 1/6] Rename tunnel ports to include source chassis name 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" This is in preparation to support multiple separate controller instances with distinct chassis names operating on the same vswitchd instance. Signed-off-by: Ihar Hrachyshka --- controller/encaps.c | 3 +- tests/ovn-controller.at | 22 +++--- tests/ovn-ipsec.at | 16 ++--- tests/ovn-performance.at | 4 +- tests/ovn.at | 144 +++++++++++++++++++-------------------- 5 files changed, 95 insertions(+), 94 deletions(-) diff --git a/controller/encaps.c b/controller/encaps.c index 9647ba507..e6b2aa074 100644 --- a/controller/encaps.c +++ b/controller/encaps.c @@ -75,7 +75,8 @@ tunnel_create_name(struct tunnel_ctx *tc, const char *chassis_id) for (i = 0; i < UINT16_MAX; i++) { char *port_name; - port_name = xasprintf("ovn-%.6s-%x", chassis_id, i); + port_name = xasprintf( + "ovn-%s-%s-%x", tc->this_chassis->name, chassis_id, i); if (!sset_contains(&tc->port_names, port_name)) { return port_name; diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index 3c3fb31c7..d6a2cbb49 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -261,7 +261,7 @@ ovs-vsctl \ ovn_attach n1 br-phys 192.168.0.1 check_tunnel_property () { - test "`ovs-vsctl get interface ovn-fakech-0 $1`" = "$2" + test "`ovs-vsctl get interface ovn-hv-fakechassis-0 $1`" = "$2" } # create "empty" chassis. vxlan is used here as a stub @@ -273,8 +273,8 @@ ovn-sbctl chassis-add fakechassis vxlan 192.168.0.2 # the chassis-id in ovn-chassis-id); if we supply a different IP here # we won't be able to co-relate this to the tunnel port that was created # in the previous step and, as a result, will end up creating another tunnel, -# ie. we can't just lookup using "ovn-fakech-0". So, need to use the same IP -# as above, i.e 192.168.0.2, here. +# ie. we can't just lookup using "ovn-hv-fakechassis-0". So, need to use the +# same IP as above, i.e 192.168.0.2, here. encap_uuid=$(ovn-sbctl add chassis fakechassis encaps @encap -- --id=@encap create encap type=geneve ip="192.168.0.2") OVS_WAIT_UNTIL([check_tunnel_property type geneve]) @@ -292,11 +292,11 @@ ovn-sbctl set encap ${encap_uuid} ip=192.168.0.2 OVS_WAIT_UNTIL([check_tunnel_property options:remote_ip "\"192.168.0.2\""]) # Change the type on the OVS side and check than OVN fixes it -ovs-vsctl set interface ovn-fakech-0 type=vxlan +ovs-vsctl set interface ovn-hv-fakechassis-0 type=vxlan OVS_WAIT_UNTIL([check_tunnel_property type geneve]) # Delete the port entirely and it should be resurrected -ovs-vsctl del-port ovn-fakech-0 +ovs-vsctl del-port ovn-hv-fakechassis-0 OVS_WAIT_UNTIL([check_tunnel_property type geneve]) # set `ovn-set-local-ip` option to true and check if tunnel parameters @@ -305,7 +305,7 @@ ovs-vsctl set open . external_ids:ovn-set-local-ip=true OVS_WAIT_UNTIL([check_tunnel_property options:local_ip "\"192.168.0.1\""]) # Change the local_ip on the OVS side and check than OVN fixes it -ovs-vsctl set interface ovn-fakech-0 options:local_ip="1.1.1.1" +ovs-vsctl set interface ovn-hv-fakechassis-0 options:local_ip="1.1.1.1" OVS_WAIT_UNTIL([check_tunnel_property options:local_ip "\"192.168.0.1\""]) # Gracefully terminate daemons @@ -769,7 +769,7 @@ ovs-vsctl \ ovn_attach n1 br-phys 192.168.0.1 check_tunnel_property () { - test "`ovs-vsctl get interface ovn-fakech-0 $1`" = "$2" + test "`ovs-vsctl get interface ovn-hv-fakechassis-0 $1`" = "$2" } # without any tos options @@ -780,7 +780,7 @@ no_tos_options="{csum=\"true\", key=flow, remote_ip=\"192.168.0.2\"}" ovn-sbctl chassis-add fakechassis geneve 192.168.0.2 OVS_WAIT_UNTIL([check_tunnel_property type geneve]) -tos_option=$(ovs-vsctl get interface ovn-fakech-0 options) +tos_option=$(ovs-vsctl get interface ovn-hv-fakechassis-0 options) AT_CHECK([test "$tos_option" = "$no_tos_options"], [0], []) expected_tos_option="inherit" @@ -791,7 +791,7 @@ ovs-vsctl \ # now, wait for a sec sleep 1 -tos_option=$(ovs-vsctl get interface ovn-fakech-0 options:tos) +tos_option=$(ovs-vsctl get interface ovn-hv-fakechassis-0 options:tos) AT_CHECK([test "$tos_option" = "$expected_tos_option"], [0], []) # Try another value @@ -803,7 +803,7 @@ ovs-vsctl \ # now, wait for a sec sleep 1 -tos_option=$(ovs-vsctl get interface ovn-fakech-0 options:tos) +tos_option=$(ovs-vsctl get interface ovn-hv-fakechassis-0 options:tos) AT_CHECK([test "$tos_option" = "\"$expected_tos_option\""], [0], []) # Remove tos option and check if we are back to the original state @@ -814,7 +814,7 @@ ovs-vsctl \ # now, wait for a sec sleep 1 -tos_option=$(ovs-vsctl get interface ovn-fakech-0 options) +tos_option=$(ovs-vsctl get interface ovn-hv-fakechassis-0 options) AT_CHECK([test "$tos_option" = "$no_tos_options"], [0], []) # Gracefully terminate daemons diff --git a/tests/ovn-ipsec.at b/tests/ovn-ipsec.at index 10ef97878..a2e185f33 100644 --- a/tests/ovn-ipsec.at +++ b/tests/ovn-ipsec.at @@ -48,14 +48,14 @@ ovn-nbctl set nb_global . options:ipsec_encapsulation=true check ovn-nbctl --wait=hv sync -AT_CHECK([as hv2 ovs-vsctl get Interface ovn-hv1-0 options:remote_ip | tr -d '"\n'], [0], [192.168.0.1]) -AT_CHECK([as hv2 ovs-vsctl get Interface ovn-hv1-0 options:local_ip | tr -d '"\n'], [0], [192.168.0.2]) -AT_CHECK([as hv2 ovs-vsctl get Interface ovn-hv1-0 options:remote_name | tr -d '\n'], [0], [hv1]) -AT_CHECK([as hv2 ovs-vsctl get Interface ovn-hv1-0 options:ipsec_encapsulation | tr -d '\n'], [0], [yes]) -AT_CHECK([as hv1 ovs-vsctl get Interface ovn-hv2-0 options:remote_ip | tr -d '"\n'], [0], [192.168.0.2]) -AT_CHECK([as hv1 ovs-vsctl get Interface ovn-hv2-0 options:local_ip | tr -d '"\n'], [0], [192.168.0.1]) -AT_CHECK([as hv1 ovs-vsctl get Interface ovn-hv2-0 options:remote_name | tr -d '\n'], [0], [hv2]) -AT_CHECK([as hv1 ovs-vsctl get Interface ovn-hv2-0 options:ipsec_encapsulation | tr -d '\n'], [0], [yes]) +AT_CHECK([as hv2 ovs-vsctl get Interface ovn-hv2-hv1-0 options:remote_ip | tr -d '"\n'], [0], [192.168.0.1]) +AT_CHECK([as hv2 ovs-vsctl get Interface ovn-hv2-hv1-0 options:local_ip | tr -d '"\n'], [0], [192.168.0.2]) +AT_CHECK([as hv2 ovs-vsctl get Interface ovn-hv2-hv1-0 options:remote_name | tr -d '\n'], [0], [hv1]) +AT_CHECK([as hv2 ovs-vsctl get Interface ovn-hv2-hv1-0 options:ipsec_encapsulation | tr -d '\n'], [0], [yes]) +AT_CHECK([as hv1 ovs-vsctl get Interface ovn-hv1-hv2-0 options:remote_ip | tr -d '"\n'], [0], [192.168.0.2]) +AT_CHECK([as hv1 ovs-vsctl get Interface ovn-hv1-hv2-0 options:local_ip | tr -d '"\n'], [0], [192.168.0.1]) +AT_CHECK([as hv1 ovs-vsctl get Interface ovn-hv1-hv2-0 options:remote_name | tr -d '\n'], [0], [hv2]) +AT_CHECK([as hv1 ovs-vsctl get Interface ovn-hv1-hv2-0 options:ipsec_encapsulation | tr -d '\n'], [0], [yes]) AT_CLEANUP diff --git a/tests/ovn-performance.at b/tests/ovn-performance.at index 9affca498..5c0267a88 100644 --- a/tests/ovn-performance.at +++ b/tests/ovn-performance.at @@ -251,7 +251,7 @@ for i in `seq 1 5`; do for j in `seq 1 5`; do if [[ $i -ne $j ]] ; then OVS_WAIT_UNTIL([ - test $(as hv$i ovs-vsctl list interface ovn-hv$j-0 | \ + test $(as hv$i ovs-vsctl list interface ovn-hv$i-hv$j-0 | \ grep -c tunnel_egress_iface_carrier=up) -eq 1 ]) fi @@ -519,7 +519,7 @@ OVN_CONTROLLER_EXPECT_HIT( # Make hv4 master. There is remote possibility that full recompute # triggers for hv1-hv5 after hv4 becomes master because of updates to the -# ovn-hv$i-0 interfaces. Most of the time there will be no recompute. +# ovn-hv$i-hv$j-0 interfaces. Most of the time there will be no recompute. ovn-nbctl --wait=hv lrp-set-gateway-chassis lr1-public hv4 40 hv4_ch=$(ovn-sbctl --bare --columns _uuid list chassis hv4) OVS_WAIT_UNTIL([ovn-sbctl find port_binding logical_port=cr-lr1-public chassis=$hv4_ch]) diff --git a/tests/ovn.at b/tests/ovn.at index 80e9192ca..c03ff4f17 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -11007,8 +11007,8 @@ AT_CHECK([ovn-nbctl --wait=sb sync], [0], [ignore]) ovn-sbctl dump-flows > sbflows AT_CAPTURE_FILE([sbflows]) -hv1_gw1_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw1-0) -hv1_gw2_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw2-0) +hv1_gw1_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv1-gw1-0) +hv1_gw2_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv1-gw2-0) OVS_WAIT_UNTIL([ test 1 = $(as hv1 ovs-ofctl dump-flows br-int table=37 | grep -c "active_backup,ofport,members:$hv1_gw1_ofport,$hv1_gw2_ofport") @@ -11141,7 +11141,7 @@ AT_CHECK([test $gw2_claim_ct = `cat gw2/ovn-controller.log | \ grep -c "cr-alice: Claiming"`]) OVS_WAIT_UNTIL([ - bfd_status=$(as hv1 ovs-vsctl get interface ovn-gw2-0 bfd_status:state) + bfd_status=$(as hv1 ovs-vsctl get interface ovn-hv1-gw2-0 bfd_status:state) echo "bfd status = $bfd_status" test "$bfd_status" = "down" ]) @@ -11291,8 +11291,8 @@ wait_column "$hv1_ch_uuid" HA_Chassis_Group ref_chassis # Allow some time for ovn-northd and ovn-controller to catch up. check ovn-nbctl --wait=hv sync -hv1_gw1_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw1-0) -hv1_gw2_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw2-0) +hv1_gw1_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv1-gw1-0) +hv1_gw2_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv1-gw2-0) OVS_WAIT_UNTIL([ test 1 = $(as hv1 ovs-ofctl dump-flows br-int table=37 | grep -c "active_backup,ofport,members:$hv1_gw1_ofport,$hv1_gw2_ofport") @@ -13039,10 +13039,10 @@ bfd_dump() { bfd_dump -hv1_gw1_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw1-0) -hv1_gw2_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw2-0) -hv2_gw1_ofport=$(as hv2 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw1-0) -hv2_gw2_ofport=$(as hv2 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw2-0) +hv1_gw1_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv1-gw1-0) +hv1_gw2_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv1-gw2-0) +hv2_gw1_ofport=$(as hv2 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv2-gw1-0) +hv2_gw2_ofport=$(as hv2 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv2-gw2-0) echo $hv1_gw1_ofport echo $hv1_gw2_ofport @@ -13121,7 +13121,7 @@ wait_row_count Port_Binding 1 logical_port=cr-outside chassis=$gw2_chassis as gw1 for chassis in gw2 hv1 hv2; do echo "checking gw1 -> $chassis" - AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], + AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-gw1-$chassis-0],[0], [[enable=true ]]) done @@ -13131,7 +13131,7 @@ done as gw2 for chassis in gw1 hv1 hv2; do echo "checking gw2 -> $chassis" - AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], + AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-gw2-$chassis-0],[0], [[enable=true ]]) done @@ -13140,12 +13140,12 @@ done as hv1 for chassis in gw1 gw2; do echo "checking hv1 -> $chassis" - AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], + AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv1-$chassis-0],[0], [[enable=true ]]) done # make sure BFD is not enabled to hv2, we don't need it -AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-0],[0], +AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv1-hv2-0],[0], [[ ]]) @@ -13154,12 +13154,12 @@ AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-0],[0], as hv2 for chassis in gw1 gw2; do echo "checking hv2 -> $chassis" - AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], + AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-$chassis-0],[0], [[enable=true ]]) done # make sure BFD is not enabled to hv1, we don't need it -AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv1-0],[0], +AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-hv1-0],[0], [[ ]]) @@ -13194,7 +13194,7 @@ as gw2 for chassis in gw1 hv1 hv2; do echo "checking gw2 -> $chassis" OVS_WAIT_UNTIL([ - bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0) + bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-gw2-$chassis-0) test "$bfd_cfg" = "enable=true min_rx=2000" ]) done @@ -13202,7 +13202,7 @@ ovn-nbctl --wait=hv set NB_Global . options:"bfd-min-tx"=1500 for chassis in gw1 hv1 hv2; do echo "checking gw2 -> $chassis" OVS_WAIT_UNTIL([ - bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0) + bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-gw2-$chassis-0) test "$bfd_cfg" = "enable=true min_rx=2000 min_tx=1500" ]) done @@ -13211,7 +13211,7 @@ ovn-nbctl --wait=hv set NB_Global . options:"bfd-mult"=5 for chassis in gw1 hv1 hv2; do echo "checking gw2 -> $chassis" OVS_WAIT_UNTIL([ - bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0) + bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-gw2-$chassis-0) test "$bfd_cfg" = "enable=true min_tx=1500 mult=5" ]) done @@ -13347,7 +13347,7 @@ grep active_backup | grep slaves:$hv2_gw2_ofport,$hv2_gw1_ofport \ as gw1 for chassis in gw2 hv1 hv2; do echo "checking gw1 -> $chassis" - AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], + AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-gw1-$chassis-0],[0], [[enable=true ]]) done @@ -13356,7 +13356,7 @@ done as gw2 for chassis in gw1 hv1 hv2; do echo "checking gw2 -> $chassis" - AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], + AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-gw2-$chassis-0],[0], [[enable=true ]]) done @@ -13365,12 +13365,12 @@ done as hv1 for chassis in gw1 gw2; do echo "checking hv1 -> $chassis" - AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], + AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv1-$chassis-0],[0], [[enable=true ]]) done # make sure BFD is not enabled to hv2, we don't need it -AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-0],[0], +AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv1-hv2-0],[0], [[ ]]) @@ -13378,12 +13378,12 @@ AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-0],[0], as hv2 for chassis in gw1 gw2; do echo "checking hv2 -> $chassis" - AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], + AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-$chassis-0],[0], [[enable=true ]]) done # make sure BFD is not enabled to hv1, we don't need it -AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv1-0],[0], +AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-hv1-0],[0], [[ ]]) @@ -19690,42 +19690,42 @@ check ovn-nbctl --wait=hv sync dnl Assert that each Chassis has a tunnel formed to every other Chassis as hv1 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv2-0 -ovn-hv3-0 -ovn-hv4-0 -ovn-hv5-0 +[[ovn-hv1-hv2-0 +ovn-hv1-hv3-0 +ovn-hv1-hv4-0 +ovn-hv1-hv5-0 ]]) as hv2 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv1-0 -ovn-hv3-0 -ovn-hv4-0 -ovn-hv5-0 +[[ovn-hv2-hv1-0 +ovn-hv2-hv3-0 +ovn-hv2-hv4-0 +ovn-hv2-hv5-0 ]]) as hv3 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv1-0 -ovn-hv2-0 -ovn-hv4-0 -ovn-hv5-0 +[[ovn-hv3-hv1-0 +ovn-hv3-hv2-0 +ovn-hv3-hv4-0 +ovn-hv3-hv5-0 ]]) as hv4 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv1-0 -ovn-hv2-0 -ovn-hv3-0 -ovn-hv5-0 +[[ovn-hv4-hv1-0 +ovn-hv4-hv2-0 +ovn-hv4-hv3-0 +ovn-hv4-hv5-0 ]]) as hv5 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv1-0 -ovn-hv2-0 -ovn-hv3-0 -ovn-hv4-0 +[[ovn-hv5-hv1-0 +ovn-hv5-hv2-0 +ovn-hv5-hv3-0 +ovn-hv5-hv4-0 ]]) dnl Let's now add some Chassis to different transport zones @@ -19756,28 +19756,28 @@ check ovn-nbctl --wait=hv sync as hv1 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv2-0 -ovn-hv3-0 +[[ovn-hv1-hv2-0 +ovn-hv1-hv3-0 ]]) as hv2 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv1-0 +[[ovn-hv2-hv1-0 ]]) as hv3 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv1-0 +[[ovn-hv3-hv1-0 ]]) as hv4 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv5-0 +[[ovn-hv4-hv5-0 ]]) as hv5 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv4-0 +[[ovn-hv5-hv4-0 ]]) dnl Removing the transport zones should make all Chassis to create @@ -19792,42 +19792,42 @@ check ovn-nbctl --wait=hv sync as hv1 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv2-0 -ovn-hv3-0 -ovn-hv4-0 -ovn-hv5-0 +[[ovn-hv1-hv2-0 +ovn-hv1-hv3-0 +ovn-hv1-hv4-0 +ovn-hv1-hv5-0 ]]) as hv2 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv1-0 -ovn-hv3-0 -ovn-hv4-0 -ovn-hv5-0 +[[ovn-hv2-hv1-0 +ovn-hv2-hv3-0 +ovn-hv2-hv4-0 +ovn-hv2-hv5-0 ]]) as hv3 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv1-0 -ovn-hv2-0 -ovn-hv4-0 -ovn-hv5-0 +[[ovn-hv3-hv1-0 +ovn-hv3-hv2-0 +ovn-hv3-hv4-0 +ovn-hv3-hv5-0 ]]) as hv4 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv1-0 -ovn-hv2-0 -ovn-hv3-0 -ovn-hv5-0 +[[ovn-hv4-hv1-0 +ovn-hv4-hv2-0 +ovn-hv4-hv3-0 +ovn-hv4-hv5-0 ]]) as hv5 AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], -[[ovn-hv1-0 -ovn-hv2-0 -ovn-hv3-0 -ovn-hv4-0 +[[ovn-hv5-hv1-0 +ovn-hv5-hv2-0 +ovn-hv5-hv3-0 +ovn-hv5-hv4-0 ]]) OVN_CLEANUP([hv1], [hv2], [hv3]) @@ -25690,14 +25690,14 @@ check ovn-nbctl fwd-group-del fwd_grp1 check ovn-nbctl --wait=hv --liveness fwd-group-add fwd_grp1 ls2 172.16.1.11 00:11:de:ad:be:ef lsp21 lsp22 # Verify openflow group members -ofport_lsp21=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv2-0) +ofport_lsp21=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv1-hv2-0) tunnel_key=`ovn-sbctl --bare --column tunnel_key find port_binding logical_port=lsp21` AT_CHECK([as hv1 ovs-ofctl -O OpenFlow13 dump-groups br-int | \ grep "bucket=watch_port:$ofport_lsp21,actions=load:0x"$tunnel_key | wc -l], [0], [dnl 1 ]) -ofport_lsp22=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv3-0) +ofport_lsp22=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-hv1-hv3-0) tunnel_key=`ovn-sbctl --bare --column tunnel_key find port_binding logical_port=lsp22` AT_CHECK([as hv1 ovs-ofctl -O OpenFlow13 dump-groups br-int | \ grep "bucket=watch_port:$ofport_lsp22,actions=load:0x"$tunnel_key | wc -l], [0], [dnl From patchwork Tue Sep 20 00:04:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1679825 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=VgaEZeae; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MWhdK4s4pz1yp7 for ; Tue, 20 Sep 2022 10:05:25 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 161FB823AB; Tue, 20 Sep 2022 00:05:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 161FB823AB Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VgaEZeae X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hSPZ2IQb_wSz; Tue, 20 Sep 2022 00:05:16 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 6707381CE3; Tue, 20 Sep 2022 00:05:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 6707381CE3 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3E50BC0032; Tue, 20 Sep 2022 00:05:14 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3CAB9C0081 for ; Tue, 20 Sep 2022 00:05:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A840D60B36 for ; Tue, 20 Sep 2022 00:05:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A840D60B36 Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VgaEZeae X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y9intqeNCse6 for ; Tue, 20 Sep 2022 00:05:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org BF38D60AFE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id BF38D60AFE for ; Tue, 20 Sep 2022 00:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663632306; 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: in-reply-to:in-reply-to:references:references; bh=HC/VWMcH78GxKKnVyyvJ7O6Vi28a/MQzG98+0HOR8sY=; b=VgaEZeae8h8sMubQIlIzsSBAK6sTZDGPUNtQPogfQl0xZWJN7bK2ijzamaEMoTvZTaXfl7 cOICIiA12Bst7Q54icUPEJJTVNhNeyC3wD1Sl6wsXzqKtZIiUkZh5DDEVm7uXMNlxkPr6W wNZeVDdfWfz6RDH92zcAmL6lq8j8Kbo= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-90-_BOyvwphOS2_nWFGryMRqQ-1; Mon, 19 Sep 2022 20:05:05 -0400 X-MC-Unique: _BOyvwphOS2_nWFGryMRqQ-1 Received: by mail-qv1-f69.google.com with SMTP id nm17-20020a0562143b1100b004a5a3002d87so840830qvb.8 for ; Mon, 19 Sep 2022 17:05:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=HC/VWMcH78GxKKnVyyvJ7O6Vi28a/MQzG98+0HOR8sY=; b=t324dOogHHNat+U3Q0jrG08JjT2Or4zqswfW8sctpDf56MLef4dMZmPTA0umdrJkYW 579zf6jNc20KxvskbLYZEDAlezzJiorf45Jca09mQgHVykI6mRPMPocE9yAHEZSAmqmJ H2QlRaAluqTJCrY+u7X9VBy4mkgbW3C6qDn+NbCyGmc1Z0GH0j4CT2EITUd2c7DAFSJe woO3uNKXEONNlVGDskf5kNC2QTnvdHeidFYY3LpojlhmeSgTK3W5L9ljd6AVf5PufX3J viBFrqaNCrKnpq89EvigUbilDUFWw2yG+UsnuEesMXQz+e8ikBeeetfSlOiFXYQNxVSg xTGA== X-Gm-Message-State: ACrzQf2Q0Pozg+DdpWDf2ksNNfM8Hymg03LjCiZQMm9bsKlsV9e6IpId EH1IqKxYbi6McogkDWgwdf+8B8QmC8l+kZpqFw2q7OBNJBVPUcH91todQKxNKwQMYP1PXqaqrZx ERAA3PkiIKg04g3gb4aaY/DE8UGRFLTpmzGiEUGSB2YDVgkPqjkG2UeWEsIfjkaCo X-Received: by 2002:ad4:5f4c:0:b0:4aa:7121:7a with SMTP id p12-20020ad45f4c000000b004aa7121007amr17150660qvg.63.1663632304283; Mon, 19 Sep 2022 17:05:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5trXCswft+pGpnJOZEzJxZzqy1Z1x6EMh+UvIey3KrRZ7yJlSvuy4fv4DQNoT5lMNt6wu8Vg== X-Received: by 2002:ad4:5f4c:0:b0:4aa:7121:7a with SMTP id p12-20020ad45f4c000000b004aa7121007amr17150601qvg.63.1663632303533; Mon, 19 Sep 2022 17:05:03 -0700 (PDT) Received: from fedora34.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a454c00b006aedb35d8a1sm14621611qkp.74.2022.09.19.17.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 17:05:01 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 20 Sep 2022 00:04:49 +0000 Message-Id: <20220920000453.357057-3-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920000453.357057-1-ihrachys@redhat.com> References: <20220920000453.357057-1-ihrachys@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 2/6] Support ovn-...- specific global ovsdb options 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" Before the patch, all controller instances were reading configuration from the same external-ids:ovn-* options. This patch adds support for distinct config otions for different chassis names stored in the same ovsdb global config object. To configure an option for a distinct chassis name, an admin may add a suffix with the desired chassis name to a config option. For example, if the following is configured in ovsdb, only a controller with the corresponding chassis name (either 'hv1' or 'hv2') would read just one of the following options: ovs-vsctl set open . external-ids:ovn-bridge-mappings-hv1=phys:br-phys-1 ovs-vsctl set open . external-ids:ovn-bridge-mappings-hv2=phys:br-phys-2 Chassis specific config options override any global settings, so for example if the following configuration is used, then controller 'hv1' will use the first setting but not the latter. Any other controllers will use the global setting, which is the second setting.. ovs-vsctl set open . external-ids:ovn-bridge-mappings-hv1=phys:br-phys-1 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys-2 This is supported for other options too. This is in preparation to support running multiple controller instances using the same vswitchd instance. Signed-off-by: Ihar Hrachyshka --- controller/chassis.c | 151 +++++++++++++++++++++++------------- controller/chassis.h | 6 +- controller/encaps.c | 13 ++-- controller/ovn-controller.c | 121 ++++++++++++++++------------- controller/patch.c | 5 +- controller/physical.c | 2 +- lib/ovn-util.c | 87 +++++++++++++++++++++ lib/ovn-util.h | 26 +++++++ tests/automake.mk | 1 + tests/ovn-macros.at | 4 +- tests/ovn.at | 41 ++++++++++ 11 files changed, 337 insertions(+), 120 deletions(-) diff --git a/controller/chassis.c b/controller/chassis.c index 685d9b2ae..241913d1f 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -93,9 +93,10 @@ chassis_register_ovs_idl(struct ovsdb_idl *ovs_idl) } static const char * -get_hostname(const struct smap *ext_ids) +get_hostname(const struct smap *ext_ids, const char *chassis_id) { - const char *hostname = smap_get_def(ext_ids, "hostname", ""); + const char *hostname = get_chassis_external_id_value(ext_ids, chassis_id, + "hostname", ""); if (strlen(hostname) == 0) { static char hostname_[HOST_NAME_MAX + 1]; @@ -111,69 +112,81 @@ get_hostname(const struct smap *ext_ids) } static const char * -get_bridge_mappings(const struct smap *ext_ids) +get_bridge_mappings(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-bridge-mappings", ""); + return get_chassis_external_id_value(ext_ids, chassis_id, + "ovn-bridge-mappings", ""); } const char * -get_chassis_mac_mappings(const struct smap *ext_ids) +get_chassis_mac_mappings(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-chassis-mac-mappings", ""); + return get_chassis_external_id_value(ext_ids, chassis_id, + "ovn-chassis-mac-mappings", ""); } static const char * -get_cms_options(const struct smap *ext_ids) +get_cms_options(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-cms-options", ""); + return get_chassis_external_id_value(ext_ids, chassis_id, + "ovn-cms-options", ""); } static const char * -get_monitor_all(const struct smap *ext_ids) +get_monitor_all(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-monitor-all", "false"); + return get_chassis_external_id_value(ext_ids, chassis_id, + "ovn-monitor-all", "false"); } static const char * -get_enable_lflow_cache(const struct smap *ext_ids) +get_enable_lflow_cache(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-enable-lflow-cache", "true"); + return get_chassis_external_id_value(ext_ids, chassis_id, + "ovn-enable-lflow-cache", "true"); } static const char * -get_limit_lflow_cache(const struct smap *ext_ids) +get_limit_lflow_cache(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-limit-lflow-cache", ""); + return get_chassis_external_id_value(ext_ids, chassis_id, + "ovn-limit-lflow-cache", ""); } static const char * -get_memlimit_lflow_cache(const struct smap *ext_ids) +get_memlimit_lflow_cache(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-memlimit-lflow-cache-kb", ""); + return get_chassis_external_id_value(ext_ids, chassis_id, + "ovn-memlimit-lflow-cache-kb", ""); } static const char * -get_trim_limit_lflow_cache(const struct smap *ext_ids) +get_trim_limit_lflow_cache(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-trim-limit-lflow-cache", ""); + return get_chassis_external_id_value(ext_ids, chassis_id, + "ovn-trim-limit-lflow-cache", ""); } static const char * -get_trim_wmark_perc_lflow_cache(const struct smap *ext_ids) +get_trim_wmark_perc_lflow_cache(const struct smap *ext_ids, + const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-trim-wmark-perc-lflow-cache", ""); + return get_chassis_external_id_value( + ext_ids, chassis_id, "ovn-trim-wmark-perc-lflow-cache", ""); } static const char * -get_trim_timeout(const struct smap *ext_ids) +get_trim_timeout(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-trim-timeout-ms", ""); + return get_chassis_external_id_value(ext_ids, chassis_id, + "ovn-trim-timeout-ms", ""); } static const char * -get_encap_csum(const struct smap *ext_ids) +get_encap_csum(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_def(ext_ids, "ovn-encap-csum", "true"); + return get_chassis_external_id_value(ext_ids, chassis_id, + "ovn-encap-csum", "true"); } static const char * @@ -187,9 +200,10 @@ get_datapath_type(const struct ovsrec_bridge *br_int) } static bool -get_is_interconn(const struct smap *ext_ids) +get_is_interconn(const struct smap *ext_ids, const char *chassis_id) { - return smap_get_bool(ext_ids, "ovn-is-interconn", false); + return get_chassis_external_id_value_bool(ext_ids, chassis_id, + "ovn-is-interconn", false); } static void @@ -260,6 +274,22 @@ chassis_parse_ovs_iface_types(char **iface_types, size_t n_iface_types, return true; } +const char * +get_ovs_chassis_id(const struct ovsrec_open_vswitch_table *ovs_table) +{ + const struct ovsrec_open_vswitch *cfg + = ovsrec_open_vswitch_table_first(ovs_table); + const char *chassis_id = cfg ? smap_get(&cfg->external_ids, "system-id") + : NULL; + + if (!chassis_id) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); + VLOG_WARN_RL(&rl, "'system-id' in Open_vSwitch database is missing."); + } + + return chassis_id; +} + /* * Parse the 'ovs_table' entry and populate 'ovs_cfg'. */ @@ -276,30 +306,39 @@ chassis_parse_ovs_config(const struct ovsrec_open_vswitch_table *ovs_table, return false; } - const char *encap_type = smap_get(&cfg->external_ids, "ovn-encap-type"); - const char *encap_ips = smap_get(&cfg->external_ids, "ovn-encap-ip"); + const char *chassis_id = get_ovs_chassis_id(ovs_table); + const char *encap_type = get_chassis_external_id_value( + &cfg->external_ids, chassis_id, "ovn-encap-type", NULL); + + const char *encap_ips = get_chassis_external_id_value( + &cfg->external_ids, chassis_id, "ovn-encap-ip", NULL); if (!encap_type || !encap_ips) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); VLOG_INFO_RL(&rl, "Need to specify an encap type and ip"); return false; } - ovs_cfg->hostname = get_hostname(&cfg->external_ids); - ovs_cfg->bridge_mappings = get_bridge_mappings(&cfg->external_ids); + ovs_cfg->hostname = get_hostname(&cfg->external_ids, chassis_id); + ovs_cfg->bridge_mappings = get_bridge_mappings( + &cfg->external_ids, chassis_id); ovs_cfg->datapath_type = get_datapath_type(br_int); - ovs_cfg->encap_csum = get_encap_csum(&cfg->external_ids); - ovs_cfg->cms_options = get_cms_options(&cfg->external_ids); - ovs_cfg->monitor_all = get_monitor_all(&cfg->external_ids); - ovs_cfg->chassis_macs = get_chassis_mac_mappings(&cfg->external_ids); - ovs_cfg->enable_lflow_cache = get_enable_lflow_cache(&cfg->external_ids); - ovs_cfg->limit_lflow_cache = get_limit_lflow_cache(&cfg->external_ids); + ovs_cfg->encap_csum = get_encap_csum(&cfg->external_ids, chassis_id); + ovs_cfg->cms_options = get_cms_options(&cfg->external_ids, chassis_id); + ovs_cfg->monitor_all = get_monitor_all(&cfg->external_ids, chassis_id); + ovs_cfg->chassis_macs = get_chassis_mac_mappings( + &cfg->external_ids, chassis_id); + ovs_cfg->enable_lflow_cache = get_enable_lflow_cache( + &cfg->external_ids, chassis_id); + ovs_cfg->limit_lflow_cache = get_limit_lflow_cache( + &cfg->external_ids, chassis_id); ovs_cfg->memlimit_lflow_cache = - get_memlimit_lflow_cache(&cfg->external_ids); + get_memlimit_lflow_cache(&cfg->external_ids, chassis_id); ovs_cfg->trim_limit_lflow_cache = - get_trim_limit_lflow_cache(&cfg->external_ids); + get_trim_limit_lflow_cache(&cfg->external_ids, chassis_id); ovs_cfg->trim_wmark_perc_lflow_cache = - get_trim_wmark_perc_lflow_cache(&cfg->external_ids); - ovs_cfg->trim_timeout_ms = get_trim_timeout(&cfg->external_ids); + get_trim_wmark_perc_lflow_cache(&cfg->external_ids, chassis_id); + ovs_cfg->trim_timeout_ms = + get_trim_timeout(&cfg->external_ids, chassis_id); if (!chassis_parse_ovs_encap_type(encap_type, &ovs_cfg->encap_type_set)) { return false; @@ -322,7 +361,7 @@ chassis_parse_ovs_config(const struct ovsrec_open_vswitch_table *ovs_table, sset_destroy(&ovs_cfg->encap_ip_set); } - ovs_cfg->is_interconn = get_is_interconn(&cfg->external_ids); + ovs_cfg->is_interconn = get_is_interconn(&cfg->external_ids, chassis_id); return true; } @@ -362,7 +401,7 @@ chassis_other_config_changed(const struct ovs_chassis_cfg *ovs_cfg, const struct sbrec_chassis *chassis_rec) { const char *chassis_bridge_mappings = - get_bridge_mappings(&chassis_rec->other_config); + get_bridge_mappings(&chassis_rec->other_config, chassis_rec->name); if (strcmp(ovs_cfg->bridge_mappings, chassis_bridge_mappings)) { return true; @@ -376,42 +415,42 @@ chassis_other_config_changed(const struct ovs_chassis_cfg *ovs_cfg, } const char *chassis_cms_options = - get_cms_options(&chassis_rec->other_config); + get_cms_options(&chassis_rec->other_config, chassis_rec->name); if (strcmp(ovs_cfg->cms_options, chassis_cms_options)) { return true; } const char *chassis_monitor_all = - get_monitor_all(&chassis_rec->other_config); + get_monitor_all(&chassis_rec->other_config, chassis_rec->name); if (strcmp(ovs_cfg->monitor_all, chassis_monitor_all)) { return true; } const char *chassis_enable_lflow_cache = - get_enable_lflow_cache(&chassis_rec->other_config); + get_enable_lflow_cache(&chassis_rec->other_config, chassis_rec->name); if (strcmp(ovs_cfg->enable_lflow_cache, chassis_enable_lflow_cache)) { return true; } const char *chassis_limit_lflow_cache = - get_limit_lflow_cache(&chassis_rec->other_config); + get_limit_lflow_cache(&chassis_rec->other_config, chassis_rec->name); if (strcmp(ovs_cfg->limit_lflow_cache, chassis_limit_lflow_cache)) { return true; } - const char *chassis_memlimit_lflow_cache = - get_memlimit_lflow_cache(&chassis_rec->other_config); + const char *chassis_memlimit_lflow_cache = get_memlimit_lflow_cache( + &chassis_rec->other_config, chassis_rec->name); if (strcmp(ovs_cfg->memlimit_lflow_cache, chassis_memlimit_lflow_cache)) { return true; } - const char *chassis_trim_limit_lflow_cache = - get_trim_limit_lflow_cache(&chassis_rec->other_config); + const char *chassis_trim_limit_lflow_cache = get_trim_limit_lflow_cache( + &chassis_rec->other_config, chassis_rec->name); if (strcmp(ovs_cfg->trim_limit_lflow_cache, chassis_trim_limit_lflow_cache)) { @@ -419,7 +458,8 @@ chassis_other_config_changed(const struct ovs_chassis_cfg *ovs_cfg, } const char *chassis_trim_wmark_perc_lflow_cache = - get_trim_wmark_perc_lflow_cache(&chassis_rec->other_config); + get_trim_wmark_perc_lflow_cache( + &chassis_rec->other_config, chassis_rec->name); if (strcmp(ovs_cfg->trim_wmark_perc_lflow_cache, chassis_trim_wmark_perc_lflow_cache)) { @@ -427,14 +467,14 @@ chassis_other_config_changed(const struct ovs_chassis_cfg *ovs_cfg, } const char *chassis_trim_timeout_ms = - get_trim_timeout(&chassis_rec->other_config); + get_trim_timeout(&chassis_rec->other_config, chassis_rec->name); if (strcmp(ovs_cfg->trim_timeout_ms, chassis_trim_timeout_ms)) { return true; } - const char *chassis_mac_mappings = - get_chassis_mac_mappings(&chassis_rec->other_config); + const char *chassis_mac_mappings = get_chassis_mac_mappings( + &chassis_rec->other_config, chassis_rec->name); if (strcmp(ovs_cfg->chassis_macs, chassis_mac_mappings)) { return true; } @@ -755,7 +795,8 @@ chassis_get_mac(const struct sbrec_chassis *chassis_rec, struct eth_addr *chassis_mac) { const char *tokens - = get_chassis_mac_mappings(&chassis_rec->other_config); + = get_chassis_mac_mappings(&chassis_rec->other_config, + chassis_rec->name); if (!tokens[0]) { return false; } diff --git a/controller/chassis.h b/controller/chassis.h index 18b45a1c5..05a96bb0c 100644 --- a/controller/chassis.h +++ b/controller/chassis.h @@ -46,7 +46,9 @@ bool chassis_cleanup(struct ovsdb_idl_txn *ovnsb_idl_txn, bool chassis_get_mac(const struct sbrec_chassis *chassis, const char *bridge_mapping, struct eth_addr *chassis_mac); -const char * get_chassis_mac_mappings(const struct smap *ext_ids); - +const char * get_chassis_mac_mappings(const struct smap *ext_ids, + const char *chassis_id); +const char * +get_ovs_chassis_id(const struct ovsrec_open_vswitch_table *ovs_table); #endif /* controller/chassis.h */ diff --git a/controller/encaps.c b/controller/encaps.c index e6b2aa074..572c38542 100644 --- a/controller/encaps.c +++ b/controller/encaps.c @@ -184,7 +184,8 @@ tunnel_add(struct tunnel_ctx *tc, const struct sbrec_sb_global *sbg, bool set_local_ip = false; if (cfg) { /* If the tos option is configured, get it */ - const char *encap_tos = smap_get_def(&cfg->external_ids, + const char *encap_tos = get_chassis_external_id_value( + &cfg->external_ids, tc->this_chassis->name, "ovn-encap-tos", "none"); if (encap_tos && strcmp(encap_tos, "none")) { @@ -193,15 +194,17 @@ tunnel_add(struct tunnel_ctx *tc, const struct sbrec_sb_global *sbg, /* If the df_default option is configured, get it */ - const char *encap_df = smap_get(&cfg->external_ids, - "ovn-encap-df_default"); + const char *encap_df = get_chassis_external_id_value( + &cfg->external_ids, tc->this_chassis->name, + "ovn-encap-df_default", NULL); if (encap_df) { smap_add(&options, "df_default", encap_df); } /* If ovn-set-local-ip option is configured, get it */ - set_local_ip = smap_get_bool(&cfg->external_ids, "ovn-set-local-ip", - false); + set_local_ip = get_chassis_external_id_value_bool( + &cfg->external_ids, tc->this_chassis->name, + "ovn-set-local-ip", false); } /* Add auth info if ipsec is enabled. */ diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 43fbf2ba3..59ae732b3 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -310,9 +310,13 @@ out:; } static const char * -br_int_name(const struct ovsrec_open_vswitch *cfg) +br_int_name(const struct ovsrec_open_vswitch_table *ovs_table) { - return smap_get_def(&cfg->external_ids, "ovn-bridge", DEFAULT_BRIDGE_NAME); + const struct ovsrec_open_vswitch *cfg = + ovsrec_open_vswitch_table_first(ovs_table); + const char *chassis_id = get_ovs_chassis_id(ovs_table); + return get_chassis_external_id_value(&cfg->external_ids, chassis_id, + "ovn-bridge", DEFAULT_BRIDGE_NAME); } static const struct ovsrec_bridge * @@ -324,7 +328,7 @@ create_br_int(struct ovsdb_idl_txn *ovs_idl_txn, if (!cfg) { return NULL; } - const char *bridge_name = br_int_name(cfg); + const char *bridge_name = br_int_name(ovs_table); ovsdb_idl_txn_add_comment(ovs_idl_txn, "ovn-controller: creating integration bridge '%s'", bridge_name); @@ -409,7 +413,7 @@ get_br_int(const struct ovsrec_bridge_table *bridge_table, return NULL; } - return get_bridge(bridge_table, br_int_name(cfg)); + return get_bridge(bridge_table, br_int_name(ovs_table)); } static const struct ovsrec_datapath * @@ -448,8 +452,10 @@ process_br_int(struct ovsdb_idl_txn *ovs_idl_txn, * Otherwise use the datapath-type set in br-int, if any. * Finally, assume "system" datapath if none configured. */ - const char *datapath_type = - smap_get(&cfg->external_ids, "ovn-bridge-datapath-type"); + const char *chassis_id = get_ovs_chassis_id(ovs_table); + const char *datapath_type = get_chassis_external_id_value( + &cfg->external_ids, chassis_id, + "ovn-bridge-datapath-type", NULL); if (!datapath_type) { if (br_int->datapath_type[0]) { @@ -477,22 +483,6 @@ process_br_int(struct ovsdb_idl_txn *ovs_idl_txn, *br_int_ = br_int; } -static const char * -get_ovs_chassis_id(const struct ovsrec_open_vswitch_table *ovs_table) -{ - const struct ovsrec_open_vswitch *cfg - = ovsrec_open_vswitch_table_first(ovs_table); - const char *chassis_id = cfg ? smap_get(&cfg->external_ids, "system-id") - : NULL; - - if (!chassis_id) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); - VLOG_WARN_RL(&rl, "'system-id' in Open_vSwitch database is missing."); - } - - return chassis_id; -} - static void update_ssl_config(const struct ovsrec_ssl_table *ssl_table) { @@ -516,10 +506,16 @@ static int get_ofctrl_probe_interval(struct ovsdb_idl *ovs_idl) { const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(ovs_idl); - return !cfg ? OFCTRL_DEFAULT_PROBE_INTERVAL_SEC : - smap_get_int(&cfg->external_ids, - "ovn-openflow-probe-interval", - OFCTRL_DEFAULT_PROBE_INTERVAL_SEC); + if (!cfg) { + return OFCTRL_DEFAULT_PROBE_INTERVAL_SEC; + } + + const struct ovsrec_open_vswitch_table *ovs_table = + ovsrec_open_vswitch_table_get(ovs_idl); + const char *chassis_id = get_ovs_chassis_id(ovs_table); + return get_chassis_external_id_value_int( + &cfg->external_ids, chassis_id, + "ovn-openflow-probe-interval", OFCTRL_DEFAULT_PROBE_INTERVAL_SEC); } /* Retrieves the pointer to the OVN Southbound database from 'ovs_idl' and @@ -536,18 +532,23 @@ update_sb_db(struct ovsdb_idl *ovs_idl, struct ovsdb_idl *ovnsb_idl, } /* Set remote based on user configuration. */ - const char *remote = smap_get(&cfg->external_ids, "ovn-remote"); + const struct ovsrec_open_vswitch_table *ovs_table = + ovsrec_open_vswitch_table_get(ovs_idl); + const char *chassis_id = get_ovs_chassis_id(ovs_table); + const char *remote = get_chassis_external_id_value( + &cfg->external_ids, chassis_id, "ovn-remote", NULL); ovsdb_idl_set_remote(ovnsb_idl, remote, true); /* Set probe interval, based on user configuration and the remote. */ int default_interval = (remote && !stream_or_pstream_needs_probes(remote) ? 0 : DEFAULT_PROBE_INTERVAL_MSEC); - int interval = smap_get_int(&cfg->external_ids, - "ovn-remote-probe-interval", default_interval); + int interval = get_chassis_external_id_value_int( + &cfg->external_ids, chassis_id, + "ovn-remote-probe-interval", default_interval); ovsdb_idl_set_probe_interval(ovnsb_idl, interval); - bool monitor_all = smap_get_bool(&cfg->external_ids, "ovn-monitor-all", - false); + bool monitor_all = get_chassis_external_id_value_bool( + &cfg->external_ids, chassis_id, "ovn-monitor-all", false); if (monitor_all) { /* Always call update_sb_monitors when monitor_all is true. * Otherwise, don't call it here, because there would be unnecessary @@ -570,25 +571,31 @@ update_sb_db(struct ovsdb_idl *ovs_idl, struct ovsdb_idl *ovnsb_idl, } if (ctx) { - lflow_cache_enable(ctx->lflow_cache, - smap_get_bool(&cfg->external_ids, - "ovn-enable-lflow-cache", - true), - smap_get_uint(&cfg->external_ids, - "ovn-limit-lflow-cache", - DEFAULT_LFLOW_CACHE_MAX_ENTRIES), - smap_get_ullong(&cfg->external_ids, - "ovn-memlimit-lflow-cache-kb", - DEFAULT_LFLOW_CACHE_MAX_MEM_KB), - smap_get_uint(&cfg->external_ids, - "ovn-trim-limit-lflow-cache", - DEFAULT_LFLOW_CACHE_TRIM_LIMIT), - smap_get_uint(&cfg->external_ids, - "ovn-trim-wmark-perc-lflow-cache", - DEFAULT_LFLOW_CACHE_WMARK_PERC), - smap_get_uint(&cfg->external_ids, - "ovn-trim-timeout-ms", - DEFAULT_LFLOW_CACHE_TRIM_TO_MS)); + lflow_cache_enable( + ctx->lflow_cache, + get_chassis_external_id_value_bool( + &cfg->external_ids, chassis_id, + "ovn-enable-lflow-cache", true), + get_chassis_external_id_value_uint( + &cfg->external_ids, chassis_id, + "ovn-limit-lflow-cache", + DEFAULT_LFLOW_CACHE_MAX_ENTRIES), + get_chassis_external_id_value_ullong( + &cfg->external_ids, chassis_id, + "ovn-memlimit-lflow-cache-kb", + DEFAULT_LFLOW_CACHE_MAX_MEM_KB), + get_chassis_external_id_value_uint( + &cfg->external_ids, chassis_id, + "ovn-trim-limit-lflow-cache", + DEFAULT_LFLOW_CACHE_TRIM_LIMIT), + get_chassis_external_id_value_uint( + &cfg->external_ids, chassis_id, + "ovn-trim-wmark-perc-lflow-cache", + DEFAULT_LFLOW_CACHE_WMARK_PERC), + get_chassis_external_id_value_uint( + &cfg->external_ids, chassis_id, + "ovn-trim-timeout-ms", + DEFAULT_LFLOW_CACHE_TRIM_TO_MS)); } } @@ -811,7 +818,7 @@ restore_ct_zones(const struct ovsrec_bridge_table *bridge_table, } const struct ovsrec_bridge *br_int; - br_int = get_bridge(bridge_table, br_int_name(cfg)); + br_int = get_bridge(bridge_table, br_int_name(ovs_table)); if (!br_int) { /* If the integration bridge hasn't been defined, assume that * any existing ct-zone definitions aren't valid. */ @@ -920,7 +927,9 @@ get_transport_zones(const struct ovsrec_open_vswitch_table *ovs_table) { const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_table_first(ovs_table); - return smap_get_def(&cfg->external_ids, "ovn-transport-zones", ""); + const char *chassis_id = get_ovs_chassis_id(ovs_table); + return get_chassis_external_id_value(&cfg->external_ids, chassis_id, + "ovn-transport-zones", ""); } static void @@ -3464,8 +3473,12 @@ check_northd_version(struct ovsdb_idl *ovs_idl, struct ovsdb_idl *ovnsb_idl, static bool version_mismatch; const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(ovs_idl); - if (!cfg || !smap_get_bool(&cfg->external_ids, "ovn-match-northd-version", - false)) { + const struct ovsrec_open_vswitch_table *ovs_table = + ovsrec_open_vswitch_table_get(ovs_idl); + const char *chassis_id = get_ovs_chassis_id(ovs_table); + if (!cfg || !get_chassis_external_id_value_bool( + &cfg->external_ids, chassis_id, + "ovn-match-northd-version", false)) { version_mismatch = false; return true; } diff --git a/controller/patch.c b/controller/patch.c index 12e0b6f7c..166fb4678 100644 --- a/controller/patch.c +++ b/controller/patch.c @@ -15,6 +15,7 @@ #include +#include "chassis.h" #include "patch.h" #include "ovsport.h" @@ -131,7 +132,9 @@ add_ovs_bridge_mappings(const struct ovsrec_open_vswitch_table *ovs_table, const char *mappings_cfg; char *cur, *next, *start; - mappings_cfg = smap_get(&cfg->external_ids, "ovn-bridge-mappings"); + const char *chassis_id = get_ovs_chassis_id(ovs_table); + mappings_cfg = get_chassis_external_id_value( + &cfg->external_ids, chassis_id, "ovn-bridge-mappings", NULL); if (!mappings_cfg || !mappings_cfg[0]) { return; } diff --git a/controller/physical.c b/controller/physical.c index f3c8bddce..6ce790f14 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -503,7 +503,7 @@ populate_remote_chassis_macs(const struct sbrec_chassis *my_chassis, } const char *tokens - = get_chassis_mac_mappings(&chassis->other_config); + = get_chassis_mac_mappings(&chassis->other_config, chassis->name); if (!strlen(tokens)) { continue; diff --git a/lib/ovn-util.c b/lib/ovn-util.c index d80db179a..ae9481403 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -935,3 +935,90 @@ daemon_started_recently(void) /* Ensure that at least an amount of time has passed. */ return time_wall_msec() - startup_ts <= DAEMON_STARTUP_DELAY_MS; } + +const char * +get_chassis_external_id_value(const struct smap *external_ids, + const char *chassis_id, + const char *option_key, + const char *def) +{ + const char *option_value = NULL; + if (chassis_id) { + char *chassis_option_key = xasprintf("%s-%s", option_key, chassis_id); + option_value = smap_get(external_ids, chassis_option_key); + free(chassis_option_key); + } + if (!option_value) { + option_value = smap_get_def(external_ids, option_key, def); + } + return option_value; +} + +int +get_chassis_external_id_value_int(const struct smap *external_ids, + const char *chassis_id, + const char *option_key, + int def) +{ + const char *value = get_chassis_external_id_value( + external_ids, chassis_id, option_key, NULL); + + int i_value; + if (!value || !str_to_int(value, 10, &i_value)) { + return def; + } + + return i_value; +} + +unsigned int +get_chassis_external_id_value_uint(const struct smap *external_ids, + const char *chassis_id, + const char *option_key, + unsigned int def) +{ + const char *value = get_chassis_external_id_value( + external_ids, chassis_id, option_key, NULL); + + unsigned int u_value; + + if (!value || !str_to_uint(value, 10, &u_value)) { + return def; + } + + return u_value; +} + +unsigned long long int +get_chassis_external_id_value_ullong(const struct smap *external_ids, + const char *chassis_id, + const char *option_key, + unsigned long long int def) +{ + const char *value = get_chassis_external_id_value( + external_ids, chassis_id, option_key, NULL); + + unsigned long long ull_value; + + if (!value || !str_to_ullong(value, 10, &ull_value)) { + return def; + } + + return ull_value; +} + +bool +get_chassis_external_id_value_bool(const struct smap *external_ids, + const char *chassis_id, + const char *option_key, + bool def) +{ + const char *value = get_chassis_external_id_value( + external_ids, chassis_id, option_key, ""); + + if (def) { + return strcasecmp("false", value) != 0; + } else { + return !strcasecmp("true", value); + } +} diff --git a/lib/ovn-util.h b/lib/ovn-util.h index 145f974ed..2a19faa43 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -314,4 +314,30 @@ void daemon_started_recently_ignore(void); bool daemon_started_recently(void); int64_t daemon_startup_ts(void); +const char * +get_chassis_external_id_value(const struct smap *, + const char *chassis_id, + const char *option_key, + const char *def); +int +get_chassis_external_id_value_int(const struct smap *, + const char *chassis_id, + const char *option_key, + int def); +unsigned int +get_chassis_external_id_value_uint(const struct smap *, + const char *chassis_id, + const char *option_key, + unsigned int def); +unsigned long long int +get_chassis_external_id_value_ullong(const struct smap *external_ids, + const char *chassis_id, + const char *option_key, + unsigned long long int def); +bool +get_chassis_external_id_value_bool(const struct smap *, + const char *chassis_id, + const char *option_key, + bool def); + #endif /* OVN_UTIL_H */ diff --git a/tests/automake.mk b/tests/automake.mk index dce9c9108..d9f2777f3 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -253,6 +253,7 @@ tests_ovstest_SOURCES = \ tests_ovstest_LDADD = $(OVS_LIBDIR)/daemon.lo \ $(OVS_LIBDIR)/libopenvswitch.la lib/libovn.la \ controller/binding.$(OBJEXT) \ + controller/chassis.$(OBJEXT) \ controller/encaps.$(OBJEXT) \ controller/ha-chassis.$(OBJEXT) \ controller/if-status.$(OBJEXT) \ diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at index a3c7f8125..35b7b3872 100644 --- a/tests/ovn-macros.at +++ b/tests/ovn-macros.at @@ -290,7 +290,7 @@ net_attach () { # ovn_az_attach AZ NETWORK BRIDGE IP [MASKLEN] ovn_az_attach() { - local az=$1 net=$2 bridge=$3 ip=$4 masklen=${5-24} encap=${6-geneve,vxlan} + local az=$1 net=$2 bridge=$3 ip=$4 masklen=${5-24} encap=${6-geneve,vxlan} systemid=${7-$sandbox} net_attach $net $bridge || return 1 mac=`ovs-vsctl get Interface $bridge mac_in_use | sed s/\"//g` @@ -310,7 +310,7 @@ ovn_az_attach() { fi ovs-vsctl \ -- set Open_vSwitch . external-ids:hostname=$sandbox \ - -- set Open_vSwitch . external-ids:system-id=$sandbox \ + -- set Open_vSwitch . external-ids:system-id=$systemid \ -- set Open_vSwitch . external-ids:ovn-remote=$ovn_remote \ -- set Open_vSwitch . external-ids:ovn-encap-type=$encap \ -- set Open_vSwitch . external-ids:ovn-encap-ip=$ip \ diff --git a/tests/ovn.at b/tests/ovn.at index c03ff4f17..3614601e2 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -32889,3 +32889,44 @@ check ovn-nbctl --wait=hv sync OVN_CLEANUP([hv1]) AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD([ +AT_SETUP([chassis-specific configuration options]) +ovn_start +net_add n1 + +sim_add hv1 +as hv1 +ovs-vsctl add-br br-phys + +ovs-vsctl \ + -- set Open_vSwitch . external-ids:ovn-encap-type-hv3=geneve \ + -- set Open_vSwitch . external-ids:ovn-encap-ip-hv3=192.168.1.1 + +as hv1 ovs-vsctl set-ssl \ + $PKIDIR/testpki-hv3-privkey.pem \ + $PKIDIR/testpki-hv3-cert.pem \ + $PKIDIR/testpki-cacert.pem + +ovn_attach n1 br-phys 192.168.0.1 24 vxlan hv3 + +sim_add hv2 +as hv2 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.2 24 geneve + +# despite that we configured ovn-encap-ip=192.168.0.1, this setting is +# overridden by chassis specific ovn-encap-ip-hv3 +OVS_WAIT_UNTIL([ + test "1" = "$(ovn-sbctl list Encap | grep -c '192.168.1.1')" +]) + +encap_hv3_ip=$(fetch_column Encap ip chassis_name=hv3 type=geneve) +AT_CHECK(test x$encap_hv3_ip == x192.168.1.1) + +encap_hv1_ip=$(fetch_column Encap ip chassis_name=hv1 type=vxlan) +AT_CHECK(test x$encap_hv1_ip == x) + +OVN_CLEANUP([hv1],[hv2]) +AT_CLEANUP +]) From patchwork Tue Sep 20 00:04:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1679823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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=XF9Od7Ll; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MWhd947xVz1yp7 for ; Tue, 20 Sep 2022 10:05:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id BF4B360B46; Tue, 20 Sep 2022 00:05:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org BF4B360B46 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XF9Od7Ll X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TLi1neLnqWD3; Tue, 20 Sep 2022 00:05:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id A29A860B5A; Tue, 20 Sep 2022 00:05:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A29A860B5A Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 60878C007E; Tue, 20 Sep 2022 00:05:11 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 19C2CC0032 for ; Tue, 20 Sep 2022 00:05:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9E3E560B42 for ; Tue, 20 Sep 2022 00:05:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9E3E560B42 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kPvxpLA7VE3y for ; Tue, 20 Sep 2022 00:05:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B523160B10 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id B523160B10 for ; Tue, 20 Sep 2022 00:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663632307; 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: in-reply-to:in-reply-to:references:references; bh=tw/RmDHGFqmY7OLjMWP6IaVBUxwOtVifCFU6UvNU7Gs=; b=XF9Od7LleHOhe1hIx46eomgw0RmJmhSOj9Ubv6UZOjo3KEjHzDayIBGnAVhHJLHoE5GnTH E7E8psvnGKyNwIpZc3fuJ3OLbuJupJ1wYmOa+hlw1Sd8C4TttGraYHLoCvDMI4kc8iVP/A dBEGiJGoGuyNkyCxG39YygS+jYuWIho= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-314-SVqCiPBEMEe56gwKOtatkg-1; Mon, 19 Sep 2022 20:05:06 -0400 X-MC-Unique: SVqCiPBEMEe56gwKOtatkg-1 Received: by mail-qt1-f199.google.com with SMTP id b10-20020ac8540a000000b0035ba387b0d1so645489qtq.15 for ; Mon, 19 Sep 2022 17:05:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=tw/RmDHGFqmY7OLjMWP6IaVBUxwOtVifCFU6UvNU7Gs=; b=ceggVO67k28StppWkTAgSMaW77H9GBhrCuj4dfTL+8AdhexIIsvjyiFbAID8yldmll J7yfv4lAR/cAaAMkOjf19veiM+Q6hXDoGIsqzOHfmhY/aeKr2JooWHF8MlkVodXijq/r w+3ejEzJmzPD7tDYQ2zZaCyI/VYhK1TJwWgMQdJoP8J80HItgLoNOMqLaYFSfOtQ3t2a 93Zez5GmkTWFKAMYrwli09HoeaqmzVdFv2S/oR2wgk9vdZME7X6gEey/LAeHX3AFL6m7 +xIHTXKAP9l14ijGD6h32r6WznIWIhPSjS2Ni/oZi51/kxSFXxz5GIRb8Z27nr1ADx+c aD4Q== X-Gm-Message-State: ACrzQf0bHsfY3BqpRR6w0J4QVRu/FCgJjuIIhtXlzmvB4jG+IIAwf07S DaOTTwMRaJO+LkxWLGeixnaHOAcdiWHgfu2kPjKNhFvKiZnbmht85dE8f2I4Ju2L1u42VDsQ9Si auJ9ZcxJIfaiIFa9jxaIr/ufBz383t2X0VOZi0fwOjIlpxVir5pKU577eHNeoNjLf X-Received: by 2002:a05:620a:4081:b0:6ce:6253:b90c with SMTP id f1-20020a05620a408100b006ce6253b90cmr14725451qko.172.1663632305728; Mon, 19 Sep 2022 17:05:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6tAdEbNr4DBwJD5QGMKXrZy9qkgrWkTldsb8JqTR3Hw/PwUU5kgTCatD7J4HJPCVli7ja5aA== X-Received: by 2002:a05:620a:4081:b0:6ce:6253:b90c with SMTP id f1-20020a05620a408100b006ce6253b90cmr14725429qko.172.1663632305345; Mon, 19 Sep 2022 17:05:05 -0700 (PDT) Received: from fedora34.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a454c00b006aedb35d8a1sm14621611qkp.74.2022.09.19.17.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 17:05:04 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 20 Sep 2022 00:04:50 +0000 Message-Id: <20220920000453.357057-4-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920000453.357057-1-ihrachys@redhat.com> References: <20220920000453.357057-1-ihrachys@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 3/6] Allow to override system-id via file 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" Before the patch, system-id could be configured via a global config option in ovsdb. This patch adds another option - configure system-id via a file. This is achieved by writing the desired system-id into the following file location: ${OVN_SYSCONFDIR}/system-id-override. The file is read on controller startup. The file setting overrides configuration stored in ovsdb, if any. This may be useful when running multiple containerized controller instances using the same vswitchd. Signed-off-by: Ihar Hrachyshka Reviewed-by: Ales Musil --- controller/chassis.c | 6 ++++++ controller/chassis.h | 2 ++ controller/ovn-controller.c | 34 ++++++++++++++++++++++++++++++ tests/ovn.at | 42 +++++++++++++++++++++++++++++++++++++ tests/ovs-macros.at | 2 ++ 5 files changed, 86 insertions(+) diff --git a/controller/chassis.c b/controller/chassis.c index 241913d1f..bc8fb5282 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -37,6 +37,8 @@ VLOG_DEFINE_THIS_MODULE(chassis); #define HOST_NAME_MAX 255 #endif /* HOST_NAME_MAX */ +char *file_system_id = NULL; + /* * Structure for storing the chassis config parsed from the ovs table. */ @@ -277,6 +279,10 @@ chassis_parse_ovs_iface_types(char **iface_types, size_t n_iface_types, const char * get_ovs_chassis_id(const struct ovsrec_open_vswitch_table *ovs_table) { + if (file_system_id) { + return file_system_id; + } + const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_table_first(ovs_table); const char *chassis_id = cfg ? smap_get(&cfg->external_ids, "system-id") diff --git a/controller/chassis.h b/controller/chassis.h index 05a96bb0c..baa327059 100644 --- a/controller/chassis.h +++ b/controller/chassis.h @@ -31,6 +31,8 @@ struct sset; struct eth_addr; struct smap; +extern char *file_system_id; + void chassis_register_ovs_idl(struct ovsdb_idl *); const struct sbrec_chassis *chassis_run( struct ovsdb_idl_txn *ovnsb_idl_txn, diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 59ae732b3..c71b0851f 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -18,10 +18,14 @@ #include "ovn-controller.h" #include +#include #include #include #include #include +#include +#include +#include #include "bfd.h" #include "binding.h" @@ -55,6 +59,7 @@ #include "lib/ip-mcast-index.h" #include "lib/mac-binding-index.h" #include "lib/mcast-group-index.h" +#include "lib/ovn-dirs.h" #include "lib/ovn-sb-idl.h" #include "lib/ovn-util.h" #include "patch.h" @@ -151,6 +156,29 @@ struct pending_pkt { /* Registered ofctrl seqno type for nb_cfg propagation. */ static size_t ofctrl_seq_type_nb_cfg; +static char *get_file_system_id(void) +{ + char *ret = NULL; + char *filename = xasprintf("%s/system-id-override", ovn_sysconfdir()); + errno = 0; + int fd = open(filename, O_RDONLY); + if (fd != -1) { + char system_id[64]; + int nread = read(fd, system_id, sizeof system_id); + if (nread) { + system_id[nread] = '\0'; + if (system_id[nread - 1] == '\n') { + system_id[nread - 1] = '\0'; + } + ret = xstrdup(system_id); + } + close(fd); + } + + free(filename); + return ret; +} + static unsigned int update_sb_monitors(struct ovsdb_idl *ovnsb_idl, const struct sbrec_chassis *chassis, @@ -3519,6 +3547,9 @@ main(int argc, char *argv[]) struct ovn_controller_exit_args exit_args = {&exiting, &restart}; int retval; + /* Read from system-id-override file once on startup. */ + file_system_id = get_file_system_id(); + ovs_cmdl_proctitle_init(argc, argv); ovn_set_program_name(argv[0]); service_start(&argc, &argv); @@ -4485,6 +4516,9 @@ loop_done: ovs_feature_support_destroy(); free(ovs_remote); + if (file_system_id) { + free(file_system_id); + } service_stop(); exit(retval); diff --git a/tests/ovn.at b/tests/ovn.at index 3614601e2..5972089f1 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -32930,3 +32930,45 @@ AT_CHECK(test x$encap_hv1_ip == x) OVN_CLEANUP([hv1],[hv2]) AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD([ +AT_SETUP([chassis name override via file]) +ovn_start +net_add n1 + +sim_add hv1 +as hv1 +ovs-vsctl add-br br-phys + +ovs-vsctl \ + -- set Open_vSwitch . external-ids:ovn-encap-type-hv3=geneve \ + -- set Open_vSwitch . external-ids:ovn-encap-ip-hv3=192.168.1.1 + +as hv1 ovs-vsctl set-ssl \ + $PKIDIR/testpki-hv3-privkey.pem \ + $PKIDIR/testpki-hv3-cert.pem \ + $PKIDIR/testpki-cacert.pem + +echo hv3 > ${OVN_SYSCONFDIR}/system-id-override +ovn_attach n1 br-phys 192.168.0.1 24 vxlan + +sim_add hv2 +as hv2 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.2 24 geneve + +# despite that we configured ovn-encap-ip=192.168.0.1, this setting is +# overridden by chassis specific ovn-encap-ip-hv3 +OVS_WAIT_UNTIL([ + test "1" = "$(ovn-sbctl list Encap | grep -c '192.168.1.1')" +]) + +encap_hv3_ip=$(fetch_column Encap ip chassis_name=hv3 type=geneve) +AT_CHECK(test x$encap_hv3_ip == x192.168.1.1) + +encap_hv1_ip=$(fetch_column Encap ip chassis_name=hv1 type=vxlan) +AT_CHECK(test x$encap_hv1_ip == x) + +OVN_CLEANUP([hv1],[hv2]) +AT_CLEANUP +]) diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 5a06fe956..36b58b5ae 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -88,7 +88,9 @@ ovs_setenv() { OVS_LOGDIR=$ovs_dir; export OVS_LOGDIR OVS_DBDIR=$ovs_dir; export OVS_DBDIR OVS_SYSCONFDIR=$ovs_dir; export OVS_SYSCONFDIR + OVN_SYSCONFDIR=$ovs_dir; export OVN_SYSCONFDIR OVS_PKGDATADIR=$ovs_dir; export OVS_PKGDATADIR + OVN_PKGDATADIR=$ovs_dir; export OVN_PKGDATADIR } # Prints the integers from $1 to $2, increasing by $3 (default 1) on stdout. From patchwork Tue Sep 20 00:04:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1679824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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=EuokbaJH; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MWhdG20bzz1yp7 for ; Tue, 20 Sep 2022 10:05:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BFCE6417AD; Tue, 20 Sep 2022 00:05:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org BFCE6417AD Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EuokbaJH X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9fA8Cfd83YWw; Tue, 20 Sep 2022 00:05:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 25D284177F; Tue, 20 Sep 2022 00:05:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 25D284177F Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5EAACC0077; Tue, 20 Sep 2022 00:05:16 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1BCB5C0032 for ; Tue, 20 Sep 2022 00:05:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C7B8281CAF for ; Tue, 20 Sep 2022 00:05:12 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org C7B8281CAF Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EuokbaJH X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hWZPns0pNLtd for ; Tue, 20 Sep 2022 00:05:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 403DC81C81 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 403DC81C81 for ; Tue, 20 Sep 2022 00:05:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663632309; 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: in-reply-to:in-reply-to:references:references; bh=KJ//ZG03ll+XZLGtTB1HV1HBnqu5Bjc4gQaBt8KPPG8=; b=EuokbaJHRY8o4Nx9J+GOa+jyG9zLd7alfHz2xbhQFCyA5MkZG0mH8dXQPM6nqnJcMPvBrj iIWVcOQMxtHSBEvvI1rEox0GyIrIMNvGrPzRzggCqJva3N46jiV15ZykqzA8lc1NtN2fgO XhzM7uuJDsJ+IYCerGOqaS3Qws4zwuQ= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-673-jXglXaIeP8CUg78Pa7i7NA-1; Mon, 19 Sep 2022 20:05:08 -0400 X-MC-Unique: jXglXaIeP8CUg78Pa7i7NA-1 Received: by mail-qt1-f198.google.com with SMTP id b13-20020ac87fcd000000b0035cbe5d58afso652355qtk.9 for ; Mon, 19 Sep 2022 17:05:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KJ//ZG03ll+XZLGtTB1HV1HBnqu5Bjc4gQaBt8KPPG8=; b=v+T3XpxLaVFCOV4kCRzoYq2xdarQfn+6scdsWKkiP2zcXlTCoov/pyxq9g6BTv3+6F Ej1GPoKJDMGw7BbrOFWH0DIvLULLXv47wsDxdN1+nzOukFIXMAkULUOQo8Oj0JRIt5ot YI33gpztKBtuW4gPtaMPVe0IxC2qiZ1FlVX7ZTJNqvLEaSv4yP54lOaagISuDAEW1uqi /Yhk+u/WpP11tGLuzIXeJAimD29z3pwfjH0VPvpLYFeSlAlxnFAhXBAcHsCgmZBbM4ya aPJZS70G8VhPUp53O4xpzT232sHsvKlce784DMNUga3Qx+6O3Xd1LTm/d8QGu4efsc8Z aaaw== X-Gm-Message-State: ACrzQf0e5DGCMmTTeVMr3IyTyhDDj6wZnucAnQlsb6U6r/8RMJ+b0o82 +8gxOQVzp0F5ZOP3Bzj3nzbQT10QQu3IGe4ZiR6QSlo6slTAkMiiRMN8oYXrPhQkp+e61KYFiPT oluXb0b9GDwbGDJWnTE/Cvb1/NRR3AOpTXLSDNRLqYmZRA+d+1I/0GE4D6j6GiXHc X-Received: by 2002:a05:622a:91:b0:35c:f240:2fa7 with SMTP id o17-20020a05622a009100b0035cf2402fa7mr3520696qtw.439.1663632307592; Mon, 19 Sep 2022 17:05:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM47Jm433H7gEfeI/fQ8YLbj0YJrPqF+CPN77Y82jekAMGGEeF8AEhL5wsey9O7uKsGAIAMK2g== X-Received: by 2002:a05:622a:91:b0:35c:f240:2fa7 with SMTP id o17-20020a05622a009100b0035cf2402fa7mr3520667qtw.439.1663632307250; Mon, 19 Sep 2022 17:05:07 -0700 (PDT) Received: from fedora34.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a454c00b006aedb35d8a1sm14621611qkp.74.2022.09.19.17.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 17:05:05 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 20 Sep 2022 00:04:51 +0000 Message-Id: <20220920000453.357057-5-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920000453.357057-1-ihrachys@redhat.com> References: <20220920000453.357057-1-ihrachys@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 4/6] Support passing chassis name via CLI 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" This patch adds support for the desired system-id (chassis name) to be passed via CLI: $ ovn-controller -n If passed, CLI overrides any settings stored in ovsdb or in system-id-override file. This may be useful when running multiple controller instances using the same vswitchd instance. Signed-off-by: Ihar Hrachyshka Reviewed-by: Ales Musil --- controller/chassis.c | 5 +++++ controller/chassis.h | 1 + controller/ovn-controller.c | 9 ++++++++ tests/ovn-macros.at | 4 ++-- tests/ovn.at | 42 +++++++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-) diff --git a/controller/chassis.c b/controller/chassis.c index bc8fb5282..383223019 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -37,6 +37,7 @@ VLOG_DEFINE_THIS_MODULE(chassis); #define HOST_NAME_MAX 255 #endif /* HOST_NAME_MAX */ +char *cli_system_id = NULL; char *file_system_id = NULL; /* @@ -279,6 +280,10 @@ chassis_parse_ovs_iface_types(char **iface_types, size_t n_iface_types, const char * get_ovs_chassis_id(const struct ovsrec_open_vswitch_table *ovs_table) { + if (cli_system_id) { + return cli_system_id; + } + if (file_system_id) { return file_system_id; } diff --git a/controller/chassis.h b/controller/chassis.h index baa327059..309ced28f 100644 --- a/controller/chassis.h +++ b/controller/chassis.h @@ -31,6 +31,7 @@ struct sset; struct eth_addr; struct smap; +extern char *cli_system_id; extern char *file_system_id; void chassis_register_ovs_idl(struct ovsdb_idl *); diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index c71b0851f..16cbb971d 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -4519,6 +4519,9 @@ loop_done: if (file_system_id) { free(file_system_id); } + if (file_system_id) { + free(cli_system_id); + } service_stop(); exit(retval); @@ -4544,6 +4547,7 @@ parse_options(int argc, char *argv[]) STREAM_SSL_LONG_OPTIONS, {"peer-ca-cert", required_argument, NULL, OPT_PEER_CA_CERT}, {"bootstrap-ca-cert", required_argument, NULL, OPT_BOOTSTRAP_CA_CERT}, + {"chassis", required_argument, NULL, 'n'}, {"enable-dummy-vif-plug", no_argument, NULL, OPT_ENABLE_DUMMY_VIF_PLUG}, {NULL, 0, NULL, 0} @@ -4595,6 +4599,10 @@ parse_options(int argc, char *argv[]) vif_plug_dummy_enable(); break; + case 'n': + cli_system_id = xstrdup(optarg); + break; + case '?': exit(EXIT_FAILURE); @@ -4630,6 +4638,7 @@ usage(void) daemon_usage(); vlog_usage(); printf("\nOther options:\n" + " -n custom chassis name\n" " -h, --help display this help message\n" " -V, --version display version information\n"); exit(EXIT_SUCCESS); diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at index 35b7b3872..b7f236fa8 100644 --- a/tests/ovn-macros.at +++ b/tests/ovn-macros.at @@ -290,7 +290,7 @@ net_attach () { # ovn_az_attach AZ NETWORK BRIDGE IP [MASKLEN] ovn_az_attach() { - local az=$1 net=$2 bridge=$3 ip=$4 masklen=${5-24} encap=${6-geneve,vxlan} systemid=${7-$sandbox} + local az=$1 net=$2 bridge=$3 ip=$4 masklen=${5-24} encap=${6-geneve,vxlan} systemid=${7-$sandbox} cli_args=${@:8} net_attach $net $bridge || return 1 mac=`ovs-vsctl get Interface $bridge mac_in_use | sed s/\"//g` @@ -326,7 +326,7 @@ ovn_az_attach() { ovs-vsctl set open . external_ids:ovn-monitor-all=true fi - start_daemon ovn-controller --enable-dummy-vif-plug || return 1 + start_daemon ovn-controller --enable-dummy-vif-plug ${cli_args} || return 1 } # ovn_attach NETWORK BRIDGE IP [MASKLEN] diff --git a/tests/ovn.at b/tests/ovn.at index 5972089f1..e7b65691e 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -32972,3 +32972,45 @@ AT_CHECK(test x$encap_hv1_ip == x) OVN_CLEANUP([hv1],[hv2]) AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD([ +AT_SETUP([chassis name override via CLI]) +ovn_start +net_add n1 + +sim_add hv1 +as hv1 +ovs-vsctl add-br br-phys + +ovs-vsctl \ + -- set Open_vSwitch . external-ids:ovn-encap-type-hv3=geneve \ + -- set Open_vSwitch . external-ids:ovn-encap-ip-hv3=192.168.1.1 + +as hv1 ovs-vsctl set-ssl \ + $PKIDIR/testpki-hv3-privkey.pem \ + $PKIDIR/testpki-hv3-cert.pem \ + $PKIDIR/testpki-cacert.pem + +# the last argument is passed to ovn-controller through cli +ovn_attach n1 br-phys 192.168.0.1 24 vxlan hv1 -n hv3 + +sim_add hv2 +as hv2 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.2 24 geneve + +# despite that we configured ovn-encap-ip=192.168.0.1, this setting is +# overridden by chassis specific ovn-encap-ip-hv3 +OVS_WAIT_UNTIL([ + test "1" = "$(ovn-sbctl list Encap | grep -c '192.168.1.1')" +]) + +encap_hv3_ip=$(fetch_column Encap ip chassis_name=hv3 type=geneve) +AT_CHECK(test x$encap_hv3_ip == x192.168.1.1) + +encap_hv1_ip=$(fetch_column Encap ip chassis_name=hv1 type=vxlan) +AT_CHECK(test x$encap_hv1_ip == x) + +OVN_CLEANUP([hv1],[hv2]) +AT_CLEANUP +]) From patchwork Tue Sep 20 00:04:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1679826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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=TWHE+rb2; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MWhdL1D7tz1yqC for ; Tue, 20 Sep 2022 10:05:26 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8AF90417B0; Tue, 20 Sep 2022 00:05:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8AF90417B0 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TWHE+rb2 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6hvnLYa8wM03; Tue, 20 Sep 2022 00:05:20 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 5FCB841775; Tue, 20 Sep 2022 00:05:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5FCB841775 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2811AC002D; Tue, 20 Sep 2022 00:05:17 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8B60DC007F for ; Tue, 20 Sep 2022 00:05:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4ECB04028D for ; Tue, 20 Sep 2022 00:05:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4ECB04028D Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TWHE+rb2 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q0gxhBXEWgJz for ; Tue, 20 Sep 2022 00:05:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4629D4041C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 4629D4041C for ; Tue, 20 Sep 2022 00:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663632311; 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: in-reply-to:in-reply-to:references:references; bh=SbVBrhwjB2gozunJBIxLuRulx/rpTjOGj5o0bH+SsWs=; b=TWHE+rb244n3QJI/JavY3Wt93o66Bn13qlZtKzazP2/GtcnPg17BWJTkOavkUPsSMR/yFM VYMpO+fCwyXlHQX/G7Qbt57ZFrOdboQ1Hxn+cTg2EBiRXRAsqKZ22/cx2PQ5dz37GeFxpr 1yW+4ip+A3Rdgoc7fusBm73RIW4XkKk= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-588-xpkg5lBUMc6kCfBp5ifk2A-1; Mon, 19 Sep 2022 20:05:10 -0400 X-MC-Unique: xpkg5lBUMc6kCfBp5ifk2A-1 Received: by mail-qv1-f70.google.com with SMTP id ok32-20020a0562143ca000b004a10b5f97e6so833307qvb.12 for ; Mon, 19 Sep 2022 17:05:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=SbVBrhwjB2gozunJBIxLuRulx/rpTjOGj5o0bH+SsWs=; b=Hcq8yKW2G9eee1r3jClALMa4wDirzc+Mzrr45OClDeNAvz01c/IoBrIT8xQEREYzHA +KdEhA2n3LsBfsu7YGjfbPsEUj4DbDnqpCQ2MIuTmEsrb6Y5EELouxolJ6deV0Y6WR8p /TKsmJQWRtzn4HTIC/qnu1AhLE+om9u3/r4W6t/S7RmZcjNKzrr8F/OTQ3ZJ2CF/mxVp SGpMPms5vtUN+NO3HOO6Sp46Wcnqivo75T5Gg59YRbYzrdSWIb1tZHw+vA2VFVXWoa4M aKO1vEMlD+hpxtTc3AfxdvggK3ZBrRtq0AvR4AWwazU/o6bE1eSKdE8JfhYe3gTWSt8o 1zOg== X-Gm-Message-State: ACrzQf1BJkUpbEWVCpOQn/EWo+SFhxJMoGvcVkkBBwCOXeZRpNdI9v+G qE560C5zKfzithJNytOBzFZobMDhIklTeY521PJDmu8q7feMyjA+sN4YbMaxskPfGFzCcWbHz5h NYCGzHPKmjz92ohvM3v5ygf6oP20wSPnXcBb3MEeXfVujC/9BUrHy0gD7XmAhj43Z X-Received: by 2002:ad4:5bcd:0:b0:4ad:2fc4:6571 with SMTP id t13-20020ad45bcd000000b004ad2fc46571mr9385428qvt.103.1663632309329; Mon, 19 Sep 2022 17:05:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ZAR6udET10PF5220hLsbbTE/d64+iSagBDyAUFRloBQSFf3htmiLnYqyb++uJHaLpapnI1w== X-Received: by 2002:ad4:5bcd:0:b0:4ad:2fc4:6571 with SMTP id t13-20020ad45bcd000000b004ad2fc46571mr9385400qvt.103.1663632308947; Mon, 19 Sep 2022 17:05:08 -0700 (PDT) Received: from fedora34.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a454c00b006aedb35d8a1sm14621611qkp.74.2022.09.19.17.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 17:05:07 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 20 Sep 2022 00:04:52 +0000 Message-Id: <20220920000453.357057-6-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920000453.357057-1-ihrachys@redhat.com> References: <20220920000453.357057-1-ihrachys@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 5/6] Don't touch tunnel ports from a different br-int 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" When multiple controllers are running using the same vswitchd, controllers should delete only those tunnel ports that belong to the integration bridge that is managed by the controller instance. This makes sure multiple controllers don't step on each other when running using the same vswitchd instance. Signed-off-by: Ihar Hrachyshka Reviewed-by: Ales Musil --- controller/encaps.c | 42 ++++++++++------------ controller/encaps.h | 1 - controller/ovn-controller.c | 3 +- tests/ovn.at | 70 +++++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 26 deletions(-) diff --git a/controller/encaps.c b/controller/encaps.c index 572c38542..95b474b04 100644 --- a/controller/encaps.c +++ b/controller/encaps.c @@ -385,7 +385,6 @@ chassis_tzones_overlap(const struct sset *transport_zones, void encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, - const struct ovsrec_bridge_table *bridge_table, const struct ovsrec_bridge *br_int, const struct sbrec_chassis_table *chassis_table, const struct sbrec_chassis *this_chassis, @@ -398,7 +397,6 @@ encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, } const struct sbrec_chassis *chassis_rec; - const struct ovsrec_bridge *br; struct tunnel_ctx tc = { .chassis = SHASH_INITIALIZER(&tc.chassis), @@ -415,27 +413,25 @@ encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, /* Collect all port names into tc.port_names. * * Collect all the OVN-created tunnels into tc.tunnel_hmap. */ - OVSREC_BRIDGE_TABLE_FOR_EACH (br, bridge_table) { - for (size_t i = 0; i < br->n_ports; i++) { - const struct ovsrec_port *port = br->ports[i]; - sset_add(&tc.port_names, port->name); - - /* - * note that the id here is not just the chassis name, but the - * combination of - */ - const char *id = smap_get(&port->external_ids, "ovn-chassis-id"); - if (id) { - if (!shash_find(&tc.chassis, id)) { - struct chassis_node *chassis = xzalloc(sizeof *chassis); - chassis->bridge = br; - chassis->port = port; - shash_add_assert(&tc.chassis, id, chassis); - } else { - /* Duplicate port for ovn-chassis-id. Arbitrarily choose - * to delete this one. */ - ovsrec_bridge_update_ports_delvalue(br, port); - } + for (size_t i = 0; i < br_int->n_ports; i++) { + const struct ovsrec_port *port = br_int->ports[i]; + sset_add(&tc.port_names, port->name); + + /* + * note that the id here is not just the chassis name, but the + * combination of + */ + const char *id = smap_get(&port->external_ids, "ovn-chassis-id"); + if (id) { + if (!shash_find(&tc.chassis, id)) { + struct chassis_node *chassis = xzalloc(sizeof *chassis); + chassis->bridge = br_int; + chassis->port = port; + shash_add_assert(&tc.chassis, id, chassis); + } else { + /* Duplicate port for ovn-chassis-id. Arbitrarily choose + * to delete this one. */ + ovsrec_bridge_update_ports_delvalue(br_int, port); } } } diff --git a/controller/encaps.h b/controller/encaps.h index 25d44b034..867c6f28c 100644 --- a/controller/encaps.h +++ b/controller/encaps.h @@ -30,7 +30,6 @@ struct sset; void encaps_register_ovs_idl(struct ovsdb_idl *); void encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, - const struct ovsrec_bridge_table *, const struct ovsrec_bridge *br_int, const struct sbrec_chassis_table *, const struct sbrec_chassis *, diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 16cbb971d..eefbf6863 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -4136,8 +4136,7 @@ main(int argc, char *argv[]) } if (chassis) { - encaps_run(ovs_idl_txn, - bridge_table, br_int, + encaps_run(ovs_idl_txn, br_int, sbrec_chassis_table_get(ovnsb_idl_loop.idl), chassis, sbrec_sb_global_first(ovnsb_idl_loop.idl), diff --git a/tests/ovn.at b/tests/ovn.at index e7b65691e..cd4561069 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -33014,3 +33014,73 @@ AT_CHECK(test x$encap_hv1_ip == x) OVN_CLEANUP([hv1],[hv2]) AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD([ +AT_SETUP([controllers don't touch tunnels that are not on br-int]) +ovn_start +net_add n1 + +sim_add hv1 +as hv1 +ovs-vsctl add-br br-phys1 +ovn_attach n1 br-phys1 192.168.0.1 + +# the file is read once at startup so it's safe to write it +# here after the first ovn-controller has started +echo hv2 > ${OVN_SYSCONFDIR}/system-id-override +ovs-vsctl add-br br-phys2 + +# This function is similar to ovn_attach but makes sure it doesn't +# mess with another controller settings +start_virtual_controller() { + local net=$1 bridge=$2 ip=$3 masklen=${4-24} encap=${5-geneve,vxlan} systemid=${6-$sandbox} cli_args=${@:7} + net_attach $net $bridge || return 1 + + mac=`ovs-vsctl get Interface $bridge mac_in_use | sed s/\"//g` + arp_table="$arp_table $sandbox,$bridge,$ip,$mac" + ovs-appctl netdev-dummy/ip4addr $bridge $ip/$masklen >/dev/null || return 1 + ovs-appctl ovs/route/add $ip/$masklen $bridge >/dev/null || return 1 + + local ovn_remote + if test X$HAVE_OPENSSL = Xyes; then + ovn_remote=$SSL_OVN_SB_DB + else + ovn_remote=unix:$ovs_base/ovn-sb/ovn-sb.sock + fi + ovs-vsctl \ + -- set Open_vSwitch . external-ids:ovn-remote-$systemid=$ovn_remote \ + -- set Open_vSwitch . external-ids:ovn-encap-type-$systemid=$encap \ + -- set Open_vSwitch . external-ids:ovn-encap-ip-$systemid=$ip \ + -- set Open_vSwitch . external-ids:ovn-bridge-$systemid=br-int-2 \ + -- --may-exist add-br br-int-2 \ + -- set bridge br-int-2 fail-mode=secure other-config:disable-in-band=true \ + || return 1 + + ovn-controller --enable-dummy-vif-plug ${cli_args} -vconsole:off --detach --no-chdir +} + +# for some reason SSL ovsdb configuration overrides CLI, so +# delete ssl config from ovsdb to give CLI arguments priority +ovs-vsctl del-ssl + +start_virtual_controller n1 br-phys2 192.168.0.2 24 geneve,vxlan hv2 \ + --pidfile=${OVS_RUNDIR}/ovn-controller-2.pid \ + --log-file=${OVS_RUNDIR}/ovn-controller-2.log \ + -p $PKIDIR/testpki-hv2-privkey.pem \ + -c $PKIDIR/testpki-hv2-cert.pem \ + -C $PKIDIR/testpki-cacert.pem +pidfile="$OVS_RUNDIR"/ovn-controller-2.pid +on_exit "test -e \"$pidfile\" && kill \`cat \"$pidfile\"\`" + +# check that both tunnel ports are present, meaning controllers +# don't step on each other +OVS_WAIT_UNTIL([ovs-vsctl --columns _uuid --bare find Port \ + name=ovn-hv1-hv2-0 | wc -l], [0],[[1 +]]) +OVS_WAIT_UNTIL([ovs-vsctl --columns _uuid --bare find Port \ + name=ovn-hv2-hv1-0 | wc -l], [0],[[1 +]]) + +OVN_CLEANUP([hv1]) +AT_CLEANUP +]) From patchwork Tue Sep 20 00:04:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1679827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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=emWjNt0S; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MWhdT3YDZz1yp7 for ; Tue, 20 Sep 2022 10:05:33 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7F66682496; Tue, 20 Sep 2022 00:05:31 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7F66682496 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=emWjNt0S X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L97cizLBaHcc; Tue, 20 Sep 2022 00:05:29 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 5922E82451; Tue, 20 Sep 2022 00:05:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 5922E82451 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D260FC007C; Tue, 20 Sep 2022 00:05:18 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id B7FB3C0084 for ; Tue, 20 Sep 2022 00:05:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 732B481CA3 for ; Tue, 20 Sep 2022 00:05:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 732B481CA3 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TRsJGwqIEfQK for ; Tue, 20 Sep 2022 00:05:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A860081CE7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id A860081CE7 for ; Tue, 20 Sep 2022 00:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663632313; 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: in-reply-to:in-reply-to:references:references; bh=NYtVi2gqJdm3JR2c/GKzfrFtrrMWoJf0I5QBYDgg/ag=; b=emWjNt0SdkHKpuJOvjRNitfDy/8S3a6IvJD9eG5a0/0fkvKQnnqpbCsLRrLMQNrNS2GtgD 4MDzGU+fxJLubHrU5ic7sJl0cEP6JDrJgDpWsO59eLn9hj6vPpqDeXo1OWXzS+sTcf4ekm il927D+HmGsqlTWNxCRy6E6bX2QSnXM= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-155-4dRZ48KXO8qhiQng2bY73Q-1; Mon, 19 Sep 2022 20:05:12 -0400 X-MC-Unique: 4dRZ48KXO8qhiQng2bY73Q-1 Received: by mail-qt1-f198.google.com with SMTP id d20-20020a05622a05d400b00344997f0537so690593qtb.0 for ; Mon, 19 Sep 2022 17:05:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=NYtVi2gqJdm3JR2c/GKzfrFtrrMWoJf0I5QBYDgg/ag=; b=TQEQ1UKw1Hdzd2CQNaqn/MHyEcY81EPfLnvl6dY9Ua2Z98PE4Y0N+Hz7RluplVOcL0 kIR7lV8cA+HS9p5xI+FJ1PqYNqVRfq3mZ00A4XDFsAwoFegdxzQrKhRIXHm+1rZF4Mcs iWfvNDVH+YmYH7ojaBZZkHwVbslUNqhuXkQQuVzyEXnUFyPbUNttDzw7bCRAaXvN57kx cYnrE5XJQx0HtCnFdSGHrg3pyeYeSYHMfn6TwLNa2s4uIZ2pIX0Vyiu7s1oWLQrPWq7C E1kaKAxOiIoS2jiVIt64h1I8QOsL0Wg6pfk6nqPurupI899d7rsULXthJ0mMrADa1Xxi FLvA== X-Gm-Message-State: ACrzQf09t0XG/ZSJWScStNq5vAELESj0LmYmW55EskERCmg/3CVC4JAF s+tib0FNcMYM05b+s6N+kPQfbPVkIdL/UrNjV/2KONcSzMb1mpMig2lY8V03Ykfb20CG68l9dCk v0+v9rA9T4x0UDgMmllfKoZ3WUAbnnIkevPS85KVgYmLNYHAqW9jL88//zhRUcI5H X-Received: by 2002:ac8:5bc1:0:b0:343:7d47:c121 with SMTP id b1-20020ac85bc1000000b003437d47c121mr17475692qtb.237.1663632311698; Mon, 19 Sep 2022 17:05:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Dca8v0IbNg+WGp4zJQUH1A3WllwIewm3xP7NeRBZED2QXy5FUZkezQZY35CiBQQ8h8POPUw== X-Received: by 2002:ac8:5bc1:0:b0:343:7d47:c121 with SMTP id b1-20020ac85bc1000000b003437d47c121mr17475663qtb.237.1663632311377; Mon, 19 Sep 2022 17:05:11 -0700 (PDT) Received: from fedora34.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a454c00b006aedb35d8a1sm14621611qkp.74.2022.09.19.17.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 17:05:09 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 20 Sep 2022 00:04:53 +0000 Message-Id: <20220920000453.357057-7-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920000453.357057-1-ihrachys@redhat.com> References: <20220920000453.357057-1-ihrachys@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 6/6] Add connectivity test for 2 controllers on the same host 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" Signed-off-by: Ihar Hrachyshka Reviewed-by: Ales Musil --- tests/ovn.at | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/tests/ovn.at b/tests/ovn.at index cd4561069..564a5c149 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -33084,3 +33084,127 @@ OVS_WAIT_UNTIL([ovs-vsctl --columns _uuid --bare find Port \ OVN_CLEANUP([hv1]) AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD([ +AT_SETUP([multiple controllers on the same host can talk to each other]) +AT_KEYWORDS([ovntest]) +ovn_start +net_add n1 + +sim_add hv1 +as hv1 +ovs-vsctl add-br br-phys-1 +ovs-vsctl add-br br-phys-2 +ovs-vsctl set open . external-ids:ovn-bridge-mappings-hv1=phys:br-phys-1 +ovs-vsctl set open . external-ids:ovn-bridge-mappings-hv2=phys:br-phys-2 + +ovn_attach n1 br-phys-1 192.168.1.1 24 + +# the file is read once at startup so it's safe to write it +# here after the first ovn-controller has started +echo hv2 > ${OVN_SYSCONFDIR}/system-id-override + +# This function is similar to ovn_attach but makes sure it doesn't +# mess with another controller settings +start_virtual_controller() { + local net=$1 bridge=$2 int_bridge=$3 ip=$4 masklen=${5-24} encap=${6-geneve,vxlan} systemid=${7-$sandbox} cli_args=${@:8} + net_attach $net $bridge || return 1 + + mac=`ovs-vsctl get Interface $bridge mac_in_use | sed s/\"//g` + arp_table="$arp_table $sandbox,$bridge,$ip,$mac" + ovs-appctl netdev-dummy/ip4addr $bridge $ip/$masklen >/dev/null || return 1 + ovs-appctl ovs/route/add $ip/$masklen $bridge >/dev/null || return 1 + + local ovn_remote + if test X$HAVE_OPENSSL = Xyes; then + ovn_remote=$SSL_OVN_SB_DB + else + ovn_remote=unix:$ovs_base/ovn-sb/ovn-sb.sock + fi + ovs-vsctl \ + -- set Open_vSwitch . external-ids:ovn-remote-$systemid=$ovn_remote \ + -- set Open_vSwitch . external-ids:ovn-encap-type-$systemid=$encap \ + -- set Open_vSwitch . external-ids:ovn-encap-ip-$systemid=$ip \ + -- set Open_vSwitch . external-ids:ovn-bridge-$systemid=$int_bridge \ + -- --may-exist add-br $int_bridge \ + -- set bridge $int_bridge fail-mode=secure other-config:disable-in-band=true \ + || return 1 + + ovn-controller --enable-dummy-vif-plug ${cli_args} -vconsole:off --detach --no-chdir +} + +# for some reason SSL ovsdb configuration overrides CLI, so +# delete ssl config from ovsdb to give CLI arguments priority +ovs-vsctl del-ssl + +start_virtual_controller n1 br-phys-2 br-int-2 192.168.2.1 24 geneve,vxlan hv2 \ + --pidfile=${OVS_RUNDIR}/ovn-controller-2.pid \ + --log-file=${OVS_RUNDIR}/ovn-controller-2.log \ + -p $PKIDIR/testpki-hv2-privkey.pem \ + -c $PKIDIR/testpki-hv2-cert.pem \ + -C $PKIDIR/testpki-cacert.pem +pidfile="$OVS_RUNDIR"/ovn-controller-2.pid +on_exit "test -e \"$pidfile\" && kill \`cat \"$pidfile\"\`" + +# Disable local ARP responder to pass ARP requests through tunnels +check ovn-nbctl \ + ls-add ls \ + -- add Logical_Switch ls other_config vlan-passthru=true +ovn-nbctl lsp-add ls lp1 +ovn-nbctl lsp-add ls lp2 +ovn-nbctl lsp-set-addresses lp1 "00:00:00:00:00:01 10.0.0.1" +ovn-nbctl lsp-set-addresses lp2 "00:00:00:00:00:02 10.0.0.2" + +ovn-nbctl lsp-add ls ln_port +ovn-nbctl lsp-set-addresses ln_port unknown +ovn-nbctl lsp-set-type ln_port localnet +ovn-nbctl lsp-set-options ln_port network_name=phys + +ovs-vsctl -- add-port br-int vif1 -- \ + set interface vif1 external-ids:iface-id=lp1 \ + options:tx_pcap=hv1/vif1-tx.pcap \ + options:rxq_pcap=hv1/vif1-rx.pcap +ovs-vsctl -- add-port br-int-2 vif2 -- \ + set interface vif2 external-ids:iface-id=lp2 \ + options:tx_pcap=hv1/vif2-tx.pcap \ + options:rxq_pcap=hv1/vif2-rx.pcap + +reset_env() { + as hv1 reset_pcap_file vif1 hv1/vif1 + as hv1 reset_pcap_file vif2 hv1/vif2 + for port in hv1/vif1 hv1/vif2; do + : > $port.expected + done +} + +check_packets() { + OVN_CHECK_PACKETS_REMOVE_BROADCAST([hv1/vif1-tx.pcap], [hv1/vif1.expected]) + OVN_CHECK_PACKETS_REMOVE_BROADCAST([hv1/vif2-tx.pcap], [hv1/vif2.expected]) +} + +send_arp() { + local hv=$1 inport=$2 eth_src=$3 eth_dst=$4 spa=$5 tpa=$6 + local request=${eth_dst}${eth_src}08060001080006040001${eth_src}${spa}${eth_dst}${tpa} + as ${hv} ovs-appctl netdev-dummy/receive $inport $request + echo "${request}" +} + +wait_for_ports_up +ovn-nbctl --wait=hv sync + +OVN_POPULATE_ARP + +reset_env + +lp1_spa=$(ip_to_hex 10 0 0 1) +lp2_spa=$(ip_to_hex 10 0 0 2) +request=$(send_arp hv1 vif1 000000000001 000000000002 $lp1_spa $lp2_spa) +echo $request >> hv1/vif2.expected +request=$(send_arp hv1 vif2 000000000002 000000000001 $lp2_spa $lp1_spa) +echo $request >> hv1/vif1.expected + +check_packets + +OVN_CLEANUP([hv1]) +AT_CLEANUP +])