From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 24 08:22:05 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C749D16A4B3 for ; Wed, 24 Sep 2003 08:22:05 -0700 (PDT) Received: from pony1pub.arc.nasa.gov (pony1pub.arc.nasa.gov [128.102.31.41]) by mx1.FreeBSD.org (Postfix) with ESMTP id 107B944015 for ; Wed, 24 Sep 2003 08:22:01 -0700 (PDT) (envelope-from jtoung@arc.nasa.gov) Received: from nren-194.arc.nasa.gov ([128.102.196.194] verified) by pony1pub.arc.nasa.gov (CommuniGate Pro SMTP 4.1.3) with ESMTP id 3481345; Wed, 24 Sep 2003 08:22:00 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Jerry Toung To: "Giovanni P. Tirloni" , freebsd-hackers@freebsd.org Date: Wed, 24 Sep 2003 08:21:26 -0700 User-Agent: KMail/1.4.3 References: <20030924021219.GV34641@pixies.tirloni.org> In-Reply-To: <20030924021219.GV34641@pixies.tirloni.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200309240821.26331.jtoung@arc.nasa.gov> Subject: Re: mbuf doubts X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: jtoung@arc.nasa.gov List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Sep 2003 15:22:05 -0000 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 > Fingerprint: 8C3F BEC5 79BD 3E9B EDB8 72F4 16E8 BA5E D031 5C26