From patchwork Tue Mar 12 15:59:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1911163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=MUYlkXXw; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvJJX25QNz1yWy for ; Wed, 13 Mar 2024 03:00:27 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 225C460BC1; Tue, 12 Mar 2024 16:00:22 +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 ZlbGyjNAU9Yq; Tue, 12 Mar 2024 16:00:19 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2C10860BB3 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=MUYlkXXw Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 2C10860BB3; Tue, 12 Mar 2024 16:00:19 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EF5B4C0DD9; Tue, 12 Mar 2024 16:00:18 +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 A17BDC0DD4 for ; Tue, 12 Mar 2024 16:00:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 756F06071A for ; Tue, 12 Mar 2024 16:00:17 +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 QRGMuQYjxk4c for ; Tue, 12 Mar 2024 16:00:14 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=lorenzo.bianconi@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 7E010605CB Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7E010605CB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 7E010605CB for ; Tue, 12 Mar 2024 16:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259213; 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=jwD9dV05uODqKRLPG8JOu3TqVbGM8ptLbJXn82M34io=; b=MUYlkXXwykm8batq4mROU4lzBmrFcXIYS35EZk1e2ElJXlrTthhScZTVihnTofgdb3oZvH UKHjIJYvWE7cGnWD3mintS3IItkXetCd54hwvtTSwKaBZKnJWs21doSdj7M0epfGauCx9q meYveLxL1aNP9n/1pNkSoQSgiS8zRiU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-343-RCw-rSosNtuK-O1CdY7q5Q-1; Tue, 12 Mar 2024 12:00:12 -0400 X-MC-Unique: RCw-rSosNtuK-O1CdY7q5Q-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-33e8b535e27so1982680f8f.1 for ; Tue, 12 Mar 2024 09:00:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710259210; x=1710864010; 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=jwD9dV05uODqKRLPG8JOu3TqVbGM8ptLbJXn82M34io=; b=gFf3uSU2ba0pT55U2qMsJ1wmT78IxjPo+xSkexMJs6UXlFcbWDr8v1BffEc6EAuada CfVv99qf9TVetrElCoGq6OjNrhCt3oeNcnqIM4ySOkNiMYFQPRQFoONDdApqNew8pYdB fFxnP9xHXfuN098ra8cFolgJ2e2Iv+hamKVa9N1FAUSO6CFuI5QVWm+NlayjPLNjk/EV giqpClLoXV7hn9QMDLaSNOjzXfSgB1ngr6UcrKx5dtXNVBEhIcQVRHgCsvDmYZ/uPBv3 Fi5YpCX9pOU0wJzNpP9BWX4NQ7kNhv1vba857uY3n+B4+Q4Jnnm7z1AkCp9T7AuJqi0V tWRA== X-Gm-Message-State: AOJu0YwFsgAGZbLELZaO+FU0oD9CEFHY4bEDi+rZLQhrc1PdPChm6yOb qDszOeIc7fuydYoFX1IS9+rplroa9gbhRZR6kLXeAHofXGtBFqauicP2EuY6ApY0IDJ/MEtyNve 9LTXAYmqNNjKAlFYOChgEly9AnJ7j/gcsrRw3RVRBKSRhdyUnI6y3UABJpjxSF0ukWQOGwMFpNg Zw1m4PZ5lXVqz6TVAe1JgFEWoOQZZeOv090Zqwj3UatGo7 X-Received: by 2002:adf:a3d8:0:b0:33e:6056:6b84 with SMTP id m24-20020adfa3d8000000b0033e60566b84mr8442951wrb.2.1710259206488; Tue, 12 Mar 2024 09:00:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxMa4Eey5aSyvGi2rWsn3UilY9RcczufGmTFuQYgAIPacTJ/0dcTv8UeFtZmoz9s+sZgZFFQ== X-Received: by 2002:adf:a3d8:0:b0:33e:6056:6b84 with SMTP id m24-20020adfa3d8000000b0033e60566b84mr8442908wrb.2.1710259205872; Tue, 12 Mar 2024 09:00:05 -0700 (PDT) Received: from localhost (net-93-71-3-198.cust.vodafonedsl.it. [93.71.3.198]) by smtp.gmail.com with ESMTPSA id n8-20020a5d51c8000000b0033e6ede34d3sm9278722wrv.39.2024.03.12.09.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 09:00:05 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Tue, 12 Mar 2024 16:59:57 +0100 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn v2 1/3] northd: Introduce ECMP_Nexthop table in SB db. 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" Introduce ECMP_Nexthop table in the SB db in order to track active ecmp-symmetric-reply connections and flush stale ones. Signed-off-by: Lorenzo Bianconi --- northd/en-northd.c | 4 +++ northd/inc-proc-northd.c | 8 +++-- northd/northd.c | 73 ++++++++++++++++++++++++++++++++++++++++ northd/northd.h | 3 ++ ovn-sb.ovsschema | 18 ++++++++-- ovn-sb.xml | 26 ++++++++++++++ tests/ovn-northd.at | 4 +++ 7 files changed, 132 insertions(+), 4 deletions(-) diff --git a/northd/en-northd.c b/northd/en-northd.c index 4479b4aff..2f8408fbc 100644 --- a/northd/en-northd.c +++ b/northd/en-northd.c @@ -76,6 +76,8 @@ northd_get_input_data(struct engine_node *node, EN_OVSDB_GET(engine_get_input("NB_chassis_template_var", node)); input_data->nbrec_mirror_table = EN_OVSDB_GET(engine_get_input("NB_mirror", node)); + input_data->nbrec_static_route_table = + EN_OVSDB_GET(engine_get_input("NB_logical_router_static_route", node)); input_data->sbrec_datapath_binding_table = EN_OVSDB_GET(engine_get_input("SB_datapath_binding", node)); @@ -101,6 +103,8 @@ northd_get_input_data(struct engine_node *node, EN_OVSDB_GET(engine_get_input("SB_chassis_template_var", node)); input_data->sbrec_mirror_table = EN_OVSDB_GET(engine_get_input("SB_mirror", node)); + input_data->sbrec_ecmp_nh_table = + EN_OVSDB_GET(engine_get_input("SB_ecmp_nexthop", node)); struct ed_type_lb_data *lb_data = engine_get_input_data("lb_data", node); diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index e1073812c..1c58da0bf 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -61,7 +61,8 @@ static unixctl_cb_func chassis_features_list; NB_NODE(meter, "meter") \ NB_NODE(bfd, "bfd") \ NB_NODE(static_mac_binding, "static_mac_binding") \ - NB_NODE(chassis_template_var, "chassis_template_var") + NB_NODE(chassis_template_var, "chassis_template_var") \ + NB_NODE(logical_router_static_route, "logical_router_static_route") enum nb_engine_node { #define NB_NODE(NAME, NAME_STR) NB_##NAME, @@ -101,7 +102,8 @@ static unixctl_cb_func chassis_features_list; SB_NODE(fdb, "fdb") \ SB_NODE(static_mac_binding, "static_mac_binding") \ SB_NODE(chassis_template_var, "chassis_template_var") \ - SB_NODE(logical_dp_group, "logical_dp_group") + SB_NODE(logical_dp_group, "logical_dp_group") \ + SB_NODE(ecmp_nexthop, "ecmp_nexthop") enum sb_engine_node { #define SB_NODE(NAME, NAME_STR) SB_##NAME, @@ -180,6 +182,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_northd, &en_nb_mirror, NULL); engine_add_input(&en_northd, &en_nb_static_mac_binding, NULL); engine_add_input(&en_northd, &en_nb_chassis_template_var, NULL); + engine_add_input(&en_northd, &en_nb_logical_router_static_route, NULL); engine_add_input(&en_northd, &en_sb_chassis, NULL); engine_add_input(&en_northd, &en_sb_mirror, NULL); @@ -192,6 +195,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_northd, &en_sb_fdb, NULL); engine_add_input(&en_northd, &en_sb_static_mac_binding, NULL); engine_add_input(&en_northd, &en_sb_chassis_template_var, NULL); + engine_add_input(&en_northd, &en_sb_ecmp_nexthop, NULL); engine_add_input(&en_northd, &en_global_config, northd_global_config_handler); diff --git a/northd/northd.c b/northd/northd.c index 1839b7d8b..7b8f442e1 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -16655,6 +16655,76 @@ sync_mirrors(struct ovsdb_idl_txn *ovnsb_txn, shash_destroy(&sb_mirrors); } +struct sb_ecmp_nexthop_entry { + struct hmap_node hmap_node; + const struct sbrec_ecmp_nexthop *sb_ecmp_nexthop; +}; + +static struct sb_ecmp_nexthop_entry * +sb_ecmp_nexthop_lookup(const struct hmap *map, const char *nexthop) +{ + uint32_t hash = hash_string(nexthop, 0); + struct sb_ecmp_nexthop_entry *enh_e; + + HMAP_FOR_EACH_WITH_HASH (enh_e, hmap_node, hash, map) { + if (!strcmp(enh_e->sb_ecmp_nexthop->nexthop, nexthop)) { + return enh_e; + } + } + return NULL; +} + +#define NEXTHOP_IDS_LEN 65535 +static void +sync_ecmp_symmetric_reply_nexthop(struct ovsdb_idl_txn *ovnsb_txn, + const struct nbrec_logical_router_static_route_table *nbrec_sr_table, + const struct sbrec_ecmp_nexthop_table *sbrec_ecmp_nh_table) +{ + unsigned long *nexthop_ids = bitmap_allocate(NEXTHOP_IDS_LEN); + struct hmap sb_only = HMAP_INITIALIZER(&sb_only); + const struct sbrec_ecmp_nexthop *sb_ecmp_nexthop; + struct sb_ecmp_nexthop_entry *enh_e; + + SBREC_ECMP_NEXTHOP_TABLE_FOR_EACH (sb_ecmp_nexthop, sbrec_ecmp_nh_table) { + uint32_t hash = hash_string(sb_ecmp_nexthop->nexthop, 0); + enh_e = xmalloc(sizeof *enh_e); + enh_e->sb_ecmp_nexthop = sb_ecmp_nexthop; + bitmap_set1(nexthop_ids, sb_ecmp_nexthop->id); + hmap_insert(&sb_only, &enh_e->hmap_node, hash); + } + + const struct nbrec_logical_router_static_route *r; + NBREC_LOGICAL_ROUTER_STATIC_ROUTE_TABLE_FOR_EACH (r, nbrec_sr_table) { + if (!smap_get_bool(&r->options, "ecmp_symmetric_reply", false)) { + continue; + } + + enh_e = sb_ecmp_nexthop_lookup(&sb_only, r->nexthop); + if (!enh_e) { + int id = bitmap_scan(nexthop_ids, 0, 1, NEXTHOP_IDS_LEN); + if (id == NEXTHOP_IDS_LEN) { + continue; + } + bitmap_set1(nexthop_ids, id); + + sb_ecmp_nexthop = sbrec_ecmp_nexthop_insert(ovnsb_txn); + sbrec_ecmp_nexthop_set_nexthop(sb_ecmp_nexthop, r->nexthop); + sbrec_ecmp_nexthop_set_id(sb_ecmp_nexthop, id); + } else { + hmap_remove(&sb_only, &enh_e->hmap_node); + free(enh_e); + } + } + + HMAP_FOR_EACH_POP (enh_e, hmap_node, &sb_only) { + sbrec_ecmp_nexthop_delete(enh_e->sb_ecmp_nexthop); + free(enh_e); + } + hmap_destroy(&sb_only); + + bitmap_free(nexthop_ids); +} + /* * struct 'dns_info' is used to sync the DNS records between OVN Northbound db * and Southbound db. @@ -17335,6 +17405,9 @@ ovnnb_db_run(struct northd_input *input_data, &data->ls_datapaths.datapaths); sync_template_vars(ovnsb_txn, input_data->nbrec_chassis_template_var_table, input_data->sbrec_chassis_template_var_table); + sync_ecmp_symmetric_reply_nexthop(ovnsb_txn, + input_data->nbrec_static_route_table, + input_data->sbrec_ecmp_nh_table); cleanup_stale_fdb_entries(input_data->sbrec_fdb_table, &data->ls_datapaths.datapaths); diff --git a/northd/northd.h b/northd/northd.h index 3f1cd8341..2d4bc9363 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -34,6 +34,8 @@ struct northd_input { const struct nbrec_chassis_template_var_table *nbrec_chassis_template_var_table; const struct nbrec_mirror_table *nbrec_mirror_table; + const struct nbrec_logical_router_static_route_table + *nbrec_static_route_table; /* Southbound table references */ const struct sbrec_datapath_binding_table *sbrec_datapath_binding_table; @@ -50,6 +52,7 @@ struct northd_input { const struct sbrec_chassis_template_var_table *sbrec_chassis_template_var_table; const struct sbrec_mirror_table *sbrec_mirror_table; + const struct sbrec_ecmp_nexthop_table *sbrec_ecmp_nh_table; /* Northd lb data node inputs*/ const struct hmap *lbs; diff --git a/ovn-sb.ovsschema b/ovn-sb.ovsschema index 84ae09515..c7a1cbf59 100644 --- a/ovn-sb.ovsschema +++ b/ovn-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Southbound", - "version": "20.33.0", - "cksum": "4076371179 31328", + "version": "20.34.0", + "cksum": "2226521861 31989", "tables": { "SB_Global": { "columns": { @@ -607,6 +607,20 @@ "refTable": "Datapath_Binding"}}}}, "indexes": [["logical_port", "ip"]], "isRoot": true}, + "ECMP_Nexthop": { + "columns": { + "nexthop": {"type": "string"}, + "id": {"type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 65535}}}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, + "options": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "indexes": [["nexthop"]], + "isRoot": true}, "Chassis_Template_Var": { "columns": { "chassis": {"type": "string"}, diff --git a/ovn-sb.xml b/ovn-sb.xml index ac4e585f2..7e51411f4 100644 --- a/ovn-sb.xml +++ b/ovn-sb.xml @@ -5095,4 +5095,30 @@ tcp.flags = RST; The set of variable values for a given chassis. + + + +

+ Nexthop IP address for this route. Nexthop IP address should be the IP + address of a connected router port or the IP address of a logical port + or can be set to discard for dropping packets which match + the given route. +

+
+ + +

+ Nexthop unique indetifier. Nexthop ID is used to track active + ecmp-symmetric-reply connections and flush stale ones. +

+
+ + + Reserved for future use. + + + + See External IDs at the beginning of this document. + +
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 89aed5adc..2160e8de7 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -6542,6 +6542,7 @@ check ovn-nbctl lsp-set-addresses public-lr0 router check ovn-nbctl lsp-set-options public-lr0 router-port=lr0-public check ovn-nbctl --wait=sb --ecmp-symmetric-reply lr-route-add lr0 1.0.0.1 192.168.0.10 +check_row_count ECMP_Nexthop 1 ovn-sbctl dump-flows lr0 > lr0flows @@ -6553,6 +6554,7 @@ AT_CHECK([grep -e "lr_in_ip_routing_ecmp" lr0flows | ovn_strip_lflows], [0], [dn ]) check ovn-nbctl --wait=sb --ecmp-symmetric-reply lr-route-add lr0 1.0.0.1 192.168.0.20 +check_row_count ECMP_Nexthop 2 ovn-sbctl dump-flows lr0 > lr0flows AT_CHECK([grep -e "lr_in_ip_routing.*select" lr0flows | ovn_strip_lflows], [0], [dnl @@ -6589,6 +6591,7 @@ AT_CHECK([grep -e "lr_in_arp_resolve.*ecmp" lr0flows | ovn_strip_lflows], [0], [ # add ecmp route with wrong nexthop check ovn-nbctl --wait=sb --ecmp-symmetric-reply lr-route-add lr0 1.0.0.1 192.168.1.20 +check_row_count ECMP_Nexthop 3 ovn-sbctl dump-flows lr0 > lr0flows AT_CHECK([grep -e "lr_in_ip_routing.*select" lr0flows | ovn_strip_lflows], [0], [dnl @@ -6603,6 +6606,7 @@ AT_CHECK([grep -e "lr_in_ip_routing_ecmp" lr0flows | sed 's/192\.168\.0\..0/192. check ovn-nbctl lr-route-del lr0 wait_row_count nb:Logical_Router_Static_Route 0 +check_row_count ECMP_Nexthop 0 check ovn-nbctl --wait=sb lr-route-add lr0 1.0.0.0/24 192.168.0.10 ovn-sbctl dump-flows lr0 > lr0flows