From fa58682a111daaaa2983362b82a3a41460e3cc83 Mon Sep 17 00:00:00 2001
From: Lorenzo Bianconi
Date: Fri, 20 Dec 2024 16:30:23 +0100
Subject: [PATCH] northd: Add "ecmp_nexthop_monitor_en" config option to
NB_Global table.
Introduce "ecmp_nexthop_monitor_en" config option to NB_Global table in order
to enable or disable ecmp_nexthop tracking logic.
Signed-off-by: Lorenzo Bianconi
Signed-off-by: 0-day Robot
---
NEWS | 2 ++
northd/en-ecmp-nexthop.c | 22 ++++++++++++++++++----
northd/en-global-config.c | 5 +++++
northd/inc-proc-northd.c | 1 +
ovn-nb.xml | 9 +++++++++
tests/ovn-northd.at | 10 ++++++++++
tests/system-ovn.at | 4 ++++
7 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
index a16df17294..fdb2f91252 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,8 @@ Post v24.09.0
ARP/ND packets used for tracking ECMP next hop MAC addresses.
- Auto flush ECMP symmetric reply connection states when an ECMP route is
removed by the CMS."
+ - Add "ecmp_nexthop_monitor_en" config option to NB_Global table in order to
+ enable or disable ecmp_nexthop tracking logic.
OVN v24.09.0 - 13 Sep 2024
--------------------------
diff --git a/northd/en-ecmp-nexthop.c b/northd/en-ecmp-nexthop.c
index 738532fbe9..2b01db98b6 100644
--- a/northd/en-ecmp-nexthop.c
+++ b/northd/en-ecmp-nexthop.c
@@ -23,6 +23,7 @@
#include "openvswitch/hmap.h"
#include "util.h"
+#include "en-global-config.h"
#include "en-ecmp-nexthop.h"
#include "en-northd.h"
@@ -135,10 +136,23 @@ en_ecmp_nexthop_run(struct engine_node *node, void *data OVS_UNUSED)
struct routes_data *routes_data = engine_get_input_data("routes", node);
const struct sbrec_ecmp_nexthop_table *sbrec_ecmp_nexthop_table =
EN_OVSDB_GET(engine_get_input("SB_ecmp_nexthop", node));
-
- build_ecmp_nexthop_table(eng_ctx->ovnsb_idl_txn,
- &routes_data->parsed_routes,
- sbrec_ecmp_nexthop_table);
+ struct ed_type_global_config *global_config =
+ engine_get_input_data("global_config", node);
+ bool ecmp_nexthop_monitor_en = smap_get_bool(&global_config->nb_options,
+ "ecmp_nexthop_monitor_en",
+ false);
+
+ if (ecmp_nexthop_monitor_en) {
+ build_ecmp_nexthop_table(eng_ctx->ovnsb_idl_txn,
+ &routes_data->parsed_routes,
+ sbrec_ecmp_nexthop_table);
+ } else {
+ const struct sbrec_ecmp_nexthop *sb_ecmp_nexthop;
+ SBREC_ECMP_NEXTHOP_TABLE_FOR_EACH_SAFE (sb_ecmp_nexthop,
+ sbrec_ecmp_nexthop_table) {
+ sbrec_ecmp_nexthop_delete(sb_ecmp_nexthop);
+ }
+ }
engine_set_node_state(node, EN_UPDATED);
}
diff --git a/northd/en-global-config.c b/northd/en-global-config.c
index fff2aaa169..68533b5cc7 100644
--- a/northd/en-global-config.c
+++ b/northd/en-global-config.c
@@ -561,6 +561,11 @@ check_nb_options_out_of_sync(
return true;
}
+ if (config_out_of_sync(&nb->options, &config_data->nb_options,
+ "ecmp_nexthop_monitor_en", false)) {
+ return true;
+ }
+
return false;
}
diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c
index 5f9f4fa4bc..8b8bd02855 100644
--- a/northd/inc-proc-northd.c
+++ b/northd/inc-proc-northd.c
@@ -266,6 +266,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
engine_add_input(&en_bfd_sync, &en_route_policies, NULL);
engine_add_input(&en_bfd_sync, &en_northd, bfd_sync_northd_change_handler);
+ engine_add_input(&en_ecmp_nexthop, &en_global_config, NULL);
engine_add_input(&en_ecmp_nexthop, &en_sb_ecmp_nexthop, NULL);
engine_add_input(&en_ecmp_nexthop, &en_routes, NULL);
diff --git a/ovn-nb.xml b/ovn-nb.xml
index 8373ddb998..ce9d62c512 100644
--- a/ovn-nb.xml
+++ b/ovn-nb.xml
@@ -412,6 +412,15 @@
+
+
+ If set to true
., ovn-northd
will create
+ entries in
+ to track ECMP routes created with --ecmp_symmetric_reply
+ option. By default this option is set to false
.
+
+
+
These options control how routes are advertised between OVN
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index 9fdfdafefc..cd474d2149 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -6814,6 +6814,8 @@ check ovn-nbctl lsp-set-type public-lr0 router
check ovn-nbctl lsp-set-addresses public-lr0 router
check ovn-nbctl lsp-set-options public-lr0 router-port=lr0-public
+check ovn-nbctl set nb_global . options:ecmp_nexthop_monitor_en="true"
+
# non ecmp-symmetric-reply routes do not add any entry in ECMP_Nexthop table
check ovn-nbctl --wait=sb --ecmp lr-route-add lr0 1.0.0.1 192.168.0.10
check_row_count ECMP_Nexthop 0
@@ -6826,6 +6828,14 @@ uuid=$(fetch_column Port_Binding _uuid logical_port=lr0-public)
check_column 192.168.0.10 ECMP_Nexthop nexthop
check_column "$uuid" ECMP_Nexthop port
+# Disable ecmp_nexthop_monitor_en and check the SB.ECMP_Nexthop is empty
+check ovn-nbctl --wait=sb set nb_global . options:ecmp_nexthop_monitor_en="false"
+check_row_count ECMP_Nexthop 0
+
+# Enable ecmp_nexthop_monitor_en
+check ovn-nbctl --wait=sb set nb_global . options:ecmp_nexthop_monitor_en="true"
+check_row_count ECMP_Nexthop 1
+
ovn-sbctl dump-flows lr0 > lr0flows
AT_CHECK([grep -w "lr_in_ip_routing" lr0flows | ovn_strip_lflows], [0], [dnl
diff --git a/tests/system-ovn.at b/tests/system-ovn.at
index b58ce843d7..916dfbff79 100644
--- a/tests/system-ovn.at
+++ b/tests/system-ovn.at
@@ -14746,6 +14746,8 @@ check ovs-vsctl \
start_daemon ovn-controller
check ovs-vsctl set Open_vSwitch . external-ids:arp-nd-max-timeout-sec=1
+check ovn-nbctl set nb_global . options:ecmp_nexthop_monitor_en="true"
+
check ovn-nbctl lr-add R1
check ovn-nbctl set logical_router R1 options:chassis=hv1
check ovn-nbctl lr-add R2
@@ -15005,6 +15007,8 @@ check ovs-vsctl \
start_daemon ovn-controller
check ovs-vsctl set Open_vSwitch . external-ids:arp-nd-max-timeout-sec=1
+check ovn-nbctl set nb_global . options:ecmp_nexthop_monitor_en="true"
+
check ovn-nbctl lr-add R1
check ovn-nbctl set logical_router R1 options:chassis=hv1
check ovn-nbctl lr-add R2