NetBSD Problem Report #1693

From gnats  Wed Oct 25 12:37:19 1995
Received: from imag.imag.fr by pain.lcs.mit.edu (8.6.9/8.6.9) with ESMTP id MAA25213 for <gnats-bugs@gnats.netbsd.org>; Wed, 25 Oct 1995 12:27:39 -0400
Message-Id: <199510251429.PAA16078@ganesha.imag.fr>
Date: Wed, 25 Oct 1995 15:29:16 +0100
From: Jean-Luc.Richier@imag.fr
Reply-To: Jean-Luc.Richier@imag.fr
To: gnats-bugs@gnats.netbsd.org
Subject: bug in if_loop.c
X-Send-Pr-Version: 3.95

>Number:         1693
>Category:       kern
>Synopsis:       tcpdump shows abnormal packets
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 25 12:50:01 +0000 1995
>Closed-Date:    Fri Mar 21 16:55:22 +0000 1997
>Last-Modified:  Fri Mar 21 17:00:26 +0000 1997
>Originator:     Jean-Luc Richier
>Release:        NetBSD-current source: octobre 11
>Organization:
IMAG
>Environment:
sun netbsd-1.0A current, sparc, 2 ethernet interfaces
System: NetBSD ganesha.imag.fr 1.0A NetBSD 1.0A (GANESHAv6) #2: Thu Oct 12 09:18:43 MET 1995 richier@ganesha.imag.fr:/usr/src/sys/arch/sparc/compile/GANESHAv6 sparc


>Description:

The problem :
I have a NetBSD machine with 2 interfaces and the gated daemon.

Using tcpdump on an ethernet interface le0, the output shows abnormal packets,
with curious ethernet addresses and type.
The analysis shows that:
- an incorrect packet is received each time a RIP broadcast packet is sent;
- the content of the incorrect packet is the content of the RIP packet,
  shifted by 10 bytes.

The cause is as follows :
- the RIP packet, broadcasted, is sent down to the ethernet leoutput routine
- leouput detects that the interface is opened by bpf and sends a (correct) copy
  of the message to the bpf filter and to tcpdump
- leoutput detects that the packet is a broadcast, and, as le0 is a SIMPLEX
  interface, sends a copy of the packet to the machine via looutput
- leoutput is called with ifp=interface_le0. It detects that the interface
  is in bpf mode, and therefore sends a copy of the packet to bpf and tcpdump
Therefore the packet is passed twice to bpf.
But there is another problem with the second copy: it is passed with a
DLT_NULL(4 bytes header). Tcpdump receives it and believes that it comes from
the opened interface le0, and therefore has a DLT_10M (14 bytes) header.
Therefore tcpdump is unable to interpret the packet.

>How-To-Repeat:
see above
>Fix:

CORRECTION:
The second copy made by looutput is incorrect; looutput should call bpf only
for packets sent directly through the lo0 interface.
The suggested patch is as follow:

*** /usr/src/sys/net/if_loop.c.PB	Tue Aug 15 17:32:30 1995
--- /usr/src/sys/net/if_loop.c	Thu Oct 12 09:18:11 1995
***************
*** 126,132 ****
  		panic("looutput: no header mbuf");
  	ifp->if_lastchange = time;
  #if NBPFILTER > 0
! 	if (ifp->if_bpf) {
  		/*
  		 * We need to prepend the address family as
  		 * a four byte field.  Cons up a dummy header
--- 126,133 ----
  		panic("looutput: no header mbuf");
  	ifp->if_lastchange = time;
  #if NBPFILTER > 0
! 		/* bpf test only on lo interface, not for SIMPLEX interfaces */
! 	if (ifp->if_bpf && (ifp->if_flags&IFF_LOOPBACK)) {
  		/*
  		 * We need to prepend the address family as
  		 * a four byte field.  Cons up a dummy header
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: is 
State-Changed-When: Thu Mar 20 06:12:15 PST 1997 
State-Changed-Why:  
* This is the same problem as #1313 and #2973, explained further in #2973. 

* If bpf should "see" broadcast packets from a SIMPLEX interface, some 
of #2973's suggestions should be implemented.  
If, however, this doesnt make much sense, then the suggestion in this 
PR is correct, and furthermore it is more robust with respect to possible 
future PF additions. 
- Ignatios Souvatzis 
State-Changed-From-To: analyzed->closed 
State-Changed-By: mycroft 
State-Changed-When: Fri Mar 21 08:55:22 PST 1997 
State-Changed-Why:  
Patch applied. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.