From 647450524c42ba88c8b5acd60255e9018734c6b9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 26 Jul 2017 09:57:35 -0400 Subject: [PATCH 1/2] bgpd: Set the ifindex to DELETED after we notify zebra The code path for a deleted interface was calling zebra with a IFINDEX_DELETED, which caused zebra to bitch and moan about the issue. Since the only thing this function does is call zebra to deregister the RA stuff, don't set the ifindex to DELETED till afterwords. Signed-off-by: Donald Sharp --- bgpd/bgp_zebra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 8bf5477a61..4870e54aec 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -269,8 +269,6 @@ static int bgp_interface_delete(int command, struct zclient *zclient, if (!ifp) /* This may happen if we've just unregistered for a VRF. */ return 0; - ifp->ifindex = IFINDEX_DELETED; - if (BGP_DEBUG(zebra, ZEBRA)) zlog_debug("Rx Intf del VRF %u IF %s", vrf_id, ifp->name); @@ -279,6 +277,8 @@ static int bgp_interface_delete(int command, struct zclient *zclient, return 0; bgp_update_interface_nbrs(bgp, ifp, NULL); + + ifp->ifindex = IFINDEX_DELETED; return 0; } From 05a38c0c8b1887c58e0b916880aaf7e3004a3cc2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 26 Jul 2017 09:41:36 -0400 Subject: [PATCH 2/2] bgpd: Fix nexthop comparison for v6 When we have both a LL and a Global address, use what the attribute wants for comparison instead of assuming Global than LL. This was causing BGP to install v6 routes that used the LL as the nexthop, where the global address was different and being used as the basis for comparison. Signed-off-by: Donald Sharp --- bgpd/bgp_mpath.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index 6dc6dc6769..d3ee140bb4 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -102,6 +102,7 @@ int bgp_maximum_paths_unset(struct bgp *bgp, afi_t afi, safi_t safi, int bgp_info_nexthop_cmp(struct bgp_info *bi1, struct bgp_info *bi2) { int compare; + struct in6_addr addr1, addr2; compare = IPV4_ADDR_CMP(&bi1->attr->nexthop, &bi2->attr->nexthop); if (!compare) { @@ -120,13 +121,18 @@ int bgp_info_nexthop_cmp(struct bgp_info *bi1, struct bgp_info *bi2) &bi2->attr->mp_nexthop_global); break; case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: - compare = IPV6_ADDR_CMP( - &bi1->attr->mp_nexthop_global, - &bi2->attr->mp_nexthop_global); + addr1 = (bi1->attr->mp_nexthop_prefer_global) ? + bi1->attr->mp_nexthop_global + : bi1->attr->mp_nexthop_local; + addr2 = (bi2->attr->mp_nexthop_prefer_global) ? + bi2->attr->mp_nexthop_global + : bi2->attr->mp_nexthop_local; + + if (!bi1->attr->mp_nexthop_prefer_global && + !bi2->attr->mp_nexthop_prefer_global) + compare = !(bi1->peer->ifindex == bi2->peer->ifindex); if (!compare) - compare = IPV6_ADDR_CMP( - &bi1->attr->mp_nexthop_local, - &bi2->attr->mp_nexthop_local); + compare = IPV6_ADDR_CMP(&addr1, &addr2); break; } }