Introduce the Static_Route.option.dynamic-routing-advertise parameter in
order to enable/disable the advertisement of a specific static routes
adding/removing the entry in the Advertised_Route OVN_Southbound table.

Reported-at: https://redhat.atlassian.net/browse/FDP-2743
Signed-off-by: Lorenzo Bianconi <[email protected]>
---
 northd/en-advertised-route-sync.c |  4 ++++
 northd/en-learned-route-sync.c    |  2 +-
 northd/northd.c                   | 17 ++++++++++++-----
 northd/northd.h                   |  2 ++
 ovn-nb.xml                        | 12 ++++++------
 tests/ovn-northd.at               |  7 +++++++
 6 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/northd/en-advertised-route-sync.c 
b/northd/en-advertised-route-sync.c
index 6ae9a9689..6b02cb048 100644
--- a/northd/en-advertised-route-sync.c
+++ b/northd/en-advertised-route-sync.c
@@ -708,6 +708,10 @@ advertised_route_table_sync(
             continue;
         }
 
+        if (!route->dynamic_routing_advertise) {
+            continue;
+        }
+
         if (!should_advertise_route(route->od, route->out_port,
                                     route->source)) {
             continue;
diff --git a/northd/en-learned-route-sync.c b/northd/en-learned-route-sync.c
index 0d1953276..81ed81d3d 100644
--- a/northd/en-learned-route-sync.c
+++ b/northd/en-learned-route-sync.c
@@ -201,7 +201,7 @@ parse_route_from_sbrec_route(struct hmap *parsed_routes_out,
 
     return parsed_route_add(od, nexthop, &prefix, plen, false, lrp_addr_s,
                             out_port, 0, false, false, false, NULL,
-                            ROUTE_SOURCE_LEARNED, &route->header_, NULL,
+                            ROUTE_SOURCE_LEARNED, true, &route->header_, NULL,
                             parsed_routes_out);
 }
 
diff --git a/northd/northd.c b/northd/northd.c
index 0ea7c1b95..b9de69fae 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -12132,6 +12132,7 @@ parsed_route_init(const struct ovn_datapath *od,
                   bool override_connected,
                   const struct sset *ecmp_selection_fields,
                   enum route_source source,
+                  bool dynamic_routing_advertise,
                   const struct ovn_port *tracked_port,
                   const struct ovsdb_idl_row *source_hint)
 {
@@ -12150,6 +12151,7 @@ parsed_route_init(const struct ovn_datapath *od,
     new_pr->lrp_addr_s = nullable_xstrdup(lrp_addr_s);
     new_pr->out_port = out_port;
     new_pr->tracked_port = tracked_port;
+    new_pr->dynamic_routing_advertise = dynamic_routing_advertise;
     new_pr->source = source;
     if (ecmp_selection_fields) {
         sset_clone(&new_pr->ecmp_selection_fields, ecmp_selection_fields);
@@ -12175,7 +12177,7 @@ parsed_route_clone(const struct parsed_route *pr)
         pr->od, nexthop, pr->prefix, pr->plen, pr->is_discard_route,
         pr->lrp_addr_s, pr->out_port, pr->route_table_id, pr->is_src_route,
         pr->ecmp_symmetric_reply, pr->override_connected,
-        &pr->ecmp_selection_fields, pr->source,
+        &pr->ecmp_selection_fields, pr->source, pr->dynamic_routing_advertise,
         pr->tracked_port, pr->source_hint);
 
     new_pr->hash = pr->hash;
@@ -12239,6 +12241,7 @@ parsed_route_add(const struct ovn_datapath *od,
                  bool override_connected,
                  const struct sset *ecmp_selection_fields,
                  enum route_source source,
+                 bool dynamic_routing_advertise,
                  const struct ovsdb_idl_row *source_hint,
                  const struct ovn_port *tracked_port,
                  struct hmap *routes)
@@ -12249,7 +12252,8 @@ parsed_route_add(const struct ovn_datapath *od,
                             lrp_addr_s, out_port, route_table_id,
                             is_src_route, ecmp_symmetric_reply,
                             override_connected, ecmp_selection_fields,
-                            source, tracked_port, source_hint);
+                            source, dynamic_routing_advertise,
+                            tracked_port, source_hint);
 
     new_pr->hash = route_hash(new_pr);
 
@@ -12390,10 +12394,13 @@ parsed_routes_add_static(const struct ovn_datapath 
*od,
         source = ROUTE_SOURCE_STATIC;
     }
 
+    bool dynamic_routing_advertise = smap_get_bool(&route->options,
+                                                   "dynamic-routing-advertise",
+                                                   true);
     parsed_route_add(od, nexthop, &prefix, plen, is_discard_route, lrp_addr_s,
                      out_port, route_table_id, is_src_route,
                      ecmp_symmetric_reply, override_connected,
-                     &ecmp_selection_fields, source,
+                     &ecmp_selection_fields, source, dynamic_routing_advertise,
                      &route->header_, NULL, routes);
     sset_destroy(&ecmp_selection_fields);
 }
@@ -12411,7 +12418,7 @@ parsed_routes_add_connected(const struct ovn_datapath 
*od,
         parsed_route_add(od, NULL, &prefix, addr->plen,
                          false, addr->addr_s, op, 0, false, false,
                          false, NULL, ROUTE_SOURCE_CONNECTED,
-                         &op->nbrp->header_, NULL, routes);
+                         true, &op->nbrp->header_, NULL, routes);
     }
 
     for (size_t i = 0; i < op->lrp_networks.n_ipv6_addrs; i++) {
@@ -12419,7 +12426,7 @@ parsed_routes_add_connected(const struct ovn_datapath 
*od,
 
         parsed_route_add(od, NULL, &addr->network, addr->plen, false,
                          addr->addr_s, op, 0, false, false, false,
-                         NULL, ROUTE_SOURCE_CONNECTED,
+                         NULL, ROUTE_SOURCE_CONNECTED, true,
                          &op->nbrp->header_, NULL, routes);
     }
 }
diff --git a/northd/northd.h b/northd/northd.h
index 823f91a26..74fb58848 100644
--- a/northd/northd.h
+++ b/northd/northd.h
@@ -857,6 +857,7 @@ struct parsed_route {
     char *lrp_addr_s;
     const struct ovn_port *out_port;
     const struct ovn_port *tracked_port; /* May be NULL. */
+    bool dynamic_routing_advertise;
 };
 
 struct parsed_route *parsed_route_clone(const struct parsed_route *);
@@ -880,6 +881,7 @@ struct parsed_route *parsed_route_add(
     bool override_connected,
     const struct sset *ecmp_selection_fields,
     enum route_source source,
+    bool dynamic_routing_advertise,
     const struct ovsdb_idl_row *source_hint,
     const struct ovn_port *tracked_port,
     struct hmap *routes);
diff --git a/ovn-nb.xml b/ovn-nb.xml
index 442657018..a54a854c0 100644
--- a/ovn-nb.xml
+++ b/ovn-nb.xml
@@ -5072,13 +5072,13 @@ or
           <li>static</li>
         </ol>
       </column>
-      <column name="options" key="override-connected">
-        This option can be manually set for local static routes and
-        automatically set for ovn-interconnected learned routes.
-        Default value: <code>false</code>.
 
-        This option raises route's priority to be highest among routes
-        with same prefix.
+      <column name="options" key="dynamic-routing-advertise">
+        If the CMS set <ref column="options" key="dynamic-routing-redistribute"
+        table="Logical_Router"/> to <code>static</code>, this parameter can
+        be used to enable/disable the advertisement of the current static route
+        via the <ref table="Advertised_Route" db="OVN_Southbound"/> table.
+        Default: <code>true</code>.
       </column>
     </group>
 
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index 26a19bd96..4b5a6c883 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -15906,10 +15906,17 @@ check_column 10.0.1.0/24 Advertised_Route ip_prefix 
datapath=$datapath logical_p
 
 # Adding a static route adds an additional entry.
 check ovn-nbctl --wait=sb lr-route-add lr0 192.168.0.0/24 10.0.0.10
+lsr_uuid=$(fetch_column nb:Logical_Router_Static_Route _uuid 
nexthop="10.0.0.10")
+
 check_row_count Advertised_Route 3
 check_row_count Advertised_Route 2 logical_port=$pb
 check_row_count Advertised_Route 1 logical_port=$pb ip_prefix=192.168.0.0/24
 
+check ovn-nbctl --wait=sb set Logical_Router_Static_Route $lsr_uuid 
options:dynamic-routing-advertise=false
+check_row_count Advertised_Route 0 logical_port=$pb ip_prefix=192.168.0.0/24
+check ovn-nbctl --wait=sb set Logical_Router_Static_Route $lsr_uuid 
options:dynamic-routing-advertise=true
+check_row_count Advertised_Route 1 logical_port=$pb ip_prefix=192.168.0.0/24
+
 # Adding two static ECMP routes adds no additional entry.
 check ovn-nbctl --wait=sb lr-route-del lr0 192.168.0.0/24 10.0.0.10
 check ovn-nbctl --wait=sb --ecmp lr-route-add lr0 192.168.0.0/24 10.0.0.10
-- 
2.54.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to