From patchwork Fri Nov 19 16:07:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1557235 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=jGJzXOPv; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwhQR2MPKz9sWJ for ; Sat, 20 Nov 2021 03:07:43 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 76D258290B; Fri, 19 Nov 2021 16:07:40 +0000 (UTC) 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 4ocisc0UcU5M; Fri, 19 Nov 2021 16:07:38 +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 E25AE828A9; Fri, 19 Nov 2021 16:07:36 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B589AC0031; Fri, 19 Nov 2021 16:07:36 +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 330D2C003C for ; Fri, 19 Nov 2021 16:07:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 13C5A41BDE for ; Fri, 19 Nov 2021 16:07: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 E_VAbxEKcI1f for ; Fri, 19 Nov 2021 16:07:32 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by smtp4.osuosl.org (Postfix) with ESMTPS id C2315414A2 for ; Fri, 19 Nov 2021 16:07:31 +0000 (UTC) Received: by mail-ed1-x52c.google.com with SMTP id t5so45009271edd.0 for ; Fri, 19 Nov 2021 08:07:31 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=CYBhIrWCyVUegK3xZbBsEKczkH354RPJlujqJK0h1Bc=; b=jGJzXOPvWQ/JcRlGnnGvMk4Ja7yaPNieg7RDrRDdYHFCRJlcvi8+1PBPr/YPuS5uNL aKl5M35UurDiTkBg0nAjlqCumrhfEdoIt0yzyFBJ+i+6gxFlaKdHaYobS7bU3x04X10S NqfrDkj9Hou84bWzPVx/tmidzgU5TpZIuNxI23SlWrX3xM8aV/METU2p9eenwOh191CJ OAcgHMhsqqNxUlaB3CnNrAgUuQw/nY2PnlMUEs+OTjBamYkwv5s+7GwyxjmAwRljUpXo 6gBlWLojxCA/IV/MD49E/Hv/QT+WzVJVhhMZ2ueVYOwuXfsf5dXgHb+INozshTO2p3Gz OnZA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=CYBhIrWCyVUegK3xZbBsEKczkH354RPJlujqJK0h1Bc=; b=FlTNzfa9EjmWWNYzpL2rmC201Ocnx9Gh1/4p6jlphrSbI4YyP1Qyx2L23CSPnWzAiW bPauGvMEtgmWRT4LoSN8gzfMEUQ/D6+covyMP55npuiiX0GFc1l5JuNbxbZaVKnaFa2T +kOr9ykrV1RyKeuaMvmoE9pIMjmFYZJ7txNMa+dFULOokTBaAkWBvQ/df4FUPcjjSzv9 vg2wUFRANJBaEjKh+uMglTSd8jGjVW3AmQEklfDzQ0HNDWItxIWxv+Eve+B9SDd94e9T oCfukHsB4axCO63tEKpcE2LRByJPOiVy1RHVFPqk7z5URAS+TrTMYadASqsaRFzkRkB6 Nuog== X-Gm-Message-State: AOAM532Vw0Ao3Pp/Xkd0SyTGoGhzVpH+ENHGfTS2X868x4HC+COBbo15 MGG9zzsARIGWcr0vorhdPfDl86PXJTx6gUpO X-Google-Smtp-Source: ABdhPJzosfmmbOXihuuZNMrR0rY+ZlchUOr5NQYRFadK3ZXY2rCjQALy/9nmaDGq2/+78EwrGO7t/A== X-Received: by 2002:a17:906:d92f:: with SMTP id rn15mr8996881ejb.557.1637338049563; Fri, 19 Nov 2021 08:07: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 z6sm121427edc.76.2021.11.19.08.07.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Nov 2021 08:07:29 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Fri, 19 Nov 2021 19:07:17 +0300 Message-Id: <20211119160721.60612-3-odivlad@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20211119160721.60612-1-odivlad@gmail.com> References: <20211119160721.60612-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [PATCH ovn v9 2/6] ic: maintain route origin - connected/static 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 ability to save route's origin while IC learning. Directly connected routes are saved in IC SB DB with "connected" origin column value. Static routes have "static" value in origin column. This logic would be used in next patch to compute priority for lr_in_ip_routing stage lflows. Signed-off-by: Vladislav Odintsov Acked-by: Numan Siddique --- ic/ovn-ic.c | 34 +++++++++++++++++++-------- lib/ovn-util.h | 3 +++ ovn-ic-sb.ovsschema | 7 ++++-- ovn-ic-sb.xml | 10 ++++++++ ovn-nb.xml | 14 +++++++++++ tests/ovn-ic.at | 57 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+), 12 deletions(-) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index 303e93a4f..70abae108 100644 --- a/ic/ovn-ic.c +++ b/ic/ovn-ic.c @@ -854,6 +854,7 @@ struct ic_route_info { struct in6_addr prefix; unsigned int plen; struct in6_addr nexthop; + const char *origin; /* Either nb_route or nb_lrp is set and the other one must be NULL. * - For a route that is learned from IC-SB, or a static route that is @@ -867,22 +868,25 @@ struct ic_route_info { static uint32_t ic_route_hash(const struct in6_addr *prefix, unsigned int plen, - const struct in6_addr *nexthop) + const struct in6_addr *nexthop, const char *origin) { uint32_t basis = hash_bytes(prefix, sizeof *prefix, (uint32_t)plen); + basis = hash_string(origin, basis); return hash_bytes(nexthop, sizeof *nexthop, basis); } static struct ic_route_info * ic_route_find(struct hmap *routes, const struct in6_addr *prefix, - unsigned int plen, const struct in6_addr *nexthop) + unsigned int plen, const struct in6_addr *nexthop, + const char *origin) { struct ic_route_info *r; - uint32_t hash = ic_route_hash(prefix, plen, nexthop); + uint32_t hash = ic_route_hash(prefix, plen, nexthop, origin); HMAP_FOR_EACH_WITH_HASH (r, node, hash, routes) { if (ipv6_addr_equals(&r->prefix, prefix) && r->plen == plen && - ipv6_addr_equals(&r->nexthop, nexthop)) { + ipv6_addr_equals(&r->nexthop, nexthop) && + !strcmp(r->origin, origin)) { return r; } } @@ -926,13 +930,15 @@ add_to_routes_learned(struct hmap *routes_learned, &prefix, &plen, &nexthop)) { return false; } + const char *origin = smap_get_def(&nb_route->options, "origin", ""); struct ic_route_info *ic_route = xzalloc(sizeof *ic_route); ic_route->prefix = prefix; ic_route->plen = plen; ic_route->nexthop = nexthop; ic_route->nb_route = nb_route; + ic_route->origin = origin; hmap_insert(routes_learned, &ic_route->node, - ic_route_hash(&prefix, plen, &nexthop)); + ic_route_hash(&prefix, plen, &nexthop, origin)); return true; } @@ -1093,8 +1099,9 @@ add_to_routes_ad(struct hmap *routes_ad, ic_route->plen = plen; ic_route->nexthop = nexthop; ic_route->nb_route = nb_route; + ic_route->origin = ROUTE_ORIGIN_STATIC; hmap_insert(routes_ad, &ic_route->node, - ic_route_hash(&prefix, plen, &nexthop)); + ic_route_hash(&prefix, plen, &nexthop, ROUTE_ORIGIN_STATIC)); } static void @@ -1143,8 +1150,10 @@ add_network_to_routes_ad(struct hmap *routes_ad, const char *network, ic_route->plen = plen; ic_route->nexthop = nexthop; ic_route->nb_lrp = nb_lrp; + ic_route->origin = ROUTE_ORIGIN_CONNECTED; hmap_insert(routes_ad, &ic_route->node, - ic_route_hash(&prefix, plen, &nexthop)); + ic_route_hash(&prefix, plen, &nexthop, + ROUTE_ORIGIN_CONNECTED)); } static bool @@ -1206,7 +1215,8 @@ sync_learned_route(struct ic_context *ctx, continue; } struct ic_route_info *route_learned - = ic_route_find(&ic_lr->routes_learned, &prefix, plen, &nexthop); + = ic_route_find(&ic_lr->routes_learned, &prefix, plen, &nexthop, + isb_route->origin); if (route_learned) { /* Sync external-ids */ struct uuid ext_id; @@ -1233,6 +1243,8 @@ sync_learned_route(struct ic_context *ctx, UUID_ARGS(&isb_route->header_.uuid)); nbrec_logical_router_static_route_update_external_ids_setkey( nb_route, "ic-learned-route", uuid_s); + nbrec_logical_router_static_route_update_options_setkey( + nb_route, "origin", isb_route->origin); free(uuid_s); nbrec_logical_router_update_static_routes_addvalue( ic_lr->lr, nb_route); @@ -1297,8 +1309,9 @@ advertise_route(struct ic_context *ctx, icsbrec_route_delete(isb_route); continue; } - struct ic_route_info *route_adv = - ic_route_find(routes_ad, &prefix, plen, &nexthop); + struct ic_route_info *route_adv = ic_route_find(routes_ad, &prefix, + plen, &nexthop, + isb_route->origin); if (!route_adv) { /* Delete the extra route from IC-SB. */ VLOG_DBG("Delete route %s -> %s from IC-SB, which is not found" @@ -1338,6 +1351,7 @@ advertise_route(struct ic_context *ctx, } icsbrec_route_set_ip_prefix(isb_route, prefix_s); icsbrec_route_set_nexthop(isb_route, nexthop_s); + icsbrec_route_set_origin(isb_route, route_adv->origin); free(prefix_s); free(nexthop_s); diff --git a/lib/ovn-util.h b/lib/ovn-util.h index 2fa92e069..a923c3b65 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -25,6 +25,9 @@ #define ovn_print_version(MIN_OFP, MAX_OFP) \ ovs_print_version(MIN_OFP, MAX_OFP) +#define ROUTE_ORIGIN_CONNECTED "connected" +#define ROUTE_ORIGIN_STATIC "static" + struct nbrec_logical_router_port; struct sbrec_logical_flow; struct svec; diff --git a/ovn-ic-sb.ovsschema b/ovn-ic-sb.ovsschema index 5364b21b4..42ce85d7d 100644 --- a/ovn-ic-sb.ovsschema +++ b/ovn-ic-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_IC_Southbound", - "version": "1.0.0", - "cksum": "108951192 6585", + "version": "1.1.0", + "cksum": "423535838 6733", "tables": { "IC_SB_Global": { "columns": { @@ -94,6 +94,9 @@ "refTable": "Availability_Zone"}}}, "ip_prefix": {"type": "string"}, "nexthop": {"type": "string"}, + "origin": {"type": {"key": { + "type": "string", + "enum": ["set", ["connected", "static"]]}}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, diff --git a/ovn-ic-sb.xml b/ovn-ic-sb.xml index 3582cff47..d8338e4d3 100644 --- a/ovn-ic-sb.xml +++ b/ovn-ic-sb.xml @@ -313,6 +313,16 @@ Nexthop IP address for this route. + + + Can be one of connected or static. Routes to + directly-connected subnets - LRP's CIDRs are inserted to OVN IC SB DB + with connected value in . Static + routes are inserted to OVN IC SB DB with static value. + Next when route is learned to another AZ NB DB by ovn-ic, route origin + is synced to . + diff --git a/ovn-nb.xml b/ovn-nb.xml index 036ffa64f..ed33aa8e4 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -2967,6 +2967,20 @@ only works on gateway routers (routers that have set). + + + In case ovn-interconnection has been learned this route, it will have + its origin set: either "connected" or "static". This key is supposed + to be written only by ovn-ic daemon. ovn-northd then + checks this value when generating Logical Flows. records with same + within same Logical Router will have next + lookup order based on origin key value: +
    +
  1. connected
  2. +
  3. static
  4. +
+
diff --git a/tests/ovn-ic.at b/tests/ovn-ic.at index 9086974a3..7e8498b2f 100644 --- a/tests/ovn-ic.at +++ b/tests/ovn-ic.at @@ -423,6 +423,63 @@ AT_CHECK([ovn_as az1 ovn-nbctl lr-route-list lr11 | # Test routes from lr12 didn't leak as learned to lr21 AT_CHECK([ovn_as az1 ovn-nbctl lr-route-list lr21], [0], []) +# cleanup +ovn-ic-nbctl --if-exists ts-del ts1 +ovn_as az1 ovn-nbctl lr-del lr11 +ovn_as az1 ovn-nbctl lr-del lr21 +ovn_as az2 ovn-nbctl lr-del lr12 +ovn_as az2 ovn-nbctl lr-del lr22 + +# check routes origin advertisement and learning + +# setup topology with connected, static and source routes +ovn-ic-nbctl ts-add ts1 +for i in 1 2; do + ovn_as az$i + + # Enable route learning at AZ level + ovn-nbctl set nb_global . options:ic-route-learn=true + # Enable route advertising at AZ level + ovn-nbctl set nb_global . options:ic-route-adv=true + + # Create LRP and connect to TS + ovn-nbctl lr-add lr$i + ovn-nbctl lrp-add lr$i lrp-lr$i-ts1 aa:aa:aa:aa:aa:0$i 169.254.100.$i/24 + ovn-nbctl lsp-add ts1 lsp-ts1-lr$i \ + -- lsp-set-addresses lsp-ts1-lr$i router \ + -- lsp-set-type lsp-ts1-lr$i router \ + -- lsp-set-options lsp-ts1-lr$i router-port=lrp-lr$i-ts1 + + ovn-nbctl lrp-add lr$i lrp-lr$i-p$i 00:00:00:00:00:0$i 192.168.$i.1/24 + + # Create static routes + ovn-nbctl lr-route-add lr$i 10.11.$i.0/24 169.254.0.1 + + # Create a src-ip route, which shouldn't be synced + ovn-nbctl --policy=src-ip lr-route-add lr$i 10.22.$i.0/24 169.254.0.2 +done + +for i in 1 2; do + OVS_WAIT_UNTIL([ovn_as az$i ovn-nbctl lr-route-list lr$i | grep learned]) +done + +# check that advertised routes in ic-sb have correct origin +ovn-ic-sbctl list route +wait_row_count ic-sb:Route 1 ip_prefix=10.11.1.0/24 origin=static +wait_row_count ic-sb:Route 1 ip_prefix=192.168.1.1/24 origin=connected +wait_row_count ic-sb:Route 1 ip_prefix=10.11.2.0/24 origin=static +wait_row_count ic-sb:Route 1 ip_prefix=192.168.2.1/24 origin=connected + +# check that learned routes in ic-sb have correct origin + +ovn_as az1 +wait_row_count nb:Logical_Router_Static_Route 1 ip_prefix=10.11.2.0/24 options:origin=static +wait_row_count nb:Logical_Router_Static_Route 1 ip_prefix=192.168.2.1/24 options:origin=connected + +ovn_as az2 +wait_row_count nb:Logical_Router_Static_Route 1 ip_prefix=10.11.1.0/24 options:origin=static +wait_row_count nb:Logical_Router_Static_Route 1 ip_prefix=192.168.1.1/24 options:origin=connected + OVN_CLEANUP_IC([az1], [az2]) AT_CLEANUP