Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Sep 2003 08:21:26 -0700
From:      Jerry Toung <jtoung@arc.nasa.gov>
To:        "Giovanni P. Tirloni" <gpt@tirloni.org>, freebsd-hackers@freebsd.org
Subject:   Re: mbuf doubts
Message-ID:  <200309240821.26331.jtoung@arc.nasa.gov>
In-Reply-To: <20030924021219.GV34641@pixies.tirloni.org>
References:  <20030924021219.GV34641@pixies.tirloni.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Giovani,

you will find the answer to your question in "tcp/ip illustrated, volume =
2:=20
the implementation" in chapter 2.

But to briefly answer your question, yes, there are 4 different types of=20
mbufs, depending on the m_flags value.
1) m_flags =3D 0 and mbuf contains only data up to 108 bytes.
2) m_flags =3D M_PKTHDR to designate a packet header.
3)m_flags =3D M_EXT. In a situation where a user process write() in a buf=
fer >=20
256 bytes, the system allocates a cluster to hold that data.
4) m_flags =3D M_EXT|M_PKTHDR

and yes when  using clusters, the memory in the mbuf is unsed.

hop that  helped.

Jerry

On Tuesday 23 September 2003 07:12 pm, Giovanni P. Tirloni wrote:
> Hi,
>
>  I have been reading the D&I chapter about IPC, specially the mbuf
>  section and *many* doubts were raised by my mind. I sending them here
>  in the hope that someone can clarify some bits for me so I can proceed=
=2E
>
>  Reading sys/param.h and sys/mbuf.h I came to the conclusion that there
>  are four types of mbufs regarding it's allocation of memory for data.
>  Is the listing below correct?
>
>  struct mbuf *m;
>
>   1. Normal mbuf using m->M_databuf
>   2. Normal mbuf with external storage (cluster?) in m->m_hdr->mh_data
>   3. Header mbuf using m->m_pktdat;
>   4. Header mbuf with ext. storage (cluster?) in m->m_ext->ext_buf
>
>  Other questions:
>
>   1. When using ext. storage is the space allocated by M_databuf wasted=
?
>
>   2. How the system decides 256 bytes for each mbuf isn't enough and it
>      needs a mbuf cluster? Isn't chaining useful there?
>
>   3. How does changing MSIZE affects the whole thing?
>
>   4. What about MCLBYTES?
>
>  Sorry to make so many questions at once but I find it very interesting
>  and I'm really willing to learn how the building blocks of the network
>  stack work. Perhaps my questions are out of reality.. it's risk.
>
>  Thanks,
>
>  --
>  Giovanni P. Tirloni <gpt at tirloni.org>
>  Fingerprint: 8C3F BEC5 79BD 3E9B EDB8  72F4 16E8 BA5E D031 5C26



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200309240821.26331.jtoung>