On 26 Dec 2021, at 19:14, Gleb Smirnoff <[email protected]> wrote:
> 
>  Jessica,
> 
> On Sun, Dec 26, 2021 at 07:07:06PM +0000, Jessica Clarke wrote:
> J> > +struct prison_ip {
> J> > +        struct epoch_context ctx;
> J> > +        uint32_t        ips;
> J> > +#ifdef FUTURE_C
> J> > +        union {
> J> > +                struct in_addr pr_ip4[];
> J> > +                struct in6_addr pr_ip6[];
> J> > +        };
> J> > +#else /* No future C :( */
> J> > +#define PR_IP(pip, i)   ((const char *)((pip) + 1) + 
> pr_families[af].size * (i))
> J> > +#define PR_IPD(pip, i)  ((char *)((pip) + 1) + pr_families[af].size * 
> (i))
> J> > +#endif
> J> > +};
> J> 
> J> You can make this work with a prison_ip base and prison_ipv[46] derived
> J> structs.
> J> 
> J> As it stands this is quite gross, you’re assuming things about
> J> alignment, and don’t even have a flexible char[] at the end to
> J> represent the extra data.
> 
> Will adding char [] to the end be sufficient to guarantee proper alignment?

No.

> Using prison_ipv[46] derived structs won't work as most functions are now
> made protocol independent.

Why not? Just cast from prison_ip * to prison_ipv4 * when known/needed?

Jess


Reply via email to