Thread (7 messages) 7 messages, 5 authors, 2009-06-02

Re: [PATCH] Multicast socket option

From: Neil Horman <nhorman@tuxdriver.com>
Date: 2009-05-29 10:36:08

On Thu, May 28, 2009 at 10:00:46AM -0700, Nivedita Singhvi wrote:
quoted hunk ↗ jump to hunk
After some discussion offline with Christoph Lameter and David Stevens  
regarding multicast behaviour in Linux, I'm submitting a slightly
modified patch from the one Christoph submitted earlier.

This patch provides a new socket option IP_MULTICAST_ALL.

In this case, default behaviour is _unchanged_ from the current
Linux standard. The socket option is set by default to provide original 
behaviour. Sockets wishing to receive data only from multicast groups 
they join explicitly will need to clear this socket option. 


Signed-off-by: Nivedita Singhvi <redacted>
Signed-off-by: Christoph Lameter<redacted>
Acked-by: David Stevens <redacted>


diff -urN linux-2.6.29.2/include/linux/in.h linux-2.6.29.2.new/include/linux/in.h
--- linux-2.6.29.2/include/linux/in.h	2009-04-27 13:37:11.000000000 -0400
+++ linux-2.6.29.2.new/include/linux/in.h	2009-05-18 16:22:06.000000000 -0400
@@ -107,6 +107,7 @@
#define MCAST_JOIN_SOURCE_GROUP		46
#define MCAST_LEAVE_SOURCE_GROUP	47
#define MCAST_MSFILTER			48
+#define IP_MULTICAST_ALL		49

#define MCAST_EXCLUDE	0
#define MCAST_INCLUDE	1
diff -urN linux-2.6.29.2/include/net/inet_sock.h linux-2.6.29.2.new/include/net/inet_sock.h
--- linux-2.6.29.2/include/net/inet_sock.h	2009-04-27 13:37:11.000000000 -0400
+++ linux-2.6.29.2.new/include/net/inet_sock.h	2009-05-18 16:22:06.000000000 -0400
@@ -130,7 +130,8 @@
				freebind:1,
				hdrincl:1,
				mc_loop:1,
-				transparent:1;
+				transparent:1,
+				mc_all:1;
	int			mc_index;
	__be32			mc_addr;
	struct ip_mc_socklist	*mc_list;
diff -urN linux-2.6.29.2/net/ipv4/af_inet.c linux-2.6.29.2.new/net/ipv4/af_inet.c
--- linux-2.6.29.2/net/ipv4/af_inet.c	2009-04-27 13:37:11.000000000 -0400
+++ linux-2.6.29.2.new/net/ipv4/af_inet.c	2009-05-18 16:22:06.000000000 -0400
@@ -376,6 +376,7 @@
	inet->uc_ttl	= -1;
	inet->mc_loop	= 1;
	inet->mc_ttl	= 1;
+	inet->mc_all	= 1;
	inet->mc_index	= 0;
	inet->mc_list	= NULL;

diff -urN linux-2.6.29.2/net/ipv4/igmp.c linux-2.6.29.2.new/net/ipv4/igmp.c
--- linux-2.6.29.2/net/ipv4/igmp.c	2009-04-27 13:37:11.000000000 -0400
+++ linux-2.6.29.2.new/net/ipv4/igmp.c	2009-05-18 16:22:33.000000000 -0400
@@ -2196,7 +2196,7 @@
			break;
	}
	if (!pmc)
-		return 1;
+		return inet->mc_all;
This change also filters out broadcasts sent to sockets listening on a given
port.  Is that what you want?

Neil
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help