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 +])