]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: fix churn of aggregate routes from duplicate config 17837/head
authorEnke Chen <enchen@paloaltonetworks.com>
Sat, 11 Jan 2025 22:01:36 +0000 (14:01 -0800)
committerEnke Chen <enchen@paloaltonetworks.com>
Sat, 11 Jan 2025 22:01:36 +0000 (14:01 -0800)
Currently when an aggregate-address is configured, the existing
entry is always removed regardless whether any change is involved.
This would create unnecessary churn of the aggregate route when
the same config is applied for the aggregate address.

The fix is to check for duplicate aggregate-address config.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
bgpd/bgp_route.c

index f520c2e2bc843694e5f3be239e09d09eeae6a594..494cc6d913aaa4b494006ebfa60305480745fe18 100644 (file)
@@ -8874,6 +8874,27 @@ static int bgp_aggregate_unset(struct vty *vty, const char *prefix_str,
        return CMD_SUCCESS;
 }
 
+static bool bgp_aggregate_cmp_params(struct bgp_aggregate *aggregate, const char *rmap,
+                                    uint8_t summary_only, uint8_t as_set, uint8_t origin,
+                                    bool match_med, const char *suppress_map)
+{
+       if ((aggregate->origin != origin) || (aggregate->as_set != as_set) ||
+           (aggregate->match_med != match_med) || (aggregate->summary_only != summary_only))
+               return false;
+
+       if ((!rmap && aggregate->rmap.name) || (rmap && !aggregate->rmap.name) ||
+           (rmap && aggregate->rmap.name && !strmatch(rmap, aggregate->rmap.name)))
+               return false;
+
+       if ((!suppress_map && aggregate->suppress_map_name) ||
+           (suppress_map && !aggregate->suppress_map_name) ||
+           (suppress_map && aggregate->suppress_map_name &&
+            !strmatch(suppress_map, aggregate->suppress_map_name)))
+               return false;
+
+       return true;
+}
+
 static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
                             safi_t safi, const char *rmap,
                             uint8_t summary_only, uint8_t as_set,
@@ -8913,6 +8934,11 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
        aggregate = bgp_dest_get_bgp_aggregate_info(dest);
 
        if (aggregate) {
+               /* Check for duplicate configs */
+               if (bgp_aggregate_cmp_params(aggregate, rmap, summary_only, as_set, origin,
+                                            match_med, suppress_map))
+                       return CMD_SUCCESS;
+
                vty_out(vty, "There is already same aggregate network.\n");
                /* try to remove the old entry */
                ret = bgp_aggregate_unset(vty, prefix_str, afi, safi);