From owner-freebsd-net@FreeBSD.ORG Tue Nov 23 15:41:32 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C6B0106566C for ; Tue, 23 Nov 2010 15:41:32 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 4FD148FC12 for ; Tue, 23 Nov 2010 15:41:32 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 26622730A4; Tue, 23 Nov 2010 16:38:24 +0100 (CET) Date: Tue, 23 Nov 2010 16:38:24 +0100 From: Luigi Rizzo To: Adrian Chadd Message-ID: <20101123153824.GB48018@onelab2.iet.unipi.it> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: FreeBSD Net Subject: Re: ipfw and bridge: unaligned payload pointers panicing perfectly performing MIPS boxes X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Nov 2010 15:41:32 -0000 On Tue, Nov 23, 2010 at 02:30:56PM +0800, Adrian Chadd wrote: > Hi everyone (and Luigi especially!) > > I've found that enabling ipfw for bridge interfaces panics my MIPS > boards. A bit of digging shows that the payload mbuf isn't aligned as > passed into ipfw_chk(), and this is causing aligned access exceptions. > > It likely isn't a problem on i386/ia64 because they are happy with > unaligned access. :-) > > I'm going to try and patch it locally by copying the mbuf payload into > a new, temporary mbuf that's aligned; but I have no idea what the > "right" solution for the stack is. > > Ideas? :) the copy (especially if you make it conditional on #if NEED_ALIGNED and possibly on actual alignment) sounds good enough and it probably limits the number of changes to code. The drawback is that you might need to copy a lot of stuff unnecessarily. The other option would be to replace all the initial assignments to the copies of the header fields with macros, which then translate into assignments or bcopy depending on the circumstances. I'd go for the former, unless you are really concerned about performance. cheers luigi