diff options
| author | vivek <vivek@cumulusnetworks.com> | 2016-01-22 10:56:48 -0800 |
|---|---|---|
| committer | vivek <vivek@cumulusnetworks.com> | 2016-01-22 10:56:48 -0800 |
| commit | 96885f16b0838d3324db86153d50e27fe2cef3a6 (patch) | |
| tree | 48f7add4fe5fb036d43d6e8652d72bbf3eaa360c /bgpd/bgp_updgrp.h | |
| parent | 385f703b16874a97e9edd93c0ece5e74535d0c6b (diff) | |
BGP: Rework iteration of peer_af_array
While processing references to the macro PEERAF_FOREACH(), aggressive loop
optimization by gcc 4.9.x (probably 4.8 and greater) was resulting in the
generated code not checking on the index as well as eliminating some code.
This was leading to a dereference of invalid memory when a BGP peer came up.
The fix is to scrap this convoluted macro. Two other changes done are to
eliminate overloading of "afindex" and make the loop iterator an integer.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Dave Olson <olson@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Ticket: CM-8889
Reviewed By: CCR-4018
Testing Done: Verified failure scenario
Note: This code was added as part of update-groups implementation; when
upstreaming update-groups, this patch should also be included.
Diffstat (limited to 'bgpd/bgp_updgrp.h')
| -rw-r--r-- | bgpd/bgp_updgrp.h | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h index b94519ef00..aab2458b30 100644 --- a/bgpd/bgp_updgrp.h +++ b/bgpd/bgp_updgrp.h @@ -528,9 +528,14 @@ static inline void update_group_adjust_peer_afs (struct peer *peer) { struct peer_af *paf; - enum bgp_af_index afi; + int afidx; - PEERAF_FOREACH (peer, paf, afi) update_group_adjust_peer (paf); + for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; afidx++) + { + paf = peer->peer_af_array[afidx]; + if (paf != NULL) + update_group_adjust_peer (paf); + } } /* @@ -542,10 +547,14 @@ static inline void update_group_remove_peer_afs (struct peer *peer) { struct peer_af *paf; - enum bgp_af_index afi; + int afidx; - PEERAF_FOREACH (peer, paf, afi) - update_subgroup_remove_peer (PAF_SUBGRP (paf), paf); + for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; afidx++) + { + paf = peer->peer_af_array[afidx]; + if (paf != NULL) + update_subgroup_remove_peer (PAF_SUBGRP (paf), paf); + } } /* @@ -592,9 +601,14 @@ static inline void bgp_announce_peer (struct peer *peer) { struct peer_af *paf; - enum bgp_af_index af; + int afidx; - PEERAF_FOREACH (peer, paf, af) subgroup_announce_all (PAF_SUBGRP (paf)); + for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; afidx++) + { + paf = peer->peer_af_array[afidx]; + if (paf != NULL) + subgroup_announce_all (PAF_SUBGRP (paf)); + } } /** |
