From owner-freebsd-net@FreeBSD.ORG Mon May 2 16:39:18 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 2107C16A4CF; Mon, 2 May 2005 16:39:18 +0000 (GMT) Received: from mailgate1b.savvis.net (mailgate1b.savvis.net [216.91.182.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 08F9543D1F; Mon, 2 May 2005 16:39:17 +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 21FC03BEB3; Mon, 2 May 2005 11:39:15 -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 13248-02-12; Mon, 2 May 2005 11:39:14 -0500 (CDT) Received: from out001.email.savvis.net (out001.apptix.savvis.net [216.91.32.44]) by mailgate1b.savvis.net (Postfix) with ESMTP id 6B0313BE6E; Mon, 2 May 2005 11:39:14 -0500 (CDT) Received: from s228130hz1ew171.apptix-01.savvis.net ([10.146.4.29]) by out001.email.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Mon, 2 May 2005 11:39:00 -0500 Received: from [10.254.186.111] ([66.35.239.94]) by s228130hz1ew171.apptix-01.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Mon, 2 May 2005 11:38:51 -0500 Message-ID: <42765799.6090201@savvis.net> Date: Mon, 02 May 2005 09:38:49 -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: net@freebsd.org 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: multipart/mixed; boundary="------------030203040704050801000304" X-OriginalArrivalTime: 02 May 2005 16:38:51.0276 (UTC) FILETIME=[6BF13CC0:01C54F35] X-Virus-Scanned: amavisd-new at savvis.net cc: Sten Spans cc: John-Mark Gurney cc: glebius@FreeBSD.org cc: Julian Elischer 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 16:39:18 -0000 This is a multi-part message in MIME format. --------------030203040704050801000304 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hello, >>>>>>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 >> >>please find and review the attached patch (untested) that implements >>option (3) above. any objections to the attached (revised) patch? can i commit it? thanks, max --------------030203040704050801000304 Content-Type: text/plain; name="m_uiotombuf.diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="m_uiotombuf.diff.txt" Index: sys/kern/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 --- sys/kern/uipc_mbuf.c 17 Mar 2005 19:34:57 -0000 1.147 +++ sys/kern/uipc_mbuf.c 2 May 2005 16:33:41 -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; Index: sys/kern/uipc_syscalls.c =================================================================== RCS file: /home/ncvs/src/sys/kern/uipc_syscalls.c,v retrieving revision 1.219 diff -u -r1.219 uipc_syscalls.c --- sys/kern/uipc_syscalls.c 16 Apr 2005 18:46:28 -0000 1.219 +++ sys/kern/uipc_syscalls.c 2 May 2005 16:33:41 -0000 @@ -1796,7 +1796,7 @@ hdr_uio->uio_td = td; hdr_uio->uio_rw = UIO_WRITE; if (hdr_uio->uio_resid > 0) { - m_header = m_uiotombuf(hdr_uio, M_DONTWAIT, 0); + m_header = m_uiotombuf(hdr_uio, M_DONTWAIT, 0, 0); if (m_header == NULL) goto done; headersize = m_header->m_pkthdr.len; Index: sys/net/if_tap.c =================================================================== RCS file: /home/ncvs/src/sys/net/if_tap.c,v retrieving revision 1.52 diff -u -r1.52 if_tap.c --- sys/net/if_tap.c 13 Apr 2005 00:30:19 -0000 1.52 +++ sys/net/if_tap.c 2 May 2005 16:33:41 -0000 @@ -827,7 +827,7 @@ return (EIO); } - if ((m = m_uiotombuf(uio, M_DONTWAIT, 0)) == NULL) { + if ((m = m_uiotombuf(uio, M_DONTWAIT, 0, ETHER_ALIGN)) == NULL) { ifp->if_ierrors ++; return (error); } Index: sys/net/if_tun.c =================================================================== RCS file: /home/ncvs/src/sys/net/if_tun.c,v retrieving revision 1.149 diff -u -r1.149 if_tun.c --- sys/net/if_tun.c 31 Mar 2005 12:19:44 -0000 1.149 +++ sys/net/if_tun.c 2 May 2005 16:33:41 -0000 @@ -761,7 +761,7 @@ return (EIO); } - if ((m = m_uiotombuf(uio, M_DONTWAIT, 0)) == NULL) { + if ((m = m_uiotombuf(uio, M_DONTWAIT, 0, 0)) == NULL) { ifp->if_ierrors++; return (error); } Index: sys/netgraph/ng_device.c =================================================================== RCS file: /home/ncvs/src/sys/netgraph/ng_device.c,v retrieving revision 1.20 diff -u -r1.20 ng_device.c --- sys/netgraph/ng_device.c 14 Mar 2005 16:02:53 -0000 1.20 +++ sys/netgraph/ng_device.c 2 May 2005 16:33:41 -0000 @@ -466,7 +466,7 @@ if (uio->uio_resid < 0 || uio->uio_resid > IP_MAXPACKET) return (EIO); - if ((m = m_uiotombuf(uio, M_DONTWAIT, 0)) == NULL) + if ((m = m_uiotombuf(uio, M_DONTWAIT, 0, 0)) == NULL) return (ENOBUFS); NG_SEND_DATA_ONLY(error, priv->hook, m); Index: sys/sys/mbuf.h =================================================================== RCS file: /home/ncvs/src/sys/sys/mbuf.h,v retrieving revision 1.169 diff -u -r1.169 mbuf.h --- sys/sys/mbuf.h 17 Mar 2005 19:34:57 -0000 1.169 +++ sys/sys/mbuf.h 2 May 2005 16:33:41 -0000 @@ -582,7 +582,7 @@ struct mbuf *m_pulldown(struct mbuf *, int, int, int *); struct mbuf *m_pullup(struct mbuf *, int); struct mbuf *m_split(struct mbuf *, int, int); -struct mbuf *m_uiotombuf(struct uio *, int, int); +struct mbuf *m_uiotombuf(struct uio *, int, int, int); /*- * Network packets may have annotations attached by affixing a list --------------030203040704050801000304--