Skip to content

Commit

Permalink
Merge pull request #17641 from donaldsharp/bgp_path_info_no_infinite_…
Browse files Browse the repository at this point in the history
…loop

bgpd: When calling bgp_process, prevent infinite loop
  • Loading branch information
Jafaral authored Dec 13, 2024
2 parents f7720ab + 40c31bd commit 38c2505
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
10 changes: 5 additions & 5 deletions bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ static void bgp_llgr_stale_timer_expire(struct event *thread)
static void bgp_set_llgr_stale(struct peer *peer, afi_t afi, safi_t safi)
{
struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_path_info *pi, *next;
struct bgp_table *table;
struct attr attr;

Expand All @@ -677,8 +677,8 @@ static void bgp_set_llgr_stale(struct peer *peer, afi_t afi, safi_t safi)

for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm))
for (pi = bgp_dest_get_bgp_path_info(rm); pi;
pi = pi->next) {
for (pi = bgp_dest_get_bgp_path_info(rm);
(pi != NULL) && (next = pi->next, 1); pi = next) {
if (pi->peer != peer)
continue;

Expand Down Expand Up @@ -709,8 +709,8 @@ static void bgp_set_llgr_stale(struct peer *peer, afi_t afi, safi_t safi)
} else {
for (dest = bgp_table_top(peer->bgp->rib[afi][safi]); dest;
dest = bgp_route_next(dest))
for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next) {
for (pi = bgp_dest_get_bgp_path_info(dest);
(pi != NULL) && (next = pi->next, 1); pi = next) {
if (pi->peer != peer)
continue;

Expand Down
20 changes: 12 additions & 8 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -7410,7 +7410,7 @@ static void bgp_purge_af_static_redist_routes(struct bgp *bgp, afi_t afi,
{
struct bgp_table *table;
struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_path_info *pi, *next;

/* Do not install the aggregate route if BGP is in the
* process of termination.
Expand All @@ -7421,7 +7421,8 @@ static void bgp_purge_af_static_redist_routes(struct bgp *bgp, afi_t afi,

table = bgp->rib[afi][safi];
for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
for (pi = bgp_dest_get_bgp_path_info(dest); (pi != NULL) && (next = pi->next, 1);
pi = next) {
if (pi->peer == bgp->peer_self
&& ((pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
Expand Down Expand Up @@ -7921,7 +7922,7 @@ void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate,
struct bgp_table *table = bgp->rib[afi][safi];
const struct prefix *dest_p;
struct bgp_dest *dest, *top;
struct bgp_path_info *pi;
struct bgp_path_info *pi, *next;

/* We've found a different MED we must revert any suppressed routes. */
top = bgp_node_get(table, p);
Expand All @@ -7931,7 +7932,8 @@ void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate,
if (dest_p->prefixlen <= p->prefixlen)
continue;

for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
for (pi = bgp_dest_get_bgp_path_info(dest); (pi != NULL) && (next = pi->next, 1);
pi = next) {
if (BGP_PATH_HOLDDOWN(pi))
continue;
if (pi->sub_type == BGP_ROUTE_AGGREGATE)
Expand Down Expand Up @@ -8006,7 +8008,7 @@ bool bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
struct community *community = NULL;
struct ecommunity *ecommunity = NULL;
struct lcommunity *lcommunity = NULL;
struct bgp_path_info *pi;
struct bgp_path_info *pi, *next;
uint8_t atomic_aggregate = 0;

/* If the bgp instance is being deleted or self peer is deleted
Expand Down Expand Up @@ -8056,7 +8058,8 @@ bool bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
if (!bgp_check_advertise(bgp, dest, safi))
continue;

for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
for (pi = bgp_dest_get_bgp_path_info(dest); (pi != NULL) && (next = pi->next, 1);
pi = next) {
if (BGP_PATH_HOLDDOWN(pi))
continue;

Expand Down Expand Up @@ -8213,7 +8216,7 @@ void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
struct bgp_table *table;
struct bgp_dest *top;
struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_path_info *pi, *next;

table = bgp->rib[afi][safi];

Expand All @@ -8226,7 +8229,8 @@ void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
if (dest_p->prefixlen <= p->prefixlen)
continue;

for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
for (pi = bgp_dest_get_bgp_path_info(dest); (pi != NULL) && (next = pi->next, 1);
pi = next) {
if (BGP_PATH_HOLDDOWN(pi))
continue;

Expand Down

0 comments on commit 38c2505

Please sign in to comment.