In Quagga function strcmp is used to compare both ipv4 and ipv6 addresses. This is incorrect, since there are multiple string representations of one ipv6 address (e.g. strings 2002::a1, 2002:0:0:0:0:0:0:a1, 2002::00a1, 2002::00A1 represent one ipv6 address, 2002:0000:0000:0000:0000:0000:0000:00a1. Possible representations are described in RFC 5952). To correctly compare ipv6 addresses, they must be compared using IPV6_ADDR_CMP function (defined in lib/prefix.h), which will compare addresses stored in struct in6_addr form.
In some cases calling function is not aware of underlying string address family (AF_INET or AF_INET6). So wrapping function ip_addr_cmp is created, to determine AF of IP address string.
Tags: fix, dev, Github issue #7
Change-Id: Ib87badcbd14c6607d2119557f2adc0afa6e928f8 Signed-off-by: Ilya Schepin ischepin@mera.ru
In Quagga function
strcmp
is used to compare both ipv4 and ipv6 addresses. This is incorrect, since there are multiple string representations of one ipv6 address (e.g. strings 2002::a1, 2002:0:0:0:0:0:0:a1, 2002::00a1, 2002::00A1 represent one ipv6 address, 2002:0000:0000:0000:0000:0000:0000:00a1. Possible representations are described in RFC 5952). To correctly compare ipv6 addresses, they must be compared usingIPV6_ADDR_CMP
function (defined in lib/prefix.h
), which will compare addresses stored instruct in6_addr
form.In some cases calling function is not aware of underlying string address family (AF_INET or AF_INET6). So wrapping function
ip_addr_cmp
is created, to determine AF of IP address string.