From rmanches@brown.edu  Thu May 23 16:42:22 2002
Return-Path: <rmanches@brown.edu>
Received: from cable2-228.fctvplus.net (cable2-228.fctvplus.net [63.85.56.228])
	by hub.freebsd.org (Postfix) with ESMTP id E4EE637B40A
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 23 May 2002 16:42:21 -0700 (PDT)
Received: from lester.manchero.org (localhost [127.0.0.1])
	by cable2-228.fctvplus.net (8.12.3/8.12.3) with ESMTP id g4NKdRt3005573
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 23 May 2002 16:39:27 -0400 (EDT)
	(envelope-from rmanches@lester.manchero.org)
Received: (from rmanches@localhost)
	by lester.manchero.org (8.12.3/8.12.3/Submit) id g4NKdRLM005572;
	Thu, 23 May 2002 16:39:27 -0400 (EDT)
Message-Id: <200205232039.g4NKdRLM005572@lester.manchero.org>
Date: Thu, 23 May 2002 16:39:27 -0400 (EDT)
From: Rob Manchester <rmanches@brown.edu>
Reply-To: Rob Manchester <rmanches@brown.edu>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: src address in ipv4 hdr for multicast packets contain hosts group rather than hosts address
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         38473
>Category:       kern
>Synopsis:       src address in ipv4 hdr for multicast packets contain hosts group rather than hosts address
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 23 16:50:01 PDT 2002
>Closed-Date:    Fri Jul 19 01:28:43 PDT 2002
>Last-Modified:  Fri Jul 19 01:28:43 PDT 2002
>Originator:     Rob Manchester
>Release:        FreeBSD 4.6-RC i386
>Organization:
>Environment:
System: FreeBSD lester 4.6-RC FreeBSD 4.6-RC #21: Sat May 18 17:02:34 EDT 2002 rmanches@lester:/usr/obj/usr/src/sys/LESTER i386


>Description:
	according to section 6.2 of rfc1054, the source address in the
	ip header should contain the host's address rather than the host's
	group address.  FreeBSD from at least 4.5->4.6rc sets the source
	address to the host group.  I don't see a reason for doing this,
	and it causes incompatibility with other os's ipv4 mc
	implementaion, mainly linux.

>How-To-Repeat:

	send out a mc packet using ipv4 and watch the outgoing packets
	using tcpdump.

>Fix:

if the src address is a multicast addres, set the address to that of the
outgoing interface.

Index: ip_output.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.157
diff -u -r1.157 ip_output.c
--- ip_output.c	2002/05/21 18:52:24	1.157
+++ ip_output.c	2002/05/23 01:31:09
@@ -316,10 +316,11 @@
 			}
 		}
 		/*
-		 * If source address not specified yet, use address
-		 * of outgoing interface.
+		 * If source address not specified yet, or it is a mc
+		 * address, use the address of outgoing interface
 		 */
-		if (ip->ip_src.s_addr == INADDR_ANY) {
+		if (ip->ip_src.s_addr == INADDR_ANY ||
+			IN_MULTICAST(ntohl(ip->ip_src.s_addr))) {
 			/* Interface may have no addresses. */
 			if (ia != NULL)
 				ip->ip_src = IA_SIN(ia)->sin_addr;
>Release-Note:
>Audit-Trail:

From: John Hay <jhay@icomtek.csir.co.za>
To: rmanches@brown.edu (Rob Manchester)
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: kern/38473: src address in ipv4 hdr for multicast packets contain hosts group rather than hosts address
Date: Fri, 24 May 2002 07:43:58 +0200 (SAT)

 > 
 > >Description:
 > 	according to section 6.2 of rfc1054, the source address in the
 > 	ip header should contain the host's address rather than the host's
 > 	group address.  FreeBSD from at least 4.5->4.6rc sets the source
 > 	address to the host group.  I don't see a reason for doing this,
 > 	and it causes incompatibility with other os's ipv4 mc
 > 	implementaion, mainly linux.
 > 
 > >How-To-Repeat:
 > 
 > 	send out a mc packet using ipv4 and watch the outgoing packets
 > 	using tcpdump.
 > 
 
 What application are you using? Are you sure it isn't broken? I have
 used ntp and various routing daemons and have never seen this behaviour.
 Your patch seems to catch the case where the app sets its source
 address to the multicast address. Just don't do that. :-)
 
 John
 -- 
 John Hay -- John.Hay@icomtek.csir.co.za / jhay@FreeBSD.org
State-Changed-From-To: open->closed 
State-Changed-By: jon 
State-Changed-When: Fri Jul 19 01:28:20 PDT 2002 
State-Changed-Why:  
we think your application is broken.  If that's not true, let me know and I can 
reopen the PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=38473 
>Unformatted:
