]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Fix PIM6 MLD VRF support (use recvmsg() pktinfo)
authorMartin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
Tue, 4 Mar 2025 13:24:33 +0000 (14:24 +0100)
committerMartin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
Wed, 5 Mar 2025 15:27:23 +0000 (16:27 +0100)
When receiving MLD messages, prefer pktinfo over msghdr.msg_name for
determining the source interface. The latter is just the VRF master
interface in case of VRF and we need the true interface the packet was
received on instead.

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
pimd/pim6_mld.c

index 2546166d0ad907d737247a0060306115b2c3ce81..fed75a0a0cb2faa0096eba0f267aa13c658bdbb4 100644 (file)
@@ -1770,18 +1770,6 @@ static void gm_t_recv(struct event *t)
                goto out_free;
        }
 
-       struct interface *ifp;
-
-       ifp = if_lookup_by_index(pkt_src->sin6_scope_id, pim->vrf->vrf_id);
-       if (!ifp || !ifp->info)
-               goto out_free;
-
-       struct pim_interface *pim_ifp = ifp->info;
-       struct gm_if *gm_ifp = pim_ifp->mld;
-
-       if (!gm_ifp)
-               goto out_free;
-
        for (cmsg = CMSG_FIRSTHDR(mh); cmsg; cmsg = CMSG_NXTHDR(mh, cmsg)) {
                if (cmsg->cmsg_level != SOL_IPV6)
                        continue;
@@ -1800,6 +1788,21 @@ static void gm_t_recv(struct event *t)
                }
        }
 
+       /* Prefer pktinfo as that also works in case of VRF */
+       ifindex_t ifindex = pktinfo ? pktinfo->ipi6_ifindex
+                                   : pkt_src->sin6_scope_id;
+       struct interface *ifp;
+
+       ifp = if_lookup_by_index(ifindex, pim->vrf->vrf_id);
+       if (!ifp || !ifp->info)
+               goto out_free;
+
+       struct pim_interface *pim_ifp = ifp->info;
+       struct gm_if *gm_ifp = pim_ifp->mld;
+
+       if (!gm_ifp)
+               goto out_free;
+
        if (!pktinfo || !hoplimit) {
                zlog_err(log_ifp(
                        "BUG: packet without IPV6_PKTINFO or IPV6_HOPLIMIT"));