From patchwork Wed Feb 9 23:33:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1590752 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=F7Bz8K0J; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JvGR70kk9z9s5B for ; Thu, 10 Feb 2022 10:33:39 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id BA72E60E65; Wed, 9 Feb 2022 23:33:36 +0000 (UTC) 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 GKLbYdcBjwLp; Wed, 9 Feb 2022 23:33:35 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id E41D660808; Wed, 9 Feb 2022 23:33:34 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B7E3AC0011; Wed, 9 Feb 2022 23:33:34 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1EAF2C000B for ; Wed, 9 Feb 2022 23:33:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0D11A408F4 for ; Wed, 9 Feb 2022 23:33:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com 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 nc9uYWgnrPhi for ; Wed, 9 Feb 2022 23:33:32 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by smtp4.osuosl.org (Postfix) with ESMTPS id 2B8D3408E3 for ; Wed, 9 Feb 2022 23:33:32 +0000 (UTC) Received: by mail-lj1-x236.google.com with SMTP id o17so5682287ljp.1 for ; Wed, 09 Feb 2022 15:33:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9oNF8EVyzUueMJGvbMOkqzH7GrMl3/pSSskWJqs8O+Q=; b=F7Bz8K0Jw3IpSj3efFROI9GKYKVyq6AILbVHWCFiI8km4DCtBTyfwEaSoHa0SH9dly ZoqL19EIC0kLU+evCVMBgGLaKDeHiBi5ZcFelQpeuKI6+yFafSfSTL6b12yywvNgzi8k 2sgUCjay2ULRjhTvqRv4F4dixwMEaqyptYtU6xlz5AIUq/ZCgkKQyeMmMbP0GLYNo1OT 8q1+FKYlnhZDEqrFexkYv9sGoEO/UOt+sFmPXSKfA9xQESoO7xae0ROXQGGJLsshY4o4 /VeQz/rM94Dmj+mCyVDR/5CBDw3PRUIaBTPPt5MYvrFAHitFw9uZTwJjaegE4FR/WMSu JFjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9oNF8EVyzUueMJGvbMOkqzH7GrMl3/pSSskWJqs8O+Q=; b=iZuB5QQMMwqSHjAwemg6Q3+fMRExlRSHLsXwqJ2pq0XKRTkeyHJ1mQBY1FgQHk2Hs5 DfG6Ky+fkz2H9kmZ/YJvdT1xqMVSTPadsl8z4K0HGqFCmhfhfi9hdvEcnlpAB/SkuIRz CogkMiKPy+CpwvX0oDd65vjZD6pvaYvKFbYAcD8gOkf73A2+h44KuZdwK8kd00w/hLvR YDWCsltnYV5Qi2vYfaXv37xYBAjpJBHaCyyKnDN9df2SCBe5khDUvjfbuOv62cM+SGWW rRneekpzUvJ1FPg67dAowNAz9AQE4k2R79y3Qd1FSONvRvNRY40pSO3FkueQEIpdzRWk O/mg== X-Gm-Message-State: AOAM532rgdIIb8t2a8A4GzAnulQoH1e/JhZZ41wY+o19AbLC/VXXqDz2 z3pRqeMHVbCzbglk2l854XxHp9iSopjCDw== X-Google-Smtp-Source: ABdhPJxOclD1Zm3eaujKeK6R55EY39XCf1qy3eQ0KSxuV/TWhDNGs2RFeIpB/b7BZ+V7cdL0IbIEaQ== X-Received: by 2002:a2e:8791:: with SMTP id n17mr3292400lji.285.1644449609859; Wed, 09 Feb 2022 15:33:29 -0800 (PST) Received: from localhost.localdomain (109-252-131-59.dynamic.spd-mgts.ru. [109.252.131.59]) by smtp.gmail.com with ESMTPSA id r4sm2559199lfi.115.2022.02.09.15.33.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Feb 2022 15:33:29 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Thu, 10 Feb 2022 02:33:14 +0300 Message-Id: <20220209233314.51948-1-odivlad@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [PATCH ovn v2] controller: add ovn-set-local-ip option 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 transport node has multiple interfaces (vlans) and ovn-encap-ip on different hosts need to be configured from different VLANs source IP for encapsulated packet can be not the same, which is expected by remote system. Explicitely setting local_ip resolves such problem. Signed-off-by: Vladislav Odintsov --- controller/encaps.c | 37 +++++++++++++++++++++------------ controller/ovn-controller.8.xml | 7 +++++++ tests/ovn-controller.at | 9 ++++++++ 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/controller/encaps.c b/controller/encaps.c index 66e0cd8cd..3b0c92931 100644 --- a/controller/encaps.c +++ b/controller/encaps.c @@ -23,6 +23,7 @@ #include "openvswitch/vlog.h" #include "lib/ovn-sb-idl.h" #include "ovn-controller.h" +#include "smap.h" VLOG_DEFINE_THIS_MODULE(encaps); @@ -176,8 +177,31 @@ tunnel_add(struct tunnel_ctx *tc, const struct sbrec_sb_global *sbg, smap_add(&options, "dst_port", dst_port); } + const struct ovsrec_open_vswitch *cfg = + ovsrec_open_vswitch_table_first(ovs_table); + + 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, + "ovn-encap-tos", "none"); + + if (encap_tos && strcmp(encap_tos, "none")) { + smap_add(&options, "tos", encap_tos); + } + + /* If ovn-set-local-ip option is configured, get it */ + set_local_ip = smap_get_bool(&cfg->external_ids, "ovn-set-local-ip", + false); + } + /* Add auth info if ipsec is enabled. */ if (sbg->ipsec) { + set_local_ip = true; + smap_add(&options, "remote_name", new_chassis_id); + } + + if (set_local_ip) { const struct sbrec_chassis *this_chassis = tc->this_chassis; const char *local_ip = NULL; @@ -200,19 +224,6 @@ tunnel_add(struct tunnel_ctx *tc, const struct sbrec_sb_global *sbg, if (local_ip) { smap_add(&options, "local_ip", local_ip); } - smap_add(&options, "remote_name", new_chassis_id); - } - - const struct ovsrec_open_vswitch *cfg = - ovsrec_open_vswitch_table_first(ovs_table); - /* If the tos option is configured, get it */ - if (cfg) { - const char *encap_tos = smap_get_def(&cfg->external_ids, - "ovn-encap-tos", "none"); - - if (encap_tos && strcmp(encap_tos, "none")) { - smap_add(&options, "tos", encap_tos); - } } /* If there's an existing chassis record that does not need any change, diff --git a/controller/ovn-controller.8.xml b/controller/ovn-controller.8.xml index e9708fe64..cc9a7d1c2 100644 --- a/controller/ovn-controller.8.xml +++ b/controller/ovn-controller.8.xml @@ -304,6 +304,13 @@ of how many entries there are in the cache. By default this is set to 30000 (30 seconds). +
external_ids:ovn-set-local-ip
+
+ The boolean flag indicates if ovn-controller when create + tunnel ports should set local_ip parameter. Can be + heplful to pin source outer IP for the tunnel when multiple interfaces + are used on the host for overlay traffic. +

diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index 2f39e5f3e..9e6302e5a 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -298,6 +298,15 @@ OVS_WAIT_UNTIL([check_tunnel_property type geneve]) ovs-vsctl del-port ovn-fakech-0 OVS_WAIT_UNTIL([check_tunnel_property type geneve]) +# set `ovn-set-local-ip` option to true and check if tunnel parameters +OVS_WAIT_WHILE([check_tunnel_property options:local_ip "\"192.168.0.1\""]) +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_WAIT_UNTIL([check_tunnel_property options:local_ip "\"192.168.0.1\""]) + # Gracefully terminate daemons OVN_CLEANUP_SBOX([hv]) OVN_CLEANUP_VSWITCH([main])