Hi,

On Mon, Sep 14, 2020 at 10:56:59AM +0200, Antonio Quartulli wrote:
> >          pool->ipv6.base = ipv6_base;
> > +
> > +        /* if a pool starts at ::0, that first IPv6 address is not usable
> > +         * first clients (subnet anycast address).  Start with 1, then.
> > +         * NOTE: this will also fire for something like
> > +         *    ifconfig-ipv6-pool 2001:db8:0:1:1234::0/64
> > +         * as we only look at the rightmost 32 bits.  So be it...
> > +         */
> > +        if (base == 0)
> 
> why not memcmp'ing ipv6.base with in6addr_any (defined in netinet/in.h)?
> This way you get rid of the first NOTE (unless this header is linux
> specific..).

because ipv6.base is not "all zero"...  it's "the IPv6 address that
the pool starts on", host + network part...

If you have pools like this:

  --ifconfig-ipv6-pool 2001:db8:0:1:1234::0/64
  --ifconfig-ipv6-pool 2001:db8:0:1:1234::0/112

what would "comparing with in6addr_any" achieve?  "ipv6.base" is 
2001:db8:0:1:1234::0 in both cases.


Now, "base" is "an integer that contains the lower 32 bit of the host
part" - which is 0, for both these cases.

To fix this "totally perfect" we'd need to move "base" to 64 bit integer,
and then figure out how to do that portably across supported 32 bit
platforms (including MSVC) (or work with 2x 32 bit 'base_low', 'base_hi',
or do "full 128 bit on 16 uint8_t" stuff...).

Yes, this can be done, but I was way too lazy and went for a less intrusive 
fix instead...

gert

-- 
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             g...@greenie.muc.de

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to