[Xorp-hackers] Multicast routing

Pavlin Radoslavov pavlin at icir.org
Thu Mar 1 11:04:43 PST 2007


> > > How does the XORP multicast router sniff IGMP/MLD messages from the
> > network?
> > >
> > > I checked the some routers' code. Most of them just open a RAW socket
> > with
> > > protocol set to IPPROTO_IGMP. But using this the router gets the
> > > packets addressed to 224.0.0.1 only.
> > >
> > > How does it receive IGMPv2 and IGMPv3 membership reports sent by other
> > hosts?
> >
> > The kernel gets all multicast packets because the interface is set
> > in ALLMULTI mode (i.e., snoop all multicast packets). This happens
> > after the multicast routing socket has been opened with
> > setsockopt(..., MRT_INIT, ...) and then each interface is added with
> > setsockopt(..., MRT_ADD_VIF, ...).
> 
> 
> %Suresh : In FreeBSD, IGMP packets are handled in from ipintr() in
> ip_input.c where it directly goes to igmp_input() (igmp.c). From here, it
> puts packet to applications via rip_input call. So, I guess to receive IGMP
> packets we no need to setsockopt though IGMP ( XORP,etc) adds to VIF; thats
> to enable Mrouting on that interface. Not particularly to receive IGMP
> control packets. Please correct me if I'm wrong here.

You need MRT_ADD_VIF if you want to guarantee you will receive all
IGMP packets.

The IP stack will get a multicast packet (including the IGMP packets
that are always sent to a multicast destination) only if:

 (a) The host has explicitly joined the particular multicast group
 on the particular network interface.

OR

 (b) The network interface is in IFF_ALLMULTI mode (i.e., to snoop
 and pass all multicast packets to the IP stack).

Otherwise a multicast packet will be ignored by the network
interface and won't even reach ip_input().

Obviously, you cannot do (a) for each of the multicast groups in the
whole multicast address space.
Hence, to guarantee that you will get all IGMP packets you need to
do (b).
I believe the only API that allows the user to set the IFF_ALLMULTI
flag on an interface is by using setsockopt(MRT_ADD_VIF).
At least, this is the API that is guaranteed to work on all UNIX
systems that support multicast forwarding.

However, if you care only about the IGMP packets sent to a small
number of multicast groups, then you could explicitly join each of
those groups and you don't need setsockopt(MRT_ADD_VIF).

Regards,
Pavlin

> Then the userland program can receive the IGMP packets with opening
> > a raw IPPROTO_IGMP socket.
> >
> > BTW, note that there could be only one multicast routing socket open
> > at a time (across all processes).
> >
> > Regards,
> > Pavlin
> >
> >
> > _______________________________________________
> > Xorp-hackers mailing list
> > Xorp-hackers at icir.org
> > http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers
> >
> _______________________________________________
> Xorp-hackers mailing list
> Xorp-hackers at icir.org
> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers



More information about the Xorp-hackers mailing list