From kolya@orbit.zepa.net  Wed Aug 22 12:01:31 2001
Return-Path: <kolya@orbit.zepa.net>
Received: from orbit.zepa.net (orbit.zepa.net [205.245.53.14])
	by hub.freebsd.org (Postfix) with SMTP id BDB5837B413
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 22 Aug 2001 12:01:30 -0700 (PDT)
	(envelope-from kolya@orbit.zepa.net)
Received: (qmail 83109 invoked by uid 502); 22 Aug 2001 19:01:28 -0000
Message-Id: <20010822190128.83108.qmail@orbit.zepa.net>
Date: 22 Aug 2001 19:01:28 -0000
From: kolya@orbit.zepa.net
Reply-To: kolya@orbit.zepa.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: sent broadcast packets get spurious 4 byte prefix
X-Send-Pr-Version: 3.2

>Number:         29962
>Category:       kern
>Synopsis:       sent broadcast packets get spurious 4 byte prefix
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 22 12:10:01 PDT 2001
>Closed-Date:    Mon Oct 28 08:02:09 PST 2002
>Last-Modified:  Mon Oct 28 08:02:09 PST 2002
>Originator:     Nickolai Zeldovich
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
>Environment:

	Bug observed both with fxp and wx interfaces on an i386 machine
	running 4.3-RELEASE.

>Description:

	Sending a broadcast packet on an ethernet interface while watching
	the traffic via bpf with tcpdump produces a spurious 4-byte prefix
	on the broadcast packet (as observed with tcpdump, not on the wire.)

>How-To-Repeat:

	ifconfig fxp0 1.0.0.1
	tcpdump -e -n -x -s 1600 -i fxp0 &
	ping -c 1 1.255.255.255

	As seen in the tcpdump output, an extra 4 bytes are prepended to
	the broadcast IP packet, containing the value 0x02000000.

>Fix:

	This simple patch fixes the problem; as far as I can tell, the
	comment is wrong, though I don't claim to be very familiar with
	this code.

--- if_loop.c.orig	Wed Aug 22 14:22:54 2001
+++ if_loop.c	Wed Aug 22 14:23:52 2001
@@ -223,22 +223,8 @@
 	}
 
 	/* Let BPF see incoming packet */
-	if (ifp->if_bpf) {
-		struct mbuf m0, *n = m;
-
-		/*
-		 * We need to prepend the address family as
-		 * a four byte field.  Cons up a dummy header
-		 * to pacify bpf.  This is safe because bpf
-		 * will only read from the mbuf (i.e., it won't
-		 * try to free it or keep a pointer a to it).
-		 */
-		m0.m_next = m;
-		m0.m_len = 4;
-		m0.m_data = (char *)&af;
-		n = &m0;
-		bpf_mtap(ifp, n);
-	}
+	if (ifp->if_bpf)
+		bpf_mtap(ifp, m);
 
 	/* Strip away media header */
 	if (hlen > 0) {
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: dd 
Responsible-Changed-When: Tue Aug 28 05:21:09 PDT 2001 
Responsible-Changed-Why:  
refile 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=29962 
State-Changed-From-To: open->closed 
State-Changed-By: maxim 
State-Changed-When: Mon Oct 28 08:01:04 PST 2002 
State-Changed-Why:  
Fixed in rev. 1.61 and rev. 1.47.2.5 src/sys/net/if_loop.c in 
-CURRENT and -STABLE. Thanks for the report. 

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