ipv6: fix IPv6 address matching algorithm

Found this by actually testing the reworked version in #2003.