Remote ports that represent logical router ports in other AZs can be
marked with options:is_router=true, so northd handles them like router
ports: they are omitted from _MC_flood_l2 and no static ARP/ND entries
are created for their addresses.  Since ovn-ic creates and owns these
ports, the CMS has to set the option again whenever ovn-ic recreates
them.

Add a NB_Global option, ic-remote-lrp-is-router.  When set, ovn-ic
marks the remote ports of transit switches that represent logical
router ports with options:is_router=true, and removes the mark when the
option is disabled.  A remote port represents a router port if its
transit switch port has type "router" or, for ports connected the
legacy way, if its IC-SB Port_Binding has external_ids:router-id.

The option affects the remote ports of every transit switch, so a
change triggers a full recompute of the port binding node.

Assisted-by: Claude Opus 5.5, Claude Code
Signed-off-by: Lucas Vargas Dias <[email protected]>
---
 NEWS                 |   4 ++
 ic/en-port-binding.c |  85 +++++++++++++++++++++++++++++++++---
 ic/en-port-binding.h |   2 +
 ic/inc-proc-ic.c     |   2 +
 ovn-nb.xml           |  24 ++++++++++
 tests/ovn-ic.at      | 101 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 211 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index b2416f98b..339395ef0 100644
--- a/NEWS
+++ b/NEWS
@@ -77,6 +77,10 @@ Post v26.09.0
      the replies from the backends of its load balancers.  The CMS must make
      sure that the replies re-enter the router on the chassis that load
      balanced the request.  See ovn-nb(5).
+   - Added a new NB_Global "options:ic-remote-lrp-is-router" option.  When
+     set, ovn-ic marks the remote ports of transit switches that represent
+     logical router ports in other availability zones with
+     "options:is_router=true".
 
 OVN v26.09.0 - xxx xx xxxx
 --------------------------
diff --git a/ic/en-port-binding.c b/ic/en-port-binding.c
index 0beb9e4e7..64c89acf5 100644
--- a/ic/en-port-binding.c
+++ b/ic/en-port-binding.c
@@ -273,6 +273,39 @@ sync_local_port(struct ic_context *ctx,
     sync_lsp_tnl_key(lsp, isb_pb->tunnel_key);
 }
 
+/* Returns true if ovn-ic should mark the remote ports of transit switches
+ * that represent router ports in other AZs with options:is_router=true. */
+static bool
+remote_lrp_is_router_enabled(const struct nbrec_nb_global *nb_global)
+{
+    return nb_global && smap_get_bool(&nb_global->options,
+                                      "ic-remote-lrp-is-router", false);
+}
+
+/* Sets options:is_router on remote port 'lsp' if 'is_router' is true and
+ * removes it otherwise. */
+static void
+sync_remote_lsp_is_router(const struct nbrec_logical_switch_port *lsp,
+                          bool is_router)
+{
+    if (is_router) {
+        if (!smap_get_bool(&lsp->options, "is_router", false)) {
+            nbrec_logical_switch_port_update_options_setkey(
+                lsp, "is_router", "true");
+        }
+    } else if (smap_get(&lsp->options, "is_router")) {
+        nbrec_logical_switch_port_update_options_delkey(lsp, "is_router");
+    }
+}
+
+/* Returns true if IC-SB port binding 'isb_pb' of a transit switch represents
+ * a logical router port, i.e., the AZ that owns it found its router. */
+static bool
+isb_pb_is_router_port(const struct icsbrec_port_binding *isb_pb)
+{
+    return smap_get(&isb_pb->external_ids, "router-id") != NULL;
+}
+
 static void
 sync_tsp_router_peer(const struct icnbrec_transit_switch_port *tsp,
                      const struct nbrec_logical_switch_port *lsp)
@@ -350,17 +383,22 @@ sync_tsp_local(const struct icnbrec_transit_switch_port 
*tsp,
         nbrec_logical_switch_port_set_type(lsp, tsp->type);
     }
     sync_tsp_common(tsp, isb_pb, lsp);
+    /* The port may have been remote before. */
+    sync_remote_lsp_is_router(lsp, false);
 }
 
 static void
 sync_tsp_remote(const struct icnbrec_transit_switch_port *tsp,
                 const struct icsbrec_port_binding *isb_pb,
-                const struct nbrec_logical_switch_port *lsp)
+                const struct nbrec_logical_switch_port *lsp,
+                bool remote_lrp_is_router)
 {
     if (strcmp(lsp->type, "remote")) {
         nbrec_logical_switch_port_set_type(lsp, "remote");
     }
     sync_tsp_common(tsp, isb_pb, lsp);
+    sync_remote_lsp_is_router(
+        lsp, remote_lrp_is_router && !strcmp(tsp->type, "router"));
 }
 
 /* For each remote port:
@@ -371,8 +409,12 @@ static void
 sync_remote_port(struct ic_context *ctx,
                  const struct icsbrec_port_binding *isb_pb,
                  const struct nbrec_logical_switch_port *lsp,
-                 const struct sbrec_port_binding *sb_pb)
+                 const struct sbrec_port_binding *sb_pb,
+                 bool remote_lrp_is_router)
 {
+    sync_remote_lsp_is_router(
+        lsp, remote_lrp_is_router && isb_pb_is_router_port(isb_pb));
+
     /* Sync address from ISB to NB */
     if (isb_pb->address[0]) {
         if (lsp->n_addresses != 1 ||
@@ -463,7 +505,8 @@ sync_router_port(const struct icsbrec_port_binding *isb_pb,
 static void
 create_nb_lsp(struct ic_context *ctx,
               const struct icsbrec_port_binding *isb_pb,
-              const struct nbrec_logical_switch *ls)
+              const struct nbrec_logical_switch *ls,
+              bool remote_lrp_is_router)
 {
     /* The NB Logical_Switch_Port name is unique across the whole NB, but a
      * remote AZ may bind a port whose name is already used here, e.g. by a
@@ -497,6 +540,8 @@ create_nb_lsp(struct ic_context *ctx,
             lsp, (const char **)&isb_pb->address, 1);
     }
     sync_lsp_tnl_key(lsp, isb_pb->tunnel_key);
+    sync_remote_lsp_is_router(
+        lsp, remote_lrp_is_router && isb_pb_is_router_port(isb_pb));
     nbrec_logical_switch_update_ports_addvalue(ls, lsp);
 }
 
@@ -723,6 +768,8 @@ port_binding_sync_ts(struct ic_context *ctx,
         return;
     }
 
+    bool remote_lrp_is_router = remote_lrp_is_router_enabled(
+        nbrec_nb_global_first(ctx->ovnnb_idl));
     struct shash nb_ports = SHASH_INITIALIZER(&nb_ports);
     struct shash old_nb_ports = SHASH_INITIALIZER(&old_nb_ports);
     struct shash local_pbs = SHASH_INITIALIZER(&local_pbs);
@@ -806,7 +853,7 @@ port_binding_sync_ts(struct ic_context *ctx,
         if (!tsp->chassis[0] || !chassis_is_remote(ctx, tsp->chassis)) {
             sync_tsp_local(tsp, isb_pb, lsp);
         } else {
-            sync_tsp_remote(tsp, isb_pb, lsp);
+            sync_tsp_remote(tsp, isb_pb, lsp, remote_lrp_is_router);
         }
     }
 
@@ -855,7 +902,8 @@ port_binding_sync_ts(struct ic_context *ctx,
                 if (!sb_pb) {
                     continue;
                 }
-                sync_remote_port(ctx, isb_pb, lsp, sb_pb);
+                sync_remote_port(ctx, isb_pb, lsp, sb_pb,
+                                 remote_lrp_is_router);
             }
         } else {
             VLOG_DBG("Ignore lsp %s on ts %s with type %s.",
@@ -875,7 +923,7 @@ port_binding_sync_ts(struct ic_context *ctx,
 
     /* Create lsp in NB for remote ports */
     SHASH_FOR_EACH (node, &remote_pbs) {
-        create_nb_lsp(ctx, node->data, ls);
+        create_nb_lsp(ctx, node->data, ls, remote_lrp_is_router);
     }
 
     ovn_destroy_tnlids(&pb_tnlids);
@@ -1239,11 +1287,15 @@ port_binding_sb_name_ts_map_destroy(struct shash *map)
 struct ed_type_port_binding {
     struct sset synced_ts;
     struct sset synced_tr;
+    /* Value of NB_Global options:ic-remote-lrp-is-router used by the last
+     * full sync. */
+    bool remote_lrp_is_router;
 };
 
 enum engine_node_state
-en_port_binding_run(struct engine_node *node, void *data OVS_UNUSED)
+en_port_binding_run(struct engine_node *node, void *data_)
 {
+    struct ed_type_port_binding *data = data_;
     const struct engine_context *eng_ctx = engine_get_context();
     struct ic_context *ctx = eng_ctx->client_ctx;
     const struct ed_type_az *az = engine_get_input_data("az", node);
@@ -1254,6 +1306,8 @@ en_port_binding_run(struct engine_node *node, void *data 
OVS_UNUSED)
         return EN_UNCHANGED;
     }
 
+    data->remote_lrp_is_router = remote_lrp_is_router_enabled(
+        nbrec_nb_global_first(ctx->ovnnb_idl));
     port_binding_run(ctx, az->runned_az);
 
     return EN_UPDATED;
@@ -1747,6 +1801,23 @@ port_binding_sb_chassis_handler(struct engine_node *node,
     return EN_HANDLED_UNCHANGED;
 }
 
+/* NB_Global: only options:ic-remote-lrp-is-router is read by the sync and
+ * it affects the remote ports of every transit switch, so recompute when it
+ * changes. */
+enum engine_input_handler_result
+port_binding_nb_nb_global_handler(struct engine_node *node, void *data_)
+{
+    struct ed_type_port_binding *data = data_;
+    const struct nbrec_nb_global_table *tbl =
+        EN_OVSDB_GET(engine_get_input("NB_nb_global", node));
+
+    if (remote_lrp_is_router_enabled(nbrec_nb_global_table_first(tbl))
+        != data->remote_lrp_is_router) {
+        return EN_UNHANDLED;
+    }
+    return EN_HANDLED_UNCHANGED;
+}
+
 void *
 en_port_binding_init(struct engine_node *node OVS_UNUSED,
                      struct engine_arg *arg OVS_UNUSED)
diff --git a/ic/en-port-binding.h b/ic/en-port-binding.h
index 08bb8effa..7d63e4a17 100644
--- a/ic/en-port-binding.h
+++ b/ic/en-port-binding.h
@@ -49,5 +49,7 @@ enum engine_input_handler_result
 port_binding_sb_port_binding_handler(struct engine_node *node, void *data);
 enum engine_input_handler_result
 port_binding_sb_chassis_handler(struct engine_node *node, void *data);
+enum engine_input_handler_result
+port_binding_nb_nb_global_handler(struct engine_node *node, void *data);
 
 #endif /* EN_IC_PORT_BINDING_H */
diff --git a/ic/inc-proc-ic.c b/ic/inc-proc-ic.c
index af0060ae5..7b7e62154 100644
--- a/ic/inc-proc-ic.c
+++ b/ic/inc-proc-ic.c
@@ -314,6 +314,8 @@ void inc_proc_ic_init(struct ovsdb_idl_loop *nb,
      * updates. */
     engine_add_input(&en_port_binding, &en_sb_chassis,
                      port_binding_sb_chassis_handler);
+    engine_add_input(&en_port_binding, &en_nb_nb_global,
+                     port_binding_nb_nb_global_handler);
 
     /* en_route: advertise/learn cross-AZ routes.
      *
diff --git a/ovn-nb.xml b/ovn-nb.xml
index 7f4ee95b4..1b1409f63 100644
--- a/ovn-nb.xml
+++ b/ovn-nb.xml
@@ -583,6 +583,30 @@
         </column>
       </group>
 
+      <group title="Options for interconnection transit switch ports">
+        <column name="options" key="ic-remote-lrp-is-router"
+                type='{"type": "boolean"}'>
+          <p>
+            If set to <code>true</code>, <code>ovn-ic</code> sets
+            <ref table="Logical_Switch_Port" column="options"
+            key="is_router"/> to <code>true</code> on the
+            <code>remote</code> ports it creates on transit switches for
+            logical router ports of other availability zones, so they are
+            handled like router ports, e.g., they are not part of the
+            <code>_MC_flood_l2</code> multicast group and no static ARP/ND
+            entries are created for their addresses.  Remote ports that do
+            not represent a logical router port are not affected.
+            Default is <code>false</code>.
+          </p>
+
+          <p>
+            <code>ovn-ic</code> owns the <code>is_router</code> option of
+            the <code>remote</code> ports it creates: when this option is
+            <code>false</code> it removes <code>is_router</code> from them.
+          </p>
+        </column>
+      </group>
+
       <group title="Options for interconnection address_set advertisement">
         <p>
           These options control whether address_sets propagate from one OVN
diff --git a/tests/ovn-ic.at b/tests/ovn-ic.at
index 4576c725e..78468da09 100644
--- a/tests/ovn-ic.at
+++ b/tests/ovn-ic.at
@@ -326,6 +326,107 @@ OVN_CLEANUP_IC
 AT_CLEANUP
 ])
 
+OVN_FOR_EACH_NORTHD([
+AT_SETUP([ovn-ic -- remote router ports is_router option])
+
+ovn_init_ic_db
+net_add n1
+
+# 1 GW per AZ
+for i in 1 2; do
+    az=az$i
+    ovn_start $az
+    sim_add gw-$az
+    as gw-$az
+    check ovs-vsctl add-br br-phys
+    ovn_az_attach $az n1 br-phys 192.168.1.$i
+    check ovs-vsctl set open . external-ids:ovn-is-interconn=true
+done
+
+ovn_as az1
+check ovn-ic-nbctl --wait=sb ts-add ts1
+check ovn-nbctl lr-add lr1
+
+dnl Router port connected the legacy way.
+check ovn-nbctl lrp-add lr1 lrp1 00:00:00:00:00:01 10.0.0.1/24
+check ovn-nbctl lrp-set-gateway-chassis lrp1 gw-az1
+check ovn-nbctl lsp-add-router-port ts1 lsp1 lrp1
+
+dnl Router and non-router transit switch ports.
+check ovn-nbctl lrp-add lr1 lrp2 00:00:00:00:00:02 10.0.0.2/24
+check ovn-ic-nbctl tsp-add ts1 tsp1 type=router chassis=gw-az1 peer=lrp2
+check ovn-ic-nbctl tsp-set-addr tsp1 "00:00:00:00:00:02 10.0.0.2/24"
+check ovn-ic-nbctl tsp-add ts1 tsp2 chassis=gw-az1
+check ovn-ic-nbctl tsp-set-addr tsp2 "00:00:00:00:00:03 10.0.0.3/24"
+check ovn-ic-nbctl --wait=sb sync
+
+ovn_as az2
+wait_column "remote" nb:Logical_Switch_Port type name=lsp1
+wait_column "remote" nb:Logical_Switch_Port type name=tsp1
+wait_column "remote" nb:Logical_Switch_Port type name=tsp2
+
+check_is_router() {
+    for port in lsp1 tsp1 tsp2; do
+        echo $port $(ovn-nbctl --if-exists get Logical_Switch_Port $port \
+                     options:is_router)
+    done
+}
+
+dnl Remote ports aren't marked by default.
+AT_CHECK([check_is_router], [0], [dnl
+lsp1
+tsp1
+tsp2
+])
+
+dnl Only the remote router ports are marked when the option is set.
+check ovn-nbctl set NB_Global . options:ic-remote-lrp-is-router=true
+OVS_WAIT_UNTIL([test "$(check_is_router)" = 'lsp1 "true"
+tsp1 "true"
+tsp2'])
+
+dnl The remote ports are still bound to the remote chassis.
+check ovn-nbctl --wait=sb sync
+gw_az1=$(fetch_column Chassis _uuid name=gw-az1)
+for port in lsp1 tsp1; do
+    check_column remote Port_Binding type logical_port=$port
+    check_column "$gw_az1" Port_Binding chassis logical_port=$port
+done
+
+dnl ovn-ic restores the option if it is removed.
+check ovn-nbctl remove Logical_Switch_Port lsp1 options is_router
+OVS_WAIT_UNTIL([test "$(check_is_router)" = 'lsp1 "true"
+tsp1 "true"
+tsp2'])
+
+dnl A new remote router port is marked when it is created.
+ovn_as az1
+check ovn-nbctl lrp-add lr1 lrp3 00:00:00:00:00:04 10.0.0.4/24
+check ovn-nbctl lrp-set-gateway-chassis lrp3 gw-az1
+check ovn-nbctl lsp-add-router-port ts1 lsp3 lrp3
+check ovn-ic-nbctl --wait=sb sync
+ovn_as az2
+wait_row_count nb:Logical_Switch_Port 1 name=lsp3 options:is_router=true
+
+dnl Disabling the option removes the marks.
+check ovn-nbctl set NB_Global . options:ic-remote-lrp-is-router=false
+OVS_WAIT_UNTIL([test "$(check_is_router)" = 'lsp1
+tsp1
+tsp2'])
+wait_row_count nb:Logical_Switch_Port 0 name=lsp3 options:is_router=true
+
+ovn_as az1
+check ovn-ic-nbctl --wait=sb ts-del ts1
+for i in 1 2; do
+    az=az$i
+    ovn_as $az
+    OVN_CLEANUP_SBOX(gw-$az)
+    OVN_CLEANUP_AZ([$az])
+done
+OVN_CLEANUP_IC
+AT_CLEANUP
+])
+
 OVN_FOR_EACH_NORTHD([
 AT_SETUP([ovn-ic -- transit switch port type and address updates])
 
-- 
2.43.0


-- 




_'Esta mensagem é direcionada apenas para os endereços constantes no 
cabeçalho inicial. Se você não está listado nos endereços constantes no 
cabeçalho, pedimos-lhe que desconsidere completamente o conteúdo dessa 
mensagem e cuja cópia, encaminhamento e/ou execução das ações citadas estão 
imediatamente anuladas e proibidas'._


* **'Apesar do Magazine Luiza tomar 
todas as precauções razoáveis para assegurar que nenhum vírus esteja 
presente nesse e-mail, a empresa não poderá aceitar a responsabilidade por 
quaisquer perdas ou danos causados por esse e-mail ou por seus anexos'.*



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

Reply via email to