From owner-cvs-src@FreeBSD.ORG Tue Dec 12 14:01:00 2006 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CD8AA16A40F; Tue, 12 Dec 2006 14:01:00 +0000 (UTC) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8524F43D8D; Tue, 12 Dec 2006 13:56:50 +0000 (GMT) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.11/8.13.6) with ESMTP id kBCDvu4B061532; Tue, 12 Dec 2006 05:57:56 -0800 (PST) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.11/8.12.3/Submit) id kBCDvunV061531; Tue, 12 Dec 2006 05:57:56 -0800 (PST) (envelope-from rizzo) Date: Tue, 12 Dec 2006 05:57:56 -0800 From: Luigi Rizzo To: ticso@cicely.de Message-ID: <20061212055756.A61182@xorpc.icir.org> References: <200612081036.kB8AakMD029277@repoman.freebsd.org> <20061212131333.GU54209@cicely12.cicely.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20061212131333.GU54209@cicely12.cicely.de>; from ticso@cicely12.cicely.de on Tue, Dec 12, 2006 at 02:13:34PM +0100 Cc: cvs-src@FreeBSD.org, Luigi Rizzo , src-committers@FreeBSD.org, imp@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/net if_ethersubr.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 14:01:00 -0000 On Tue, Dec 12, 2006 at 02:13:34PM +0100, Bernd Walter wrote: > On Fri, Dec 08, 2006 at 10:36:46AM +0000, Luigi Rizzo wrote: > > luigi 2006-12-08 10:36:45 UTC > > > > FreeBSD src repository > > > > Modified files: > > sys/net if_ethersubr.c > > Log: > > Fix an oscure bug triggered by a recent change in kern_socket.c. > > The symptoms were that outgoing DHCP requests for diskless kernels > > had the IP header corrupt. After long investigations, the source of > > the problem was found in ether_output() - for SIMPLEX interfaces > > and broadcast traffic, a copy of the packet is passed back to the kernel > > through if_simloop(). However if_simloop() modifies the mbuf, while > > the copy obtained through m_copym() is a readonly one. > > > > The bug has been there forever, but it has been triggered only recently > > by a change in sosend_dgram() which passed down mbufs with sufficient > > space to prepend the header. > > > > This fix is trivial - use m_dup() instead of m_copy() to create > > the copy. As an alternative, we could try and modify if_simloop() > > to play safely with readonly mbufs, but i don't think it is worthwhile > > because 1) this is a relatively infrequent code path so we do not need > > to worry too much about performance, and 2) the cost of doing an > > extra m_pullup in if_simloop() is probably the same as doing the > > copy of the cluster, anyways. > > This change produces an alignment panic on arm. > Reverting it gets my system back to live. then i suppose the proper fix is to revert to m_copy() and work on if_simloop() so that 1. it handles a readonly chain, and 2. when doing so, it passes up a properly aligned packet... however note that there is already some code in net/if_loop.c::if_simloop(), just that it uses this: #if defined(__ia64__) || defined(__sparc64__) /* * Some archs do not like unaligned data, so * we move data down in the first mbuf. */ if (mtod(m, vm_offset_t) & 3) { KASSERT(hlen >= 3, ("if_simloop: hlen too small")); bcopy(m->m_data, (char *)(mtod(m, vm_offset_t) - (mtod(m, vm_offset_t) & 3)), m->m_len); m->m_data -= (mtod(m,vm_offset_t) & 3); } #endif to detect whether the architecture is alignment-sensitive. Is there any other identifier that we can use to check ? cheers luigi