From patchwork Fri Nov 18 16:20:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1705698 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" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=I+vgS6Sr; 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 4NDMVN5tJNz23mH for ; Sat, 19 Nov 2022 03:21:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 7CC9761134; Fri, 18 Nov 2022 16:21:29 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7CC9761134 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=I+vgS6Sr 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 S2K_eOrvpRNv; Fri, 18 Nov 2022 16:21:26 +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 7FCFA61117; Fri, 18 Nov 2022 16:21:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7FCFA61117 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 969C2C0084; Fri, 18 Nov 2022 16:21:18 +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 1910CC007B for ; Fri, 18 Nov 2022 16:21:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 87223419FD for ; Fri, 18 Nov 2022 16:21:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 87223419FD Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=I+vgS6Sr 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 rk1lNwn22gHF for ; Fri, 18 Nov 2022 16:21:13 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org F348641A0B Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by smtp4.osuosl.org (Postfix) with ESMTPS id F348641A0B for ; Fri, 18 Nov 2022 16:21:12 +0000 (UTC) Received: by mail-lj1-x231.google.com with SMTP id z24so7387099ljn.4 for ; Fri, 18 Nov 2022 08:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LKQl6pesmdEOYY/ZPjiYmgcle3VIhXaG0irRr1JNUTo=; b=I+vgS6Sr16TNQ/pfAoX9bO20jNgg/C0WTexZN1Bx0OepvZJ3FQ1vW6hkFpiQxlH79F +mbkXDgM6FNWdSUkDdbeiuxv/8C8dNTK47Bi0BRcMesWzImXuTdIAgJAhl3ZftLhIfOZ SafpzN12brhvG/gqIFVP0WrAPG8WJk40Ik5sQUlrmGBC6Z6R5b4nbAJvEQ6/Jw5uH0f2 BsoQt/990Sl8u9mS7NbOYvFfvWo1dfMDogPhRhBO0yCBu6I4lNnzIHTGH0hknn+UDEeO adYB0Z3LhfF6eDV35+KkLOaYpEKuVaWdiao6qHDvb+e5NEQl0c0p1TZqY1bqyB4/Hoyq p2/A== 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:message-id:reply-to; bh=LKQl6pesmdEOYY/ZPjiYmgcle3VIhXaG0irRr1JNUTo=; b=fk64he1brUGS8SeVbkoanQ9tN43+cMyGsQcjByE9tYqWCt+Jd0D3i80C92tKZRYDJ1 7WL/Ss5tuh2Dfptq54e8uyAW39f5DLor332mEH7OWkTIbx0PrppUEvKCz9nXwtao+T5r 2JL15uq4KHtXcPZpT4G8Ap7E1MqjnT0rivWQ4I0SRoKtd4FcwyRmOLjaAfqyQ4rn91zV ciyoxNp2oFar0CiiitUjBg6p66fIOEMDtnCgzl2xeTNJ2b5Cjlw3UiCNwM3mfj4sWfAk 0F7VU2ud2Do+rATjKFK0vNgsp62D0OTk20KleVSdjpsc7Jiktd5GVOWMx189n8ZPL9dn 6sXw== X-Gm-Message-State: ANoB5plR1A7cPRhLIS6kXgSmCmp8L6Zlt3zgJAqcdRG5B31MmSQPpwDm IncWl4jQrP2n/AciSCcrJ/uxb+u5fny8WQ== X-Google-Smtp-Source: AA0mqf4vml/GJPyaq6epH12x0oEcvC0vZpZT+vUaLgsbXru3S3LbZEnAUd+Sz/zaZ4V2YhoykrOGpw== X-Received: by 2002:a05:651c:171c:b0:26f:bfd1:cc14 with SMTP id be28-20020a05651c171c00b0026fbfd1cc14mr2767555ljb.256.1668788470588; Fri, 18 Nov 2022 08:21:10 -0800 (PST) Received: from ip-10-70-112-12.vpc-1e810be1.internal (c2-178-216-98-9.elastic.cloud.croc.ru. [178.216.98.9]) by smtp.gmail.com with ESMTPSA id o16-20020ac25e30000000b0049465afdd38sm717538lfg.108.2022.11.18.08.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 08:21:10 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Fri, 18 Nov 2022 19:20:50 +0300 Message-Id: <20221118162050.3019353-8-odivlad@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221118162050.3019353-1-odivlad@gmail.com> References: <20221118162050.3019353-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [OVN RFC 7/7] ic: prevent advertising/learning multiple same routes 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: Vladislav Odintsov --- ic/ovn-ic.c | 17 ++++++++++--- ovn-ic-sb.ovsschema | 6 +++-- tests/ovn-ic.at | 60 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 5 deletions(-) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index 59468545d..beafd133b 100644 --- a/ic/ovn-ic.c +++ b/ic/ovn-ic.c @@ -1096,11 +1096,22 @@ route_need_advertise(const char *policy, static void add_to_routes_ad(struct hmap *routes_ad, struct ic_route_info *ic_route) { + const char *route_table = ic_route->route_table ? ic_route->route_table + : ""; uint hash = ic_route_hash(&ic_route->prefix, ic_route->plen, &ic_route->nexthop, ic_route->origin, - ic_route->route_table ? ic_route->route_table - : ""); - hmap_insert(routes_ad, &ic_route->node, hash); + route_table); + + if (!ic_route_find(routes_ad, &ic_route->prefix, ic_route->plen, + &ic_route->nexthop, ic_route->origin, route_table, + hash)) { + hmap_insert(routes_ad, &ic_route->node, hash); + } + else { + VLOG_WARN("Duplicate route advertisement was suppressed! NB route " + "uuid: "UUID_FMT, + UUID_ARGS(&ic_route->nb_route->header_.uuid)); + } } static void diff --git a/ovn-ic-sb.ovsschema b/ovn-ic-sb.ovsschema index 72c9d3f3e..1d60b36d1 100644 --- a/ovn-ic-sb.ovsschema +++ b/ovn-ic-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_IC_Southbound", - "version": "1.1.0", - "cksum": "2309827842 6784", + "version": "1.1.1", + "cksum": "3684563024 6914", "tables": { "IC_SB_Global": { "columns": { @@ -101,6 +101,8 @@ "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, + "indexes": [["transit_switch", "availability_zone", "route_table", + "ip_prefix", "nexthop"]], "isRoot": true}, "Connection": { "columns": { diff --git a/tests/ovn-ic.at b/tests/ovn-ic.at index e234b7fb9..ceee45092 100644 --- a/tests/ovn-ic.at +++ b/tests/ovn-ic.at @@ -194,6 +194,66 @@ OVN_CLEANUP_IC AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD([ +AT_SETUP([ovn-ic -- duplicate NB route adv/learn]) + +ovn_init_ic_db +net_add n1 + +# 1 GW per AZ +for i in 1 2; do + az=az$i + ovn_start $az + sim_add gw-$az + as gw-$az + check ovs-vsctl add-br br-phys + ovn_az_attach $az n1 br-phys 192.168.1.$i + check ovs-vsctl set open . external-ids:ovn-is-interconn=true + check ovn-nbctl set nb-global . \ + options:ic-route-adv=true \ + options:ic-route-adv-default=true \ + options:ic-route-learn=true \ + options:ic-route-learn-default=true +done + +ovn_as az1 + +# create transit switch and connect to LR +check ovn-ic-nbctl ts-add ts1 +for i in 1 2; do + ovn_as az$i + + check ovn-nbctl lr-add lr1 + check ovn-nbctl lrp-add lr1 lrp$i 00:00:00:00:0$i:01 10.0.$i.1/24 + check ovn-nbctl lrp-set-gateway-chassis lrp$i gw-az$i + + check ovn-nbctl lsp-add ts1 lsp$i -- \ + lsp-set-addresses lsp$i router -- \ + lsp-set-type lsp$i router -- \ + lsp-set-options lsp$i router-port=lrp$i +done + +ovn_as az1 + +ovn-nbctl \ + --id=@id create logical-router-static-route ip_prefix=1.1.1.1/32 nexthop=10.0.1.10 -- \ + add logical-router lr1 static_routes @id +ovn-nbctl \ + --id=@id create logical-router-static-route ip_prefix=1.1.1.1/32 nexthop=10.0.1.10 -- \ + add logical-router lr1 static_routes @id + +wait_row_count ic-sb:route 1 ip_prefix=1.1.1.1/32 + +for i in 1 2; do + az=az$i + OVN_CLEANUP_SBOX(gw-$az) + OVN_CLEANUP_AZ([$az]) +done + +OVN_CLEANUP_IC +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD([ AT_SETUP([ovn-ic -- gateway sync])