diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 86e35541c3da..f36371fce506 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -348,6 +348,15 @@ route_match_src_peer(void *rule, const struct prefix *prefix, void *object) 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;