Introduce the {LSP,LRP}.option.dynamic-routing-advertise parameter in
oreder to enable/disable the advertisement of a specific host IP if the CMS
configures LRP dynamic-routing-redistribute option to connected-as-host.

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

diff --git a/northd/en-advertised-route-sync.c 
b/northd/en-advertised-route-sync.c
index 6b02cb048..d37bdb4a9 100644
--- a/northd/en-advertised-route-sync.c
+++ b/northd/en-advertised-route-sync.c
@@ -460,16 +460,28 @@ publish_host_routes(struct dynamic_routes_data *data,
     if (peer_od->nbr) {
         /* This is a LRP directly connected to another LRP. */
         const struct ovn_port *lrp = op->peer;
-        publish_lport_addresses(&data->routes, op->od, op,
-                                &lrp->lrp_networks, lrp);
+        if (smap_get_bool(&lrp->nbrp->options,
+                          "dynamic-routing-advertise", true)) {
+            publish_lport_addresses(&data->routes, op->od, op,
+                                    &lrp->lrp_networks, lrp);
+        }
         return;
     }
 
     struct ovn_port *port;
     HMAP_FOR_EACH (port, dp_node, &peer_od->ports) {
+        if (!smap_get_bool(&port->nbsp->options,
+                           "dynamic-routing-advertise", true)) {
+            continue;
+        }
+
         if (port->peer && port->peer->nbrp) {
             /* This is a LSP connected to an LRP */
             const struct ovn_port *lrp = port->peer;
+            if (!smap_get_bool(&lrp->nbrp->options,
+                               "dynamic-routing-advertise", true)) {
+                continue;
+            }
             publish_lport_addresses(&data->routes, op->od, op,
                                     &lrp->lrp_networks, lrp);
             /* Track the LR datapath on the other side of LS
diff --git a/ovn-nb.xml b/ovn-nb.xml
index a54a854c0..a45731b03 100644
--- a/ovn-nb.xml
+++ b/ovn-nb.xml
@@ -1463,6 +1463,14 @@
           limit.
         </column>
 
+        <column name="options" key="dynamic-routing-advertise">
+          If the CSM set <ref column="options"
+          key="dynamic-routing-redistribute" table="Logical_Router_Port"/> to
+          <code>connected-as-host</code>, this parameter is used by the CMS to
+          enable/disable the advertisement of the current host IP via the
+          <ref table="Advertised_Route" db="OVN_Southbound"/> table.
+          Default: <code>true</code>.
+        </column>
       </group>
 
       <group title="Options for localnet ports">
@@ -4667,6 +4675,15 @@ or
 
       </column>
 
+      <column name="options" key="dynamic-routing-advertise">
+        If the CSM set <ref column="options" key="dynamic-routing-redistribute"
+        table="Logical_Router_Port"/> to <code>connected-as-host</code>,
+        this parameter is used by the CMS to enable/disable the advertisement
+        of the current host IP via the <ref table="Advertised_Route"
+        db="OVN_Southbound"/> table.
+        Default: <code>true</code>.
+      </column>
+
       <column name="options"
           key="dynamic-routing-redistribute-local-only"
           type='{"type": "boolean"}'>
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index 4b5a6c883..3b1d7214d 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -16443,6 +16443,14 @@ check_row_count Advertised_Route 2 tracked_port!='[[]]'
 check_column $vif0 Advertised_Route tracked_port \
     datapath=$datapath logical_port=$sw0 ip_prefix=10.0.0.2
 
+sw0_vif0_uuid=$(fetch_column nb:Logical_Switch_Port _uuid name="sw0-vif0")
+check ovn-nbctl --wait=sb set Logical_Switch_Port $sw0_vif0_uuid 
options:dynamic-routing-advertise=false
+check_row_count Advertised_Route 2
+check ovn-nbctl --wait=sb set Logical_Switch_Port $sw0_vif0_uuid 
options:dynamic-routing-advertise=true
+check_row_count Advertised_Route 3
+check_column $vif0 Advertised_Route tracked_port \
+    datapath=$datapath logical_port=$sw0 ip_prefix=10.0.0.2
+
 # Adding a LR lr1 to the LS sw0 will advertise the LRP of the new router.
 check ovn-nbctl lr-add lr1
 check ovn-nbctl lrp-add lr1 lr1-sw0 00:00:00:01:ff:01 10.0.0.10/24
@@ -16455,6 +16463,14 @@ check_row_count Advertised_Route 3 tracked_port!='[[]]'
 check_column $lr1 Advertised_Route tracked_port \
     datapath=$datapath logical_port=$sw0 ip_prefix=10.0.0.10
 
+lr1_sw0_uuid=$(fetch_column nb:Logical_Router_Port _uuid name="lr1-sw0")
+check ovn-nbctl --wait=sb set Logical_Router_Port $lr1_sw0_uuid 
options:dynamic-routing-advertise=false
+check_row_count Advertised_Route 3
+check ovn-nbctl --wait=sb set Logical_Router_Port $lr1_sw0_uuid 
options:dynamic-routing-advertise=true
+check_row_count Advertised_Route 4
+check_column $lr1 Advertised_Route tracked_port \
+    datapath=$datapath logical_port=$sw0 ip_prefix=10.0.0.10
+
 # Adding a NAT rule to lr1 will advertise it as well.
 check ovn-nbctl --wait=sb lr-nat-add lr1 dnat_and_snat 10.0.0.100 192.168.0.1
 check_row_count Advertised_Route 5
@@ -16485,6 +16501,14 @@ check_row_count Advertised_Route 4 tracked_port!='[[]]'
 check_row_count Advertised_Route 1 datapath=$datapath logical_port=$lr0lr2 \
     ip_prefix=10.10.0.20 tracked_port='[[]]'
 
+lr1_lr0_uuid=$(fetch_column nb:Logical_Router_Port _uuid name="lr2-lr0")
+check ovn-nbctl --wait=sb set Logical_Router_Port $lr1_lr0_uuid 
options:dynamic-routing-advertise=false
+check_row_count Advertised_Route 7
+check ovn-nbctl --wait=sb set Logical_Router_Port $lr1_lr0_uuid 
options:dynamic-routing-advertise=true
+check_row_count Advertised_Route 8
+check_row_count Advertised_Route 1 datapath=$datapath logical_port=$lr0lr2 \
+    ip_prefix=10.10.0.20 tracked_port='[[]]'
+
 # Add a directly connected switch and make sure that northd is not confused.
 # The IP on a switch-switch port should be advertised.
 check ovn-nbctl ls-add sw1
-- 
2.54.0

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

Reply via email to