Introduce the NAT.option.dynamic-routing-advertise parameter in order to
enable/disable the advertisement of a specific NAT external IP if the CMS
configures LRP dynamic-routing-redistribute option to nat.

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

diff --git a/northd/en-advertised-route-sync.c 
b/northd/en-advertised-route-sync.c
index d37bdb4a9..bb08cda68 100644
--- a/northd/en-advertised-route-sync.c
+++ b/northd/en-advertised-route-sync.c
@@ -185,6 +185,11 @@ build_nat_route_for_port(const struct ovn_port 
*advertising_op,
             continue;
         }
 
+        if (!smap_get_bool(&nat->nb->options,
+                           "dynamic-routing-advertise", true)) {
+            continue;
+        }
+
         const struct ovn_port *tracked_port =
             nat->is_distributed
             ? ovn_port_find(ls_ports, nat->nb->logical_port)
diff --git a/ovn-nb.xml b/ovn-nb.xml
index a45731b03..28c4ebe4d 100644
--- a/ovn-nb.xml
+++ b/ovn-nb.xml
@@ -5454,6 +5454,14 @@ or
       <code>ovn-northd</code> manpage section on IP Routing.
     </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>nat</code>, this parameter is
+      used by the CMS to enable/disable the advertisement of the current NAT
+      external IP via the <ref table="Advertised_Route" db="OVN_Southbound"/>
+      table. Default: <code>true</code>.
+    </column>
+
     <group title="Common Columns">
       <column name="external_ids">
         See <em>External IDs</em> at the beginning of this document.
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index 3b1d7214d..3dd251250 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -16478,6 +16478,14 @@ check_row_count Advertised_Route 3 tracked_port!='[[]]'
 check_column '' Advertised_Route tracked_port \
     datapath=$datapath logical_port=$sw0 ip_prefix=10.0.0.100
 
+lr1_nat_uuid=$(fetch_column nb:NAT _uuid external_ip=10.0.0.100)
+check ovn-nbctl --wait=sb set NAT $lr1_nat_uuid 
options:dynamic-routing-advertise=false
+check_row_count Advertised_Route 4
+check ovn-nbctl --wait=sb set NAT $lr1_nat_uuid 
options:dynamic-routing-advertise=true
+check_row_count Advertised_Route 5
+check_column '' Advertised_Route tracked_port \
+    datapath=$datapath logical_port=$sw0 ip_prefix=10.0.0.100
+
 # Adding a static route to lr1 will be advertised just normally.
 check ovn-nbctl --wait=sb lr-route-add lr0 172.16.0.0/24 10.0.0.200
 check_row_count Advertised_Route 6
@@ -17155,6 +17163,12 @@ check_row_count Advertised_Route 1 \
     logical_port=$pb               \
     tracked_port=[[]]
 
+lr0_nat_uuid=$(fetch_column nb:NAT _uuid external_ip=172.16.1.10)
+check ovn-nbctl --wait=sb set NAT $lr0_nat_uuid 
options:dynamic-routing-advertise=false
+check_row_count Advertised_Route 0
+check ovn-nbctl --wait=sb set NAT $lr0_nat_uuid 
options:dynamic-routing-advertise=true
+check_row_count Advertised_Route 1
+
 # Add LR with distributed LRP connected to GW router through join LS
 # and switch dynamic-routing-redistribute to lrp-guest-join so that
 # it advertises NAT routes from the neighbors in the join LS.
@@ -17195,6 +17209,26 @@ check_row_count Advertised_Route 1 \
     logical_port=$pb               \
     tracked_port=$pb2
 
+lr0_guest_nat_uuid=$(fetch_column nb:NAT _uuid external_ip=172.16.2.10)
+check ovn-nbctl --wait=sb set NAT $lr0_nat_uuid 
options:dynamic-routing-advertise=false
+check ovn-nbctl --wait=sb set NAT $lr0_guest_nat_uuid 
options:dynamic-routing-advertise=false
+check_row_count Advertised_Route 0
+
+check ovn-nbctl --wait=sb set NAT $lr0_nat_uuid 
options:dynamic-routing-advertise=true
+check ovn-nbctl --wait=sb set NAT $lr0_guest_nat_uuid 
options:dynamic-routing-advertise=true
+
+check_row_count Advertised_Route 2
+check_row_count Advertised_Route 1 \
+    ip_prefix="172.16.1.10"        \
+    datapath=$datapath             \
+    logical_port=$pb               \
+    tracked_port=[[]]
+check_row_count Advertised_Route 1 \
+    ip_prefix="172.16.2.10"        \
+    datapath=$datapath             \
+    logical_port=$pb               \
+    tracked_port=$pb2
+
 # Add nonlocal LR with distributed LRP connected to GW router through join LS.
 check ovn-nbctl \
     -- lr-add lr-guest1 \
@@ -17769,6 +17803,16 @@ dnl advertised for each lr-ext.
 n_advertised_routes=$((2 * ($n_ext_rtrs + 1)))
 check_row_count Advertised_Route $n_advertised_routes
 
+lr_ext1_nat_uuid=$(fetch_column nb:NAT _uuid external_ip=21.0.0.42)
+lr_ext2_nat_uuid=$(fetch_column nb:NAT _uuid external_ip=22.0.0.42)
+check ovn-nbctl --wait=sb set NAT $lr_ext1_nat_uuid 
options:dynamic-routing-advertise=false
+check ovn-nbctl --wait=sb set NAT $lr_ext2_nat_uuid 
options:dynamic-routing-advertise=false
+check_row_count Advertised_Route $((2 * n_ext_rtrs))
+
+check ovn-nbctl --wait=sb set NAT $lr_ext1_nat_uuid 
options:dynamic-routing-advertise=true
+check ovn-nbctl --wait=sb set NAT $lr_ext2_nat_uuid 
options:dynamic-routing-advertise=true
+check_row_count Advertised_Route $n_advertised_routes
+
 OVN_CLEANUP_NORTHD
 AT_CLEANUP
 ])
-- 
2.54.0

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

Reply via email to