Date: Sat, 21 Sep 2002 02:18:26 -0700 (PDT) From: Neelkanth Natu <neelnatu@yahoo.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/43154: tunwrite() does not allocate clusters for packet_size >= MINCLSIZE Message-ID: <200209210918.g8L9IQUi006829@www.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 43154
>Category: kern
>Synopsis: tunwrite() does not allocate clusters for packet_size >= MINCLSIZE
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Sep 21 02:20:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Neelkanth Natu
>Release: 4.7-RC
>Organization:
>Environment:
FreeBSD localhost.neel.com 4.7-RC FreeBSD 4.7-RC #2: Thu Sep 19 03:07:57 PDT 2002 neel@localhost.neel.com:/usr/obj/usr/src/sys/NEEL i386
>Description:
The copy of the email sent to freebsd-net describes the problem:
Hi,
I noticed that tunwrite() does not allocate a cluster, even if the size of the
packet is greater than or equal to MINCLSIZE. Rather it stores the packet
in a mbuf chain.
Is there any reason why this is so ? I thought that packets with
size >= MINCLSIZE are traditionally stored in clusters.
Can someone please take a look at the patch for -current below ?
thanks
Neel
--- /home/neel/if_tun.c.current Thu Sep 19 21:19:19 2002
+++ if_tun.c Thu Sep 19 21:32:05 2002
@@ -717,27 +717,32 @@
}
tlen = uio->uio_resid;
- /* get a header mbuf */
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
- return (ENOBUFS);
- mlen = MHLEN;
-
top = 0;
mp = ⊤
while (error == 0 && uio->uio_resid > 0) {
+ if (top == 0) {
+ MGETHDR(m, M_DONTWAIT, MT_DATA);
+ mlen = MHLEN;
+ } else {
+ MGET(m, M_DONTWAIT, MT_DATA);
+ mlen = MLEN;
+ }
+ if (m == 0) {
+ error = ENOBUFS;
+ break;
+ }
+ if (uio->uio_resid >= MINCLSIZE) {
+ MCLGET(m, M_DONTWAIT);
+ if (m->m_flags & M_EXT) {
+ mlen = MCLBYTES;
+ } else {
+ /* store the data in the mbuf itself */
+ }
+ }
m->m_len = min(mlen, uio->uio_resid);
error = uiomove(mtod (m, caddr_t), m->m_len, uio);
*mp = m;
mp = &m->m_next;
- if (uio->uio_resid > 0) {
- MGET (m, M_DONTWAIT, MT_DATA);
- if (m == 0) {
- error = ENOBUFS;
- break;
- }
- mlen = MLEN;
- }
}
if (error) {
if (top)
>How-To-Repeat:
>Fix:
See description for the patch to -current.
The diff is against if_tun.c version 1.107.
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209210918.g8L9IQUi006829>
