Date: Thu, 19 Sep 2002 21:50:31 -0700 (PDT) From: Neelkanth Natu <neelnatu@yahoo.com> To: freebsd-net@freebsd.org Subject: clusters not used in /dev/tun ? Message-ID: <20020920045031.98699.qmail@web14208.mail.yahoo.com>
next in thread | raw e-mail | index | archive | help
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)
__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020920045031.98699.qmail>
