]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Define function to check if performing graceful shutdown
authorvivek <vivek@cumulusnetworks.com>
Sat, 19 Sep 2020 19:50:46 +0000 (12:50 -0700)
committervivek <vivek@cumulusnetworks.com>
Sat, 19 Sep 2020 19:50:46 +0000 (12:50 -0700)
Signed-off-by: Vivek Venkatraman <vivek@nvidia.com>
bgpd/bgp_attr.c
bgpd/bgp_route.c
bgpd/bgp_updgrp_adv.c
bgpd/bgpd.h

index 8817263cefd78cb804aa5c001d8f62f0560dab0a..0821a724a647477468560d2644ac543d147b036a 100644 (file)
@@ -954,7 +954,7 @@ struct attr *bgp_attr_aggregate_intern(
                /* If we are not shutting down ourselves and we are
                 * aggregating a route that contains the GSHUT community we
                 * need to remove that community when creating the aggregate */
-               if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)
+               if (!bgp_in_graceful_shutdown(bgp)
                    && community_include(community, gshut)) {
                        community_del_val(community, &gshut);
                }
@@ -973,7 +973,7 @@ struct attr *bgp_attr_aggregate_intern(
                attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
        }
 
-       if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
+       if (bgp_in_graceful_shutdown(bgp))
                bgp_attr_add_gshut_community(&attr);
 
        attr.label_index = BGP_INVALID_LABEL_INDEX;
@@ -1016,13 +1016,13 @@ struct attr *bgp_attr_aggregate_intern(
                        return NULL;
                }
 
-               if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
+               if (bgp_in_graceful_shutdown(bgp))
                        bgp_attr_add_gshut_community(&attr_tmp);
 
                new = bgp_attr_intern(&attr_tmp);
        } else {
 
-               if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
+               if (bgp_in_graceful_shutdown(bgp))
                        bgp_attr_add_gshut_community(&attr);
 
                new = bgp_attr_intern(&attr);
index 626f766987d79fe043df19e96410e787913d7e4b..174c11fd34b00a80f512e47fb550051d4e244627 100644 (file)
@@ -2021,7 +2021,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
        if (aspath_check_as_zero(attr->aspath))
                return false;
 
-       if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+       if (bgp_in_graceful_shutdown(bgp)) {
                if (peer->sort == BGP_PEER_IBGP
                    || peer->sort == BGP_PEER_CONFED) {
                        attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF);
@@ -3579,8 +3579,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
 
                        /* If graceful-shutdown is configured then add the GSHUT
                         * community to all paths received from eBGP peers */
-               } else if (CHECK_FLAG(peer->bgp->flags,
-                                     BGP_FLAG_GRACEFUL_SHUTDOWN))
+               } else if (bgp_in_graceful_shutdown(peer->bgp))
                        bgp_attr_add_gshut_community(&new_attr);
        }
 
@@ -5119,13 +5118,13 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
                        return;
                }
 
-               if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
+               if (bgp_in_graceful_shutdown(bgp))
                        bgp_attr_add_gshut_community(&attr_tmp);
 
                attr_new = bgp_attr_intern(&attr_tmp);
        } else {
 
-               if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
+               if (bgp_in_graceful_shutdown(bgp))
                        bgp_attr_add_gshut_community(&attr);
 
                attr_new = bgp_attr_intern(&attr);
@@ -7366,7 +7365,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
                        }
                }
 
-               if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
+               if (bgp_in_graceful_shutdown(bgp))
                        bgp_attr_add_gshut_community(&attr_new);
 
                bn = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi,
index 76bf2db05b3b1b413317d5ed23fd39099d03d726..67fa9a3ea3e2dc69984817f8b8de5150323f2ad4 100644 (file)
@@ -868,7 +868,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
                        }
 
                        /* Advertise the default route */
-                       if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
+                       if (bgp_in_graceful_shutdown(bgp))
                                bgp_attr_add_gshut_community(new_attr);
 
                        SET_FLAG(subgrp->sflags,
index 2aa069002543de88e4138c78e45bb3fdd87703b0..6293c4136c936b348c74f0bd1b3e3a038ce6b35d 100644 (file)
@@ -2157,6 +2157,11 @@ static inline void bgp_vrf_unlink(struct bgp *bgp, struct vrf *vrf)
        bgp->vrf_id = VRF_UNKNOWN;
 }
 
+static inline bool bgp_in_graceful_shutdown(struct bgp *bgp)
+{
+       return !!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN);
+}
+
 extern void bgp_unset_redist_vrf_bitmaps(struct bgp *, vrf_id_t);
 
 /* For benefit of rfapi */