Date: Fri, 14 Jun 2002 09:50:06 -0700 (PDT) From: John Polstra <jdp@polstra.com> To: net@freebsd.org Cc: spe@selectbourse.net Subject: Re: Problem using ng_ether Message-ID: <200206141650.g5EGo6c12182@vashon.polstra.com> In-Reply-To: <20020614150130.56E86BAE9@sbserv0.intra.selectbourse.net> References: <20020614150130.56E86BAE9@sbserv0.intra.selectbourse.net>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <20020614150130.56E86BAE9@sbserv0.intra.selectbourse.net>, Sebastien Petit <spe@selectbourse.net> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206141650.g5EGo6c12182>