From owner-freebsd-net Fri Jun 14 9:50:18 2002 Delivered-To: freebsd-net@freebsd.org Received: from wall.polstra.com (wall-gw.polstra.com [206.213.73.130]) by hub.freebsd.org (Postfix) with ESMTP id 22A1037B431 for ; Fri, 14 Jun 2002 09:50:14 -0700 (PDT) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.11.3/8.11.3) with ESMTP id g5EGo7f49085; Fri, 14 Jun 2002 09:50:07 -0700 (PDT) (envelope-from jdp@wall.polstra.com) Received: (from jdp@localhost) by vashon.polstra.com (8.11.6/8.11.0) id g5EGo6c12182; Fri, 14 Jun 2002 09:50:06 -0700 (PDT) (envelope-from jdp) Date: Fri, 14 Jun 2002 09:50:06 -0700 (PDT) Message-Id: <200206141650.g5EGo6c12182@vashon.polstra.com> To: net@freebsd.org From: John Polstra Cc: spe@selectbourse.net Subject: Re: Problem using ng_ether In-Reply-To: <20020614150130.56E86BAE9@sbserv0.intra.selectbourse.net> References: <20020614150130.56E86BAE9@sbserv0.intra.selectbourse.net> Organization: Polstra & Co., Seattle, WA Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org In article <20020614150130.56E86BAE9@sbserv0.intra.selectbourse.net>, Sebastien Petit wrote: > > I've a problem with ng_ether and xl0 driver, when I connect upper <-> lower > directly, packets have ip sum to 0 and a wrong tcp and udp cksum. I try to > use my test code on rl0 driver, and it work fine. > Julian or Archie, can you say me if I must recompute ip/tcp/udp checksum for > all packets read on upper and then writed on lower hook ? I'm not Julian or Archie, but I think I know what the problem is. The xl interface supports hardware checksum offloading, while the rl interface does not. When checksum offloading is used, the NIC itself checks the checksums of received packets, and calculates the checksums of transmitted packets. When transmitting packets the TCP/IP/UDP stacks set flags in the mbuf headers which tell the interface to calculate the checksums itself, if the interface has reported that it is capable of that. In that case, the TCP/IP/UDP layers don't bother to calculate the checksums in software. If you pass the mbufs directly from the upper hook to the lower hook inside the kernel, the relevant mbuf flags are preserved, and it all works as one would hope. But since you're doing the forwarding between hooks at the application layer, the mbuf flags are lost. The TCP/IP/UDP stacks assume the NIC will calculate the checksums of transmitted packets (because it said it could). But the flags telling the NIC to do so are lost. You can confirm this if you wish, by hacking up the xl driver to disable hardware checksumming. Search for "CSUM" in sys/pci/if_xl.c and #ifdef out the appropriate pieces of code. John -- John Polstra John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message