]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: fix route-map update and delete route-map
authorAbhinay Ramesh <rabhinay@vmware.com>
Mon, 7 Mar 2022 08:56:10 +0000 (08:56 +0000)
committerARShreenidhi <rshreenidhi@vmware.com>
Wed, 6 Jul 2022 05:38:35 +0000 (05:38 +0000)
Description:
- When there is change in route-map properties after
  setting the route-map with default route, changes
  will not reflect.
- When route-map associated with default-originate is
  deleted, default route doesn't get withdrawn.

- When there is change in route-map default-originate flow
  does not get triggered.

Fix:
- One of the flags needs to be unset for default-originate
  flow to get triggered after change in route-map.
  Have unset the flag, so that default originate flow can
  be triggered.

Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
bgpd/bgp_updgrp.c
bgpd/bgp_updgrp_adv.c

index c2b66326432c94121d5c95a94b1834e4910ecbc5..af2f564de74573db570f3bfa32d7e57c84dd1ed2 100644 (file)
@@ -1482,7 +1482,24 @@ static int updgrp_policy_update_walkcb(struct update_group *updgrp, void *arg)
                                        "u%" PRIu64 ":s%" PRIu64" announcing default upon default routemap %s change",
                                        updgrp->id, subgrp->id,
                                        ctx->policy_name);
-                       subgroup_default_originate(subgrp, 0);
+                       if (route_map_lookup_by_name(ctx->policy_name)) {
+                               /*
+                                * When there is change in routemap, this flow
+                                * is triggered. the routemap is still present
+                                * in lib, hence its a update flow. The flag
+                                * needs to be unset.
+                                */
+                               UNSET_FLAG(subgrp->sflags,
+                                          SUBGRP_STATUS_DEFAULT_ORIGINATE);
+                               subgroup_default_originate(subgrp, 0);
+                       } else {
+                               /*
+                                * This is a explicit withdraw, since the
+                                * routemap is not present in routemap lib. need
+                                * to pass 1 for withdraw arg.
+                                */
+                               subgroup_default_originate(subgrp, 1);
+                       }
                }
                update_subgroup_set_needs_refresh(subgrp, 0);
        }
@@ -1860,6 +1877,13 @@ update_group_default_originate_route_map_walkcb(struct update_group *updgrp,
                safi = SUBGRP_SAFI(subgrp);
 
                if (peer->default_rmap[afi][safi].name) {
+                       /*
+                        * When there is change in routemap this flow will
+                        * be triggered. We need to unset the Flag to ensure
+                        * the update flow gets triggered.
+                        */
+                       UNSET_FLAG(subgrp->sflags,
+                                  SUBGRP_STATUS_DEFAULT_ORIGINATE);
                        subgroup_default_originate(subgrp, 0);
                }
        }
index 518ce485af6d88e09d24847c6ec0dd7051eddb50..52f903f4fa414b5df6d747a47f5e0fc8568802d8 100644 (file)
@@ -879,8 +879,20 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
                }
                bgp->peer_self->rmap_type = 0;
 
-               if (ret == RMAP_DENYMATCH)
+               if (ret == RMAP_DENYMATCH) {
+                       /*
+                        * If its a implicit withdraw due to routemap
+                        * deny operation need to set the flag back.
+                        * This is a convertion of update flow to
+                        * withdraw flow.
+                        */
+                       if (!withdraw &&
+                           (!CHECK_FLAG(subgrp->sflags,
+                                        SUBGRP_STATUS_DEFAULT_ORIGINATE)))
+                               SET_FLAG(subgrp->sflags,
+                                        SUBGRP_STATUS_DEFAULT_ORIGINATE);
                        withdraw = 1;
+               }
        }
 
        /* Check if the default route is in local BGP RIB which is