Hi Felix,

CI for this patch looked pretty bad, and it's because of the removal of route_exchange_relevant_port() from route.h. This causes compilation errors. If this part of the patch is moved to patch 2, then

Acked-by: Mark Michelson <mmich...@redhat.com>

On 4/30/25 03:37, Felix Huettner via dev wrote:
Previously we created an advertise_datapath_entry for each local router
datapath, independently if any of its ports are bound to the current
chassis or take part in dynamic-routing at all.

As ad->maintain_vrf was false and there was never a route added this did
not do anything other than wasting memory.

Signed-off-by: Felix Huettner <felix.huettner@stackit.cloud>
---
  controller/route.c | 25 +++++++++++++++----------
  controller/route.h |  1 -
  2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/controller/route.c b/controller/route.c
index 55d3e0ae3..ebb44ab53 100644
--- a/controller/route.c
+++ b/controller/route.c
@@ -36,7 +36,7 @@ VLOG_DEFINE_THIS_MODULE(exchange);
  #define PRIORITY_DEFAULT 1000
  #define PRIORITY_LOCAL_BOUND 100
-bool
+static bool
  route_exchange_relevant_port(const struct sbrec_port_binding *pb)
  {
      return pb && smap_get_bool(&pb->options, "dynamic-routing", false);
@@ -161,11 +161,7 @@ route_run(struct route_ctx_in *r_ctx_in,
          if (!ld->n_peer_ports || ld->is_switch) {
              continue;
          }
-
-        ad = xzalloc(sizeof(*ad));
-        ad->db = ld->datapath;
-        hmap_init(&ad->routes);
-        smap_init(&ad->bound_ports);
+        ad = NULL;
/* This is a LR datapath, find LRPs with route exchange options
           * that are bound locally. */
@@ -181,6 +177,13 @@ route_run(struct route_ctx_in *r_ctx_in,
                  continue;
              }
+ if (!ad) {
+                ad = xzalloc(sizeof(*ad));
+                ad->db = ld->datapath;
+                hmap_init(&ad->routes);
+                smap_init(&ad->bound_ports);
+            }
+
              ad->maintain_vrf |=
                  smap_get_bool(&repb->options,
                                "dynamic-routing-maintain-vrf",
@@ -223,10 +226,12 @@ route_run(struct route_ctx_in *r_ctx_in,
              }
          }
- tracked_datapath_add(ld->datapath, TRACKED_RESOURCE_NEW,
-                             r_ctx_out->tracked_re_datapaths);
-
-        hmap_insert(r_ctx_out->announce_routes, &ad->node, ad->db->tunnel_key);
+        if (ad) {
+            tracked_datapath_add(ld->datapath, TRACKED_RESOURCE_NEW,
+                                 r_ctx_out->tracked_re_datapaths);
+            hmap_insert(r_ctx_out->announce_routes, &ad->node,
+                        ad->db->tunnel_key);
+        }
      }
const struct sbrec_advertised_route *route;
diff --git a/controller/route.h b/controller/route.h
index aee7ad302..11016d818 100644
--- a/controller/route.h
+++ b/controller/route.h
@@ -83,7 +83,6 @@ const struct sbrec_port_binding *route_exchange_find_port(
      const struct sbrec_chassis *chassis,
      const struct sset *active_tunnels,
      const struct sbrec_port_binding *pb);
-bool route_exchange_relevant_port(const struct sbrec_port_binding *);
  uint32_t advertise_route_hash(const struct in6_addr *dst, unsigned int plen);
  void route_run(struct route_ctx_in *, struct route_ctx_out *);
  void route_cleanup(struct hmap *announce_routes);

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to