From owner-freebsd-net@FreeBSD.ORG Mon May 2 23:35:41 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 B8DB416A4CE; Mon, 2 May 2005 23:35:41 +0000 (GMT) Received: from ford.blinkenlights.nl (ford.blinkenlights.nl [213.204.211.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2DE0C43D5E; Mon, 2 May 2005 23:35:41 +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 00E1B3F294; Tue, 3 May 2005 01:35:39 +0200 (CEST) Received: by tea.blinkenlights.nl (Postfix, from userid 101) id 8EFEE272; Tue, 3 May 2005 01:35:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by tea.blinkenlights.nl (Postfix) with ESMTP id 6DE9979; Tue, 3 May 2005 01:35:39 +0200 (CEST) Date: Tue, 3 May 2005 01:35:39 +0200 (CEST) From: Sten Spans To: Mike Silbersack In-Reply-To: <20050502180353.T787@odysseus.silby.com> Message-ID: References: <20050428135120.GB21428@cell.sick.ru> <427111BF.2050607@savvis.net><20050502180353.T787@odysseus.silby.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed cc: harti@FreeBSD.org cc: Gleb Smirnoff cc: net@FreeBSD.org cc: jmg@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: Mon, 02 May 2005 23:35:41 -0000 On Mon, 2 May 2005, Mike Silbersack wrote: > > On Thu, 28 Apr 2005, Bruce M Simpson wrote: > >> jmg's suggestion of bringing in the NetBSD patches to allow the entire >> network stack to be compiled with unaligned accesses (for those platforms >> which support it) is interesting because it can simplify or eliminate >> some of the acrobatics needed in network drivers to deal with the mbuf >> alignment. > > I'm too lazy to benchmark, but I suspect that having the ethernet code shift > the packet backwards by two bytes after it strips off the ethernet header is > going to be faster than requiring ip_input to allocate a new mbuf for each > received packet. > > Such a change would also ensure that we don't break all the other protocols > that jmg didn't touch in his patch. For the if_tap case fixing the driver ( or rather changing m_uiotombuf ) is definately the correct solution. No sensible person would say otherwise. Once the if_tap change is properly tested and signed off it should make it into the tree. But on the proposed alignment changes: If you would look at the netbsd url ( http://mail-index.netbsd.org/source-changes/2002/07/01/0001.html ) You would see that: 1- This code only triggers for strict alignment architectures No inpact for i386 and amd64. 2- This code only triggers when the protocol header is unaligned. If the l2 driver is ok then this code won't be triggered. 3- Only the link headers are aligned, not the entire mbuf(chain). This should limit the performance impact quite a bit. It might even alow us to eliminate quite a bit of ugly mbuf juggling in certain drivers. http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/netinet/ip_input.c.diff?r1=1.153&r2=1.154&f=h ( Or the comments are incorrect, and I need to do more code reading :) To summarize: These changes will stop kernel crashes on alpha and sparc for drivers which are currently broken. All the drivers which currently work will not trigger this code. I haven't looked at every drivers but this change looks quite a bit cleaner than most of the tricks pulled in ethernet drivers, especially when jumboframes are involved. Netbsd has had 3 years to test this code, it can't be all bad :) -- Sten Spans "There is a crack in everything, that's how the light gets in." Leonard Cohen - Anthem