mbuf doubts
Jerry Toung
jtoung at arc.nasa.gov
Wed Sep 24 08:22:05 PDT 2003
Giovani,
you will find the answer to your question in "tcp/ip illustrated, volume 2:
the implementation" in chapter 2.
But to briefly answer your question, yes, there are 4 different types of
mbufs, depending on the m_flags value.
1) m_flags = 0 and mbuf contains only data up to 108 bytes.
2) m_flags = M_PKTHDR to designate a packet header.
3)m_flags = M_EXT. In a situation where a user process write() in a buffer >
256 bytes, the system allocates a cluster to hold that data.
4) m_flags = 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.
>
> 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
More information about the freebsd-hackers
mailing list