Subject: Re: unaligned IP header
To: None <tech-net@netbsd.org>
From: Jason R Thorpe <thorpej@zembu.com>
List: tech-net
Date: 04/24/2000 07:59:31
On Mon, Apr 24, 2000 at 11:23:45AM +0900, itojun@iijlab.net wrote:

 > 	are you suggesting something like this in ip_input()?
 > 
 > itojun
 > 
 > 
 > if (((u_long)mtod(m, caddr_t)) % ALIGNBYTES) {
 > 	/* unaligned ip header - force pullup */
 > 	m = m_pullup_always(m, sizeof struct ip);	/*always pullup*/
 > }

Well, the exact clause would be more like:

	if (ALIGNED_POINTER(mtod(m, caddr_t), u_int32_t) == 0) {
		/* Unaligned IP header -- force pullup */
		m = m_pullup_always(m, sizeof(struct ip));
	}

...but this requires additional memory allocation, and additional data
copying.

Now, we could eliminate the memory allocation part by doing the m_extract()
thing suggested by Matt Thomas previously (during the m_pulldown() discussion),
and by passing a "struct ip_info" around.

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>