Subject: Re: netipsec/ipsec6.h prototype changes for NetBSD/FreeBSD diffs
To: Jonathan Stone <jonathan@DSG.Stanford.EDU>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-net
Date: 11/20/2003 07:56:48
On Nov 19, 2003, at 10:50 PM, Jonathan Stone wrote:
> The patch below shows one of two approaches to fixing the callers of
> the amended functions: assuming `struct inpcb *' is a generic PCB
> pointer, then scattering explicit casts between through the code as
> needed when the protocol-family is INET6.
>
> The other approach is to introduce macros to hide all the casts; this
> approach has the advantage that it could, in principle, hide the
> differences between KAME's preferred ``generic pcb argument
> (following back-pointer to the struct socket*, and passing it), versus
> the
> more efficient and elegant approach, of passing a pointer to
> the struct inpcb_hdr prefix which is common to both structs.
Whatever you do here, be careful not to break any of C99's alias rules;
the new GCC uses aliases rules to optimize, and when you break them,
you can get bad object code.
I tend to favor passing the common bits around, as well. Casting inpcb
to in6pcb is just going to confuse people when they look at the code
later.
-- Jason R. Thorpe <thorpej@wasabisystems.com>