mbuf doubts

Giovanni P. Tirloni gpt at tirloni.org
Tue Sep 23 19:12:24 PDT 2003


 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.


 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