From owner-freebsd-hackers Fri Jan 18 19: 6:26 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from technokratis.com (modemcable099.144-201-24.mtl.mc.videotron.ca [24.201.144.99]) by hub.freebsd.org (Postfix) with ESMTP id 2C23D37B404 for ; Fri, 18 Jan 2002 19:06:11 -0800 (PST) Received: (from bmilekic@localhost) by technokratis.com (8.11.4/8.11.3) id g0J3A1W61912; Fri, 18 Jan 2002 22:10:01 -0500 (EST) (envelope-from bmilekic) Date: Fri, 18 Jan 2002 22:10:01 -0500 From: Bosko Milekic To: Skye Poier Cc: hackers@FreeBSD.ORG Subject: Re: mbuf chains Message-ID: <20020118221001.A61874@technokratis.com> References: <20020118164617.L99893@ffwd.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020118164617.L99893@ffwd.cx>; from skye@ffwd.cx on Fri, Jan 18, 2002 at 04:46:18PM -0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Jan 18, 2002 at 04:46:18PM -0800, Skye Poier wrote: > What are the rules around mbuf chain construction? > (I've read man mbuf, doesnt go into much detail) > > In particular, I'm assuming: > - all mbufs must be same type > - the head mbuf must have M_PKTHDR set > - the head mbuf.m_pkthdr.len must be the len of the entire chain > Anything to add? Take a look at the mchain interface for a nice way to deal with mbufs in certain cases: src/sys/kern/subr_mchain.c The `rules' you state are good advice but are not _technically_ obligatory in the most general case. In other words, it is "technically" up to the implementor to decide on how to chain mbufs and what their meaning is. > My confusion is around splitting/concatenating - > > When splitting an mbuf chain, the two resultant chains must be as above > (heads have M_PKTHDR and mbuf.m_pkthdr.len set) right? > > When concatenating chains, what do you do with the M_PKTHDR that is now > in the middle of the chain? m_cat doesn't seem very sophisticated in > this regard. And of course update head mbuf.m_pkthdr.len Again, it all depends on what you're doing. Typically a packet consists of a chain with a head mbuf that is M_PKTHDR and contains the additional information. You don't normally do what you wrote, but again, it depends on the implementation, ultimately. > Thanks > Skye -- Bosko Milekic bmilekic@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message