[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netbsd-tech-net
Subject:    Re: Explicit packing in <netinet/ip.h>
From:       "B. James Phillippe \(nospam address\)" <bryan-nospam () darkforest ! org>
Date:       2002-01-21 21:13:19
[Download RAW message or body]

On the cold day of Jan 21, der Mouse mused:

> > I am curious to know why <netinet/ip.h> explicitly packs "struct ip" in
> > NetBSD (BTW, I'm on NetBSD-1.5.2/alpha).  None of the other UNIX
> > systems I have access to* do this, and I would not think it necessary.
>
> It appears - to me - to be not for the sake of structure packing but
> rather for the sake of declaring it possibly misaligned.

Right, since the definition of an IP header (all of them) is inherently
packed.

> > But would this not also cause the compiler to possibly generate fixups
> > where they are not needed as well?
>
> Yes.  In many (most?) uses of struct ip, the compiler can't know whether
> the struct is aligned until run-time (because it's overlaid onto memory
> obtained from elsewhere, such as an mbuf).

Okay, so now that I have an agreeing expert, :-) I can pose the question of
whether this will have a needless performance impact on the networking
layer?

Particulary on systems where unaligned fixups are expensive, like Alpha.
This of course assumes that the IP structures are almost always aligned
properly - I am still a newbie with NetBSD, but from looking at the if_de.c
ethernet driver, it does appear to be the case that, as in Linux, the
driver shifts the IP header up by 2 bytes to account for the 14-byte
ethernet header.

-bp
--
# bryan at darkforest dot org
# Software Architect


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic