From a2810d30256e8de250b9e0fdc274fc4852c7877c Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 18 May 2021 13:55:48 +0200 Subject: [PATCH] pimd: fix PtP address handling When we have a "192.0.2.1 peer 192.0.2.2/32" address on an interface, we need to (a) recognize the local address as being on the link for our own packets, and (b) do the IGMP socket lookup with the proper local address rather than the peer prefix. Fixes: efe6f18 ("pimd: fix IGMP receive handling") Cc: Nathan Bahr Signed-off-by: David Lamparter --- pimd/pim_iface.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 48b019c8c..0b28a3e84 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -1512,10 +1512,15 @@ struct prefix *pim_if_connected_to_source(struct interface *ifp, struct in_addr p.prefixlen = IPV4_MAX_BITLEN; for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) { - if ((c->address->family == AF_INET) - && prefix_match(CONNECTED_PREFIX(c), &p)) { - return CONNECTED_PREFIX(c); - } + if (c->address->family != AF_INET) + continue; + if (prefix_match(c->address, &p)) + return c->address; + if (CONNECTED_PEER(c) && prefix_match(c->destination, &p)) + /* this is not a typo, on PtP we need to return the + * *local* address that lines up with src. + */ + return c->address; } return NULL;