From a3cb01d89c5c741b4fa3a0f4f46264eafa0184cf Mon Sep 17 00:00:00 2001 From: vivek Date: Sun, 13 Mar 2016 06:03:10 +0000 Subject: [PATCH] BGP: Check in multipath comparison before invoking sockunion_cmp During route selection for Multipath routes, when multiple peers are flapping, it is possible that the old (former) multipath list of routes for a destination may include routes from peers which are no longer in Established state. When the new multipath list is compared against the old list to identify changes, additional checks are needed to avoid comparing connection addresses if the peer is not in Established state. This patch introduces those checks. Signed-off-by: Vivek Venkatraman Reviewed-by: Daniel Walton Reviewed-by: Don Slice Ticket: CM-9671 Reviewed By: CCR-4277 Testing Done: Manual (problem could not be replicated to verify) --- bgpd/bgp_mpath.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index 50813df034..852d863296 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -188,7 +188,16 @@ bgp_info_mpath_cmp (void *val1, void *val2) compare = bgp_info_nexthop_cmp (bi1, bi2); if (!compare) - compare = sockunion_cmp (bi1->peer->su_remote, bi2->peer->su_remote); + { + if (!bi1->peer->su_remote && !bi2->peer->su_remote) + compare = 0; + else if (!bi1->peer->su_remote) + compare = 1; + else if (!bi2->peer->su_remote) + compare = -1; + else + compare = sockunion_cmp (bi1->peer->su_remote, bi2->peer->su_remote); + } return compare; } -- 2.39.5