From owner-freebsd-net@FreeBSD.ORG Fri Apr 29 10:34:07 2005 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ADAEC16A4CE for ; Fri, 29 Apr 2005 10:34:06 +0000 (GMT) Received: from ford.blinkenlights.nl (ford.blinkenlights.nl [213.204.211.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id EF5A143D2F for ; Fri, 29 Apr 2005 10:34:05 +0000 (GMT) (envelope-from sten@blinkenlights.nl) Received: from tea.blinkenlights.nl (tea.blinkenlights.nl [192.168.1.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ford.blinkenlights.nl (Postfix) with ESMTP id EB8B33F294; Fri, 29 Apr 2005 12:34:03 +0200 (CEST) Received: by tea.blinkenlights.nl (Postfix, from userid 101) id 6EBA6272; Fri, 29 Apr 2005 11:40:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by tea.blinkenlights.nl (Postfix) with ESMTP id 5677C1DB; Fri, 29 Apr 2005 11:40:42 +0200 (CEST) Date: Fri, 29 Apr 2005 11:40:42 +0200 (CEST) From: Sten Spans To: Sam Leffler In-Reply-To: <42715269.3010306@errno.com> Message-ID: References: <20050428135120.GB21428@cell.sick.ru> <427111BF.2050607@savvis.net> <42712BAA.4070201@elischer.org> <42715269.3010306@errno.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed cc: Julian Elischer cc: net@freebsd.org Subject: Re: if_tap unaligned access problem X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Apr 2005 10:34:07 -0000 On Thu, 28 Apr 2005, Sam Leffler wrote: > Julian Elischer wrote: >> >> >> Maksim Yevmenkin wrote: >> >>> Hello, >>> >>>> A quick question about if_tap, the tapwrite function >>>> ( which copies an ethernet frame into an mbuf using uiotombuf ) >>>> is broken on alpha and sparc64. >>>> The 14 byte ethernet header causes the rest of the frame to >>>> be misaligned on 4 byte boundaries. This causes crashes in >>>> various other parts of the kernel. The solution would be to >>>> shift the mbuf by two bytes, but I am not quite sure where >>>> this should happen. >>> >>> >>> >>> i think we have few options here: >>> >>> 1) revert back original tapwrite function that was changed in v. 1.48 and >>> set offset to 2 bytes in top mbuf >>> >>> 2) change current version of tapwrite so it would m_prepend and m_pullup >>> mbuf after m_uiotombuf >>> >>> 3) change m_uiotombuf to accept one more parameter - mbuf offset at which >>> data should be copied. there are not that many users of m_uiotombuf >>> >>> /sys/kern/uipc_syscalls.c >>> /sys/net/if_tap.c >>> /sys/net/if_tun.c >>> /sys/netgraph/ng_device.c >> >> >> >> I think we should defien a MAC header that looks like: >> char dummy[2] >> char dest[6] >> char src[6] >> char type_len[2] >> and make ether net cards start writing 2 bytes into the buffer :-) > > The whole alignment thing is currently handled quite poorly. For example, > are frequently aligning to the front of a cluster for ethernet receives which > means that frames bridged to a non-802.3 device often have to prepend an mbuf > because there's not enough space for their larger header. We need to fix the > alignment on receive based on multiple considerations and not just ip > alignment. There's a similar can-of-worms on the tx side that's a bit more > involved. > > Dealing with rx-side alignment is getting high on my todo list but various > other problems keep cropping up. I could try to port the changes netbsd made using m_copyup and send you the resulting patchfile. IPv4 has already been serviced by John-Mark Gurney in perforce. Would that help getting this into the tree ? http://mail-index.netbsd.org/source-changes/2002/07/01/0001.html http://perforce.freebsd.org/fileDiffView.cgi?FSPC=//depot/user/jmg/arm/src/s ys/netinet/ip%5finput.c&REV=3&ACT=edit -- Sten Spans "There is a crack in everything, that's how the light gets in." Leonard Cohen - Anthem