Subject: IPv4 multicast transmission when there's no interface address
To: None <tech-net@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-net
Date: 01/08/2002 19:16:45
	when there's no IPv4 address assigned to the multicast outgoing
	interface (specified by setsockopt), kernel made panic.  i've committed
	the following change to avoid the kernel panic.  historic behavior
	was to use 0.0.0.0 as source.
	my question is, which behavior look better?  do any of you know
	apps that assumes "0.0.0.0 as source" behavior?

	reasoning for using 0.0.0.0 as source:
		"0.0.0.0 as source" is legal only while the interface is
		being initialized (RFC1122 p30), therefore, if there's some
		user program that uses multicast for interface initialization,
		they want the behavior.
	reasoning for forbidding packet transmission:
		IP source address must be one of the interface addresses that
		belong to outgoing interface (RFC1112 p6).  if there's none,
		we shouldn't send packet.

itojun




Index: ip_output.c
===================================================================
RCS file: /cvsroot/syssrc/sys/netinet/ip_output.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- ip_output.c	2001/11/21 06:28:08	1.90
+++ ip_output.c	2002/01/08 10:05:13	1.91
@@ -317,6 +317,10 @@
 			struct in_ifaddr *ia;
 
 			IFP_TO_IA(ifp, ia);
+			if (!ia) {
+				error = EADDRNOTAVAIL;
+				goto bad;
+			}
 			ip->ip_src = ia->ia_addr.sin_addr;
 		}