From 6cddc4c866fb8fb397112e5a89c74a9ff6359981 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Fri, 24 Mar 2023 14:38:47 +0200 Subject: [PATCH] bgpd: Allow self next-hop if `bgp allow-martian-nexthop` is enabled For instance, if we receive the routes from the peer with the next-hop as me, but those routes shares the same network, we can fake the next-hop. Signed-off-by: Donatas Abraitis --- bgpd/bgp_route.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 7365d53212..787aea1689 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3830,6 +3830,12 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi, (type == ZEBRA_ROUTE_BGP && stype == BGP_ROUTE_STATIC) ? true : false; + /* If `bgp allow-martian-nexthop` is turned on, return next-hop + * as good. + */ + if (bgp->allow_martian) + return false; + /* * Only validated for unicast and multicast currently. * Also valid for EVPN where the nexthop is an IP address. -- 2.39.5