Fix #6768 IPv6 static mapping on delegated prefixes
For example, WAN receives a /48 delegated from the upstream (ISP...), e.g. "2001:470:abcd::" pfSense then uses this as a starting point to calculate the addresses on LAN, OPT1, OPT2 etc where they have been specified asa "track interface WAN". Actually each local interface gets just a /64 taken out of the /48, using the chunk specified by "IPv6 Prefix Id" for that local interface. e.g. if "IPv6 Prefix Id" is set to "a1" on LAN, then the LAN would be: 2001:470:abcd:00a1::/64
Then when we specify a static-mapped address in LAN, or other things that live in LAN, e.g. "::4242" we mean 4242 on from the base LAN address, so "2001:470:abcd:00a1::4242"
i.e. we always have a CIDR of 64 when calculating this stuff. We do not want the logic that was in this code that was using the upstream prefix delegation size (like /48).
Note: The code in services.inc "worked" because var $ifname was not set, and so $trackifname was blank, $trackcfg was blank, and so the attempted calculation of $pdlen always came out as 64 anyway. That tricked me for a while trying to understand why the use in service.inc worked. system.inc did not work, because it actually claculated $pdlen and got a number like 48 - which actually we do not want here.
Related issues
Bug #6768: DNS Resolver entry for DHCPv6 static mapping has wrong IP address
Fix #6768 IPv6 static mapping on delegated prefixes
For example, WAN receives a /48 delegated from the upstream (ISP...),
e.g. "2001:470:abcd::" pfSense then uses this as a starting point to
calculate the addresses on LAN, OPT1, OPT2 etc where they have been
specified asa "track interface WAN".
Actually each local interface gets just a /64 taken out of the /48,
using the chunk specified by "IPv6 Prefix Id" for that local interface.
e.g. if "IPv6 Prefix Id" is set to "a1" on LAN, then the LAN would be:
2001:470:abcd:00a1::/64
Then when we specify a static-mapped address in LAN, or other things
that live in LAN, e.g. "::4242" we mean 4242 on from the base LAN
address, so "2001:470:abcd:00a1::4242"
i.e. we always have a CIDR of 64 when calculating this stuff. We do not
want the logic that was in this code that was using the upstream prefix
delegation size (like /48).
Note: The code in services.inc "worked" because var $ifname was not set,
and so $trackifname was blank, $trackcfg was blank, and so the attempted
calculation of $pdlen always came out as 64 anyway. That tricked me for
a while trying to understand why the use in service.inc worked.
system.inc did not work, because it actually claculated $pdlen and got a
number like 48 - which actually we do not want here.