RMerl/asuswrt-merlin — pull request #687 by NickZ (2014-07-30 03:15:37+00:00)
Title: FIX: Incorrect IPv6 prefix length when not /64

in getifaddr (which is used to set the nvram ipv6 variables in uhcpd), bitwise
operations are used to calculate the last byte of the netmask on prefix lengths that
are not multiples of 8 (see line 712). Unfortunately, these are being performed on a
32-bit integer, not an 8-bit char. So /60 ends up becoming /84, for example.

This bug results in non-/64 block IPv6 prefixes that are delegated via DHCP-PD to be recorded incorrectly. The incorrect prefix length is recorded in nvram and used by dhcps and radvd, but the correct prefix assigned to the bridge interface remains unchanged. As a result, DNS and router advertisement are broken.

changing this function to use ffs() instead to calculate the least significant bit fixes the length calculation, and resolved this but.