Subject: Re: kern/23221: setsockopt IP_ADD_MEMBERSHIP arguments not honored
To: Jun-ichiro itojun Hagino <>
From: William A.Carrel <>
List: tech-net
Date: 10/23/2003 22:37:04
On Thursday, October 23, 2003, at 10:02 PM, Jun-ichiro itojun Hagino 

>> I'm posting here to try and drive some action to a PR I have filed
>> regarding the handling of IPv4 multicast traffic in BSD4.4-Lite based
>> operating systems.
>> There is an error in handling incoming packets in udp4_realinput()
>> (src/sys/netinet/udp_usrreq.c at line 582).  Inbound multicast packets
>> on any interface listening to a given multicast address are passed to
>> every socket listening to that address.  This behavior is inconsistent
>> with the documentation in ip(4)s manpage and with the description 
>> given
>> in UNP Vol. 1 (Stevens) at page 496.
> 	the current behavior is the same as traditional 4.4BSD behavior.

Indeed it is.  As I pointed out, this is a long standing bug.

The behavior is contrary to the documentation for setsockopt and also 
contrary to common sense.  Contrary to common sense in that, adding 
memberships to other sockets (in other processes) should not to be able 
to cause a multicast socket to receive packets it didn't ask to 
receive.  The ability to side-effect multicast reception should be 

The patch provided should have no impact on existing multicast 
programs.  The only programs affected by the change to the current 
behavior are ones that assume some other process or socket is going to 
add memberships on other interfaces for them.  According to the 
relevant documentation this has never been a valid assumption, and as 
far as I know there aren't any programs that actually do this.  
Although writing one is pretty easy.

As the man page says, "Membership is associated with a single 
interface; ..."  The relevant code needs to be fixed so this actually 
holds true.