NetBSD Problem Report #18032

Received: (qmail 24595 invoked by uid 605); 22 Aug 2002 02:46:58 -0000
Message-Id: <20020822024656.24585.qmail@mail.netbsd.org>
Date: 22 Aug 2002 02:46:56 -0000
From: billc@netbsd.org
Sender: gnats-bugs-owner@netbsd.org
Reply-To: billc@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: hardware checksum broke in (some?) ex
X-Send-Pr-Version: 3.95

>Number:         18032
>Category:       kern
>Synopsis:       hw csum causes cksum errors on ex controllers
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 22 02:47:01 +0000 2002
>Closed-Date:    Sat Nov 25 14:38:05 +0000 2006
>Last-Modified:  Sat Nov 25 14:38:05 +0000 2006
>Originator:     William Coldwell
>Release:        NetBSD-1.6_BETA4
>Organization:
>Environment:
Architecture: i386
Machine: i386

>Description:
	When tracking down another issue, I noticed an usual amount
	of "bad [tcp] cksum" in the output of tcpdump -vvv.  Since
	I have a variety of 3Com ex cards in both i386 and alpha
	machines, I was able to attribute it to the cards, and then
	to the hardware csum by turning it off and on and monitoring
	the number.  When hw csum is turned off, there are virtually
	no errors.  With it on, there are lots... especially on a
	network loaded machine.

>How-To-Repeat:
	On a machine with an ex card (3c450-TX, 3c905C-TX tested)
	In one window, tcpdump -vvv | grep "bad ".
	Watch for errors.
	ifconfig ex0 -udp4csum -ip4csum -tcp4csum
	Watch the errors go away
	ifconfig ex0 udp4csum ip4csum tcp4csum
	Watch the errors come back.

>Fix:
>Release-Note:
>Audit-Trail:

From: enami tsugutomo <enami@sm.sony.co.jp>
To: billc@netbsd.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/18032: hardware checksum broke in (some?) ex
Date: 22 Aug 2002 12:05:32 +0900

 billc@netbsd.org writes:

 > On a machine with an ex card (3c450-TX, 3c905C-TX tested)
 > In one window, tcpdump -vvv | grep "bad ".
 > Watch for errors.

 Are you sure you aren't watching outgoing packet?

 enami.

From: "William J. Coldwell" <billc@NetBSD.org>
To: enami tsugutomo <enami@sm.sony.co.jp>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/18032: hardware checksum broke in (some?) ex
Date: Thu, 22 Aug 2002 01:17:06 -0400

 enami tsugutomo wrote:
 > billc@netbsd.org writes:
 > 
 > 
 >>On a machine with an ex card (3c450-TX, 3c905C-TX tested)
 >>In one window, tcpdump -vvv | grep "bad ".
 >>Watch for errors.
 > 
 > 
 > Are you sure you aren't watching outgoing packet?
 > 
 > enami.
 > 

 Yes, this is on outbound packets.  The destination doesn't seem to
 matter.  It seems quite unusual if this is expected behavior, but
 there was absolutely no documentation I could find on *4csum to
 explain this.  I was looking for an NFS problem when I encountered
 these "bad * cksum" packets.  It makes sense if tcpdump isn't reading
 what is going to the wire, even though the device is in promiscious
 mode... that would really make tcpdump only really useful for detecting
 incoming errors.  I conceed that this is probably an artifact of the
 outbound hardware checksum, but it should at least have a blurb, and
 that my understanding of where tcpdump is in the stack is probably
 flawed.






From: enami tsugutomo <enami@sm.sony.co.jp>
To: "William J. Coldwell" <billc@NetBSD.org>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/18032: hardware checksum broke in (some?) ex
Date: 29 Aug 2002 15:00:45 +0900

 "William J. Coldwell" <billc@NetBSD.org> writes:

 > these "bad * cksum" packets.  It makes sense if tcpdump isn't reading
 > what is going to the wire, even though the device is in promiscious
 > mode.

 Since the outbound packet will be tapped before it is passed to the
 hardware who is responsible to calculate the checksum.

 Alternatively we could do it by software when there is any bpf
 listener.  This kills tx checksum offload but it might make sense if
 an application which uses bpf strictly checks the captured packet.

 Attached patch would not be sufficient if vlan is used and user
 directly capture the packet from hardware interface.

 enami.

 Index: ip_output.c
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/netinet/ip_output.c,v
 retrieving revision 1.100
 diff -u -r1.100 ip_output.c
 --- ip_output.c	2002/08/14 00:23:32	1.100
 +++ ip_output.c	2002/08/29 05:50:58
 @@ -107,6 +107,7 @@
  #include "opt_pfil_hooks.h"
  #include "opt_ipsec.h"
  #include "opt_mrouting.h"
 +#include "bpfilter.h"

  #include <sys/param.h>
  #include <sys/malloc.h>
 @@ -612,7 +613,11 @@
  		ip->ip_sum = 0;
  		m->m_pkthdr.csum_flags |= M_CSUM_IPv4;

 -		sw_csum = m->m_pkthdr.csum_flags & ~ifp->if_csum_flags_tx;
 +		sw_csum = m->m_pkthdr.csum_flags;
 +#if NBPFILTER > 0
 +		if (ifp->if_bpf == 0)
 +#endif
 +			sw_csum &= ~ifp->if_csum_flags_tx;

  		/*
  		 * Perform any checksums that the hardware can't do
State-Changed-From-To: open->closed
State-Changed-By: tsutsui@netbsd.org
State-Changed-When: Sat, 25 Nov 2006 23:38:05 +0900
State-Changed-Why:
This is not a driver bug. Outgoing cksum is not filled when packets are
passed to bpf(4) if hwcksum is enabled. If you want to fix upper layers,
please file another PR.


>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.