svn commit: r199201 - in head: contrib/libpcap sbin/ifconfig share/man/man4 sys/kern sys/net sys/sys

Robert Watson rwatson at FreeBSD.org
Thu Nov 12 15:21:41 UTC 2009


On Thu, 12 Nov 2009, Dag-Erling Smørgrav wrote:

>> So there used to be four chars in a row here (between if_description and 
>> if_cspare). Are you sure moving the pointer in between doesn't increase the 
>> structure size?
>
> I can guarantee you that it does.  On i386, for instance, there are now 
> three bytes of implicit padding between if_alloctype and if_description, and 
> one more between if_cspare and if_pspare, so struct ifnet has grown by four 
> bytes.
>
> We should have CASSERTs for sizeof(struct ifnet) and other structs we really 
> care about.

We care less about ifnet than we used to, because ifnet is now allocated by 
the kernel rather than drivers.  However, if we want to take our KPI/KBI more 
seriously, then CTASSERTs on other "public" kernel structures might well be a 
good idea.  On the other hand, CTASSERT errors on build are almost impervious 
to mortal comprehension (if you haven't seen them before, they make little 
sense to the reader), and will make it more difficult for people hacking on 
our kernel to do so casually.  Some sort of other static checker might make 
more sense, and perhaps allow us to do more intelligent checking that just 
"total size" -- we'd also like to detect rearrangement of sensitive structs 
that would be size-preserving.

Robert


More information about the svn-src-all mailing list