mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-27 17:34:43 +00:00
bgpd: Do not treat the route as martian for static BGP routes
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>
This commit is contained in:
parent
e28f42625e
commit
7ca4ef12b8
@ -3239,6 +3239,9 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
|
|||||||
struct bgp_node *rn)
|
struct bgp_node *rn)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
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. */
|
/* Only validated for unicast and multicast currently. */
|
||||||
/* Also valid for EVPN where the nexthop is an IP address. */
|
/* 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 NEXT_HOP is present, validate it. */
|
||||||
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
|
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))
|
|| IPV4_CLASS_DE(ntohl(attr->nexthop.s_addr))
|
||||||
|| bgp_nexthop_self(bgp, afi, type, stype, attr, rn))
|
|| bgp_nexthop_self(bgp, afi, type, stype, attr, rn))
|
||||||
return true;
|
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) {
|
switch (attr->mp_nexthop_len) {
|
||||||
case BGP_ATTR_NHLEN_IPV4:
|
case BGP_ATTR_NHLEN_IPV4:
|
||||||
case BGP_ATTR_NHLEN_VPNV4:
|
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(
|
|| IPV4_CLASS_DE(
|
||||||
ntohl(attr->mp_nexthop_global_in.s_addr))
|
ntohl(attr->mp_nexthop_global_in.s_addr))
|
||||||
|| bgp_nexthop_self(bgp, afi, type, stype, attr,
|
|| 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_IPV6_GLOBAL:
|
||||||
case BGP_ATTR_NHLEN_VPNV6_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_LOOPBACK(&attr->mp_nexthop_global)
|
||||||
|| IN6_IS_ADDR_MULTICAST(
|
|| IN6_IS_ADDR_MULTICAST(
|
||||||
&attr->mp_nexthop_global)
|
&attr->mp_nexthop_global)
|
||||||
|| bgp_nexthop_self(bgp, afi, type, stype,
|
|| bgp_nexthop_self(bgp, afi, type, stype, attr,
|
||||||
attr, rn));
|
rn));
|
||||||
break;
|
break;
|
||||||
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
|
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
|
||||||
ret = (IN6_IS_ADDR_LOOPBACK(&attr->mp_nexthop_global)
|
ret = (IN6_IS_ADDR_LOOPBACK(&attr->mp_nexthop_global)
|
||||||
|
Loading…
Reference in New Issue
Block a user