Subject: m_pulldown()
To: None <>
From: None <>
List: tech-net
Date: 12/02/1999 13:35:05
	I'm now trying to upgrade IPv6 code in HEAD branch to more recent
	KAME releases.

	For better mbuf chain support in IPv6, KAME team came up with
	a function called m_pulldown().  KAME code is under migration to use
	this function.  There are #ifdef PULLDOWN_TEST in sys/netinet{,6}.

	Is it okay to bring those #ifdefs into HEAD branch?  this would allow
	me to synchronize to KAME code easier (if there's less differences
	it will be easier).


idea behind m_pulldown()

4.4BSD IPv4 code assumes the following:
- size from IPv4 header to final transport layer header (like tcp option)
  is smaller than MHLEN (m_pullup)
- no single protocol header occupies more than MLEN.
the first one is not true for IPv6 packet, or IPsec packet.  IPv6/IPsec
packet can have unlimited number of protocol headers due to header chains
(there's no upper limit set in protocol document.  in implementation
we may choose to drop packets with too many hdrs like > 20).
2nd one is more academic, but it would be better if we can remove this

current KAME code (prior to m_pulldown) changes MINCLSIZE and let drivers
throw up cluster mbufs, if a packet does not fit MHLEN.  This would allow
us to see completely contiguous packet on a single mbuf.
this approach is not very good as we need to check every drivers for mbuf
chain conditions (see 1.11 in NetBSD src/sys/netinet6/IMPLEMENTATION).
also, there are exceptions, like:
- packets from loopback
- tunnelled packets
- ipsec packets
where we see non-contiguous mbufs.

best approach would be to trim mbuf chain as necessary, to put
headers into contiguous regions (if the packet is completely contiguous
we will do nothing).  m_pulldown() does the trick.
see src/sys/kern/uipc_mbuf2.c in kame branch for the code.
(this will be put into uipc_mbuf.c.  uipc_mbuf2.c is used just for code
sharing across *BSD in KAME repository)