summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2020-06-23 11:46:56 -0400
committerGitHub <noreply@github.com>2020-06-23 11:46:56 -0400
commit08d14c81571d6a7d4d8206337ecdeec37da6ac60 (patch)
treeaa3bc9d949f3907003be957180e447bd53426003
parente28f42625e8e2ff618fc45c43a513fcb40ed6d58 (diff)
parent7ca4ef12b841f32f9eaf11e21f5abda7623f6bbb (diff)
Merge pull request #6629 from ton31337/fix/network_check_import_for_static_bgp_7.4
bgpd: [7.4] Do not treat the route as martian for static BGP routes
-rw-r--r--bgpd/bgp_route.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 0bf375415f..6ae7a59a14 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -3239,6 +3239,9 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_node *rn)
{
bool ret = false;
+ bool is_bgp_static_route =
+ (type == ZEBRA_ROUTE_BGP && stype == BGP_ROUTE_STATIC) ? true
+ : false;
/* Only validated for unicast and multicast currently. */
/* Also valid for EVPN where the nexthop is an IP address. */
@@ -3247,7 +3250,7 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
/* If NEXT_HOP is present, validate it. */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
- if (attr->nexthop.s_addr == INADDR_ANY
+ if ((attr->nexthop.s_addr == INADDR_ANY && !is_bgp_static_route)
|| IPV4_CLASS_DE(ntohl(attr->nexthop.s_addr))
|| bgp_nexthop_self(bgp, afi, type, stype, attr, rn))
return true;
@@ -3266,7 +3269,8 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
switch (attr->mp_nexthop_len) {
case BGP_ATTR_NHLEN_IPV4:
case BGP_ATTR_NHLEN_VPNV4:
- ret = (attr->mp_nexthop_global_in.s_addr == INADDR_ANY
+ ret = ((attr->mp_nexthop_global_in.s_addr == INADDR_ANY
+ && !is_bgp_static_route)
|| IPV4_CLASS_DE(
ntohl(attr->mp_nexthop_global_in.s_addr))
|| bgp_nexthop_self(bgp, afi, type, stype, attr,
@@ -3275,12 +3279,14 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
case BGP_ATTR_NHLEN_VPNV6_GLOBAL:
- ret = (IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)
+ ret = ((IN6_IS_ADDR_UNSPECIFIED(
+ &attr->mp_nexthop_global)
+ && !is_bgp_static_route)
|| IN6_IS_ADDR_LOOPBACK(&attr->mp_nexthop_global)
|| IN6_IS_ADDR_MULTICAST(
- &attr->mp_nexthop_global)
- || bgp_nexthop_self(bgp, afi, type, stype,
- attr, rn));
+ &attr->mp_nexthop_global)
+ || bgp_nexthop_self(bgp, afi, type, stype, attr,
+ rn));
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
ret = (IN6_IS_ADDR_LOOPBACK(&attr->mp_nexthop_global)