Hi everyone, I am working on a program that requires putting the node in all-multicast mode. The program needs to see all the packets going to solicited-node multicast addresses. I did this by modifying the interface flags to add IFF_ALLMULTI.
Unfortunately recvmsg() was only returning for the packets destined for multicast groups I had explicitly joined and not all of them. After this change, I can see the packets as expected. A similar change will probably be required for the ip4 variant of this function. I also noticed that for this to work, IFF_PROMISC needs to be set as well. Shouldn't it be possible to have IFF_MULTI without IFF_PROMISC? I am using the em(4) driver and I can see the following code in there: ifp->if_flags &= ~IFF_ALLMULTI; if (ifp->if_flags & IFF_PROMISC || ac->ac_multirangecnt > 0 || ac->ac_multicnt > MAX_NUM_MULTICAST_ADDRESSES) { ifp->if_flags |= IFF_ALLMULTI; reg_rctl |= E1000_RCTL_MPE; if (ifp->if_flags & IFF_PROMISC) reg_rctl |= E1000_RCTL_UPE; } else { ETHER_FIRST_MULTI(step, ac, enm); while (enm != NULL) { bcopy(enm->enm_addrlo, mta + i, ETH_LENGTH_OF_ADDRESS); i += ETH_LENGTH_OF_ADDRESS; ETHER_NEXT_MULTI(step, enm); } em_mc_addr_list_update(&sc->hw, mta, ac->ac_multicnt, 0, 1); } I am not sure how to control ac->ac_multirangecnt from userspace or if this behaviour is intended in the first place. diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 8b9ff6d..5630fb9 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1342,6 +1342,9 @@ in6_hasmulti(struct in6_addr *maddr6, struct ifnet *ifp) struct in6_multi *in6m; int joined; + if ((ifp->if_flags & IFF_ALLMULTI) != 0) + return 1; + IN6_LOOKUP_MULTI(*maddr6, ifp, in6m); joined = (in6m != NULL);