Subject: Re: adding mbuf member
To: Jun-ichiro itojun Hagino <>
From: Jason Thorpe <>
List: tech-net
Date: 01/29/2000 09:14:41
On Sat, 29 Jan 2000 16:38:30 +0900 
 Jun-ichiro itojun Hagino <> wrote:

 > 	I'm still wondering what kind of format is good for "aux" portion.
 > 	I'm thinking about tagging mbuf on "aux" chain with commonly formatted
 > 	data item like:
 > 		struct tag {
 > 			u_int8_t proto;
 > 			u_int8_t code;
 > 		};

This seems okay, but remember this is going to be padded out on most
platforms, so you might just consider making them "int"s, or something.

 > 	By searching through "aux" chain, we can use the variable across
 > 	various protocol handlers (not only ipsec, but also some others like
 > 	filters maybe?).
 > 	m_freem() needs to call m_freem(m->m_pkthdr.aux) as well to
 > 	avoid memory leakage.

Be careful to avoid recursion :-)

 > 	downside of this is, of course, MHLEN becomes smaller by addition
 > 	of pointer item.  having generic data item to "aux", I hope to
 > 	avoid future member addition to mbuf structure.

Yah, that's annoying.  Maybe we should increase MSIZE to 256 across the
board?  The Alpha and Sparc64 will still lose space (because they already
have MSIZE == 256), but I don't see what harm will come to other ports,
really, unless they are otherwise seriously memory-starved already.

 > 	If it is okay to add this member, first step would be to use "aux"
 > 	just to avoid overloading of m->m_pkthdr.rcvif to help if_detach and
 > 	packet filters.  then, we'll implement extra mbuf chain handling
 > 	and put socket information and other things into "aux"chain.
 > 	I'll test it in KAME tree and bring it into netbsd, hopefully very soon.
 > 	Comments/suggestions/whatever?

Yes, that's great... I really want to stop overloading `rcvif' ... because
I'm currently working on if_detach :-)

 >  struct	pkthdr {
 >  	struct	ifnet *rcvif;		/* rcv interface */
 >  	int	len;			/* total packet length */
 > +	struct mbuf *aux;		/* aux data buffer; ipsec and others */
 >  };

I have a concern here... you're going to waste space on LP64 platforms
with this arrangement... it should be:

	struct ifnet *rcvif;
	struct mbuf *aux;
	int len;

But then its an ABI change for LKMs.  I guess people will have to recompile
IP Filter.  This will warrant a version number bump (to 1.4R).

        -- Jason R. Thorpe <>