diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2024-12-12 15:08:35 -0500 | 
|---|---|---|
| committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-12-13 04:03:45 +0000 | 
| commit | c71114ff7f37481eac0338cdfe9e276f6e9f5cfd (patch) | |
| tree | 56bd3c48b1c253b0d65d3caab91e665c1428591e /bgpd/bgp_fsm.c | |
| parent | 90de7a4ece16f3d6441fd7311197fcedc9dde7a7 (diff) | |
bgpd: When calling bgp_process, prevent infinite loop
If we have this construct:
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
     ...
     bgp_process();
}
This can induce an infinite loop.  This happens because bgp_process
will move the unsorted items to the top of the list for handling,
as such it is necessary to hold the next pointer to the side
to actually look at each possible bgp_path_info.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 40c31bdf4092d45c23fc0e1eed9467015d224d2d)
Diffstat (limited to 'bgpd/bgp_fsm.c')
| -rw-r--r-- | bgpd/bgp_fsm.c | 10 | 
1 files changed, 5 insertions, 5 deletions
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index e5692b6b48..ac33e8a62c 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -661,7 +661,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; @@ -676,8 +676,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; @@ -708,8 +708,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;  | 
