Subject: MINCLSIZE one byte to small?
To: None <current-users@NetBSD.ORG>
From: Thorsten Frueauf <>
List: current-users
Date: 05/25/1997 14:49:39

As I try to understand the implementation for TCP/IP, I am currently reading
"TCP/IP Illustrated, Volume 2" - a really good book I must admit :)

Trying to understand the memory buffers, I found that little note on page

"We would expect the minimum value of m_len to be 209 for this type of mbuf,
not 208 as we indicate in the figure. That is, a record with 208 bytes of
data can be stored in two mbufs, with 100 bytes in the first and 108 in the
second. The source code, however, has a bug and allocates a cluster if the
size is greater or equal to 208."

So I was curios if NetBSD has this "bug" too (the book refers to 4.4BSDlite),
and I found in /src/sys/sys/mbuf.h:

#define MINCLSIZE       (MHLEN + MLEN)  /* smallest amount to put in cluster */

and in /src/sys/kern/uipc_mbuf.c:

                if (len >= MINCLSIZE) {
                        MCLGET(m, M_DONTWAIT);
                        if ((m->m_flags & M_EXT) == 0) {
                                return (0);
                        m->m_len = len = min(len, MCLBYTES);
                } else {
                         * Place initial small packet/header at end of mbuf.

So as MHLEN is the max ammount of data in mbuf with packet header and
MLEN is the max amount of data in normal mbuf - shouldn't MINCLSIZE be
defined as (MHLEN + MLEN +1)?

Dunno if this would be a real win, and dunno if my understanding is right
here, but I would like to hear what the gurus say to this :-)

Thanx for any comment in advance!