From f153998874ca2b53cf366af12d62a9428efea8b4 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 26 Sep 2024 14:06:08 +0300 Subject: [PATCH] bgpd: Fallback to destination peer when using `match src-peer ...` If using at incoming direction, e.g.: route-map test permit 10 match src-peer 10.0.0.1 ! router bgp 65000 neighbor 10.0.0.1 route-map test in ! Signed-off-by: Donatas Abraitis --- bgpd/bgp_routemap.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 15373a0c37..1d8b949ed4 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -348,6 +348,15 @@ static enum route_map_cmd_result_t route_match_src_peer(void *rule, const struct bpi = object; peer = bpi->from; + /* Fallback to destination (current) peer. This is mostly + * happens if `match src-peer ...` is used at incoming direction. + */ + if (!peer) + peer = bpi->peer; + + if (!peer) + return RMAP_NOMATCH; + if (pc->interface) { if (!peer->conf_if && !peer->group) return RMAP_NOMATCH;