]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Do not treat the route as martian for static BGP routes 6629/head
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Mon, 22 Jun 2020 13:23:24 +0000 (16:23 +0300)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Tue, 23 Jun 2020 13:45:39 +0000 (16:45 +0300)
If we have something like:
```
ip route 1.1.1.0/24 Null0
!
router bgp 100
 no bgp ebgp-requires-policy
 neighbor 192.168.0.2 remote-as 200
 !
 address-family ipv4 unicast
  network 1.1.1.0/24
  redistribute connected
 exit-address-family
!
line vty
!
```

1.1.1.0/24 is not advertised due to martian nexthop (0.0.0.0). It starts
working only when we use `redistribute static`.

By checking if it's a BGP static route we able to announce
1.1.1.0/24 with `network 1.1.1.0/24` without redistribute even when
`bgp import-check` is enabled.

Disabling `bgp import-check` works as well, but it's enabled by default
since 7.4.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
bgpd/bgp_route.c

index 0bf375415f05d038d28e2e18f06296b9856ec6f7..6ae7a59a14d52ba415c784f42a212f5315da0871 100644 (file)
@@ -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)