From owner-freebsd-net@FreeBSD.ORG Fri Apr 29 18:36:05 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 1B10816A4CE for ; Fri, 29 Apr 2005 18:36:05 +0000 (GMT) Received: from mailgate1b.savvis.net (mailgate1b.savvis.net [216.91.182.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 98D2643D58 for ; Fri, 29 Apr 2005 18:36:04 +0000 (GMT) (envelope-from Maksim.Yevmenkin@savvis.net) Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgate1b.savvis.net (Postfix) with ESMTP id 3AD403BEB0; Fri, 29 Apr 2005 13:36:04 -0500 (CDT) Received: from mailgate1b.savvis.net ([127.0.0.1]) by localhost (mailgate1b.savvis.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 13728-01-96; Fri, 29 Apr 2005 13:36:04 -0500 (CDT) Received: from out002.email.savvis.net (out002.apptix.savvis.net [216.91.32.45]) by mailgate1b.savvis.net (Postfix) with ESMTP id 019283BE66; Fri, 29 Apr 2005 13:36:04 -0500 (CDT) Received: from s228130hz1ew171.apptix-01.savvis.net ([10.146.4.29]) by out002.email.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Fri, 29 Apr 2005 13:35:52 -0500 Received: from [10.254.186.111] ([66.35.239.94]) by s228130hz1ew171.apptix-01.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Fri, 29 Apr 2005 13:35:26 -0500 Message-ID: <42727E6D.5020304@savvis.net> Date: Fri, 29 Apr 2005 11:35:25 -0700 From: Maksim Yevmenkin User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.2) Gecko/20040822 X-Accept-Language: en-us, en MIME-Version: 1.0 To: John-Mark Gurney References: <20050428135120.GB21428@cell.sick.ru> <427111BF.2050607@savvis.net> <42712BAA.4070201@elischer.org> <42715269.3010306@errno.com> <4272743A.2030003@savvis.net> <20050429182819.GP2670@funkthat.com> In-Reply-To: <20050429182819.GP2670@funkthat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 29 Apr 2005 18:35:26.0975 (UTC) FILETIME=[3676F0F0:01C54CEA] X-Virus-Scanned: amavisd-new at savvis.net cc: Sten Spans cc: net@freebsd.org cc: Julian Elischer cc: Sam Leffler 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 18:36:05 -0000 [...] >>>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. >> >>having these changes in the tree is a good thing, but it will require >>more testing. maybe for now we could get away with simpler changes? > > >>@@ -1342,12 +1342,15 @@ >> total = min(uio->uio_resid, len); >> else >> total = uio->uio_resid; >>+ if (align >= MHLEN) >>+ goto nospace; >> if (total > MHLEN) > > > Shouldn't this check be total + align > MHLEN? ops. yes it should, thanks for catching this! >> m_final = m_getcl(how, MT_DATA, M_PKTHDR); >> else >> m_final = m_gethdr(how, MT_DATA); >> if (m_final == NULL) >> goto nospace; >>+ m_adj(m_final, align); >> m_new = m_final; >> while (progress < total) { >> length = total - progress; also, there is probably no good reason to call m_adj, we could just "m_final->m_data += align" like so Index: uipc_mbuf.c =================================================================== RCS file: /home/ncvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.147 diff -u -r1.147 uipc_mbuf.c --- uipc_mbuf.c 17 Mar 2005 19:34:57 -0000 1.147 +++ uipc_mbuf.c 29 Apr 2005 18:31:51 -0000 @@ -1333,7 +1333,7 @@ #endif struct mbuf * -m_uiotombuf(struct uio *uio, int how, int len) +m_uiotombuf(struct uio *uio, int how, int len, int align) { struct mbuf *m_new = NULL, *m_final = NULL; int progress = 0, error = 0, length, total; @@ -1342,12 +1342,15 @@ total = min(uio->uio_resid, len); else total = uio->uio_resid; - if (total > MHLEN) + if (align >= MHLEN) + goto nospace; + if (total + align > MHLEN) m_final = m_getcl(how, MT_DATA, M_PKTHDR); else m_final = m_gethdr(how, MT_DATA); if (m_final == NULL) goto nospace; + m_final->m_data += align; m_new = m_final; while (progress < total) { length = total - progress; thanks, max