net-snk: Fix the check for link-local addresses when receiving RAs
The code that checks whether the router advertisments contain only a link-local address has a bug: It must check the full first 10 bits of the address, not only the first 9 bits. Otherwise, site-local addresses (which start with 0xFEC0...) are also recognized as link-local, which is wrong, of course. Fix it by also introducing a proper wrapper functions for link-local addresses (which will be used in a later patch, too). Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
This commit is contained in:
parent
caf8309249
commit
7dc047e600
|
@ -78,8 +78,8 @@ handle_prefixoption (uint8_t *option)
|
|||
prefix_option = (struct option_prefix *) option;
|
||||
memcpy( &(prefix.addr), &(prefix_option->prefix.addr), IPV6_ADDR_LENGTH);
|
||||
|
||||
/* Link-local adresses in RAs are nonsense */
|
||||
if ( (IPV6_LL_PREFIX & (prefix_option->prefix.part.prefix)) == IPV6_LL_PREFIX )
|
||||
/* Link-local adresses in RAs are nonsense */
|
||||
if (ip6_is_linklocal(&prefix))
|
||||
return;
|
||||
|
||||
if (prefix_option->preferred_lifetime > prefix_option->valid_lifetime)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#define IPV6_ADDR_LENGTH 16 /* Size of IPv6 adress in bytes */
|
||||
#define IPV6_LL_PREFIX 0xFE80000000000000ULL
|
||||
#define IPV6_LL_PREFIX_MASK 0xFFC0000000000000ULL
|
||||
#define IPV6_SOLIC_NODE_PREFIX 0xFF02000000000000ULL
|
||||
#define IPV6_SOLIC_NODE_IFACE_ID 0x00000001FF000000ULL
|
||||
|
||||
|
@ -179,6 +180,12 @@ void * ip6_prefix2addr (ip6_addr_t prefix);
|
|||
/* Compare IPv6 adresses */
|
||||
int8_t ip6_cmp( ip6_addr_t *ip_1, ip6_addr_t *ip_2 );
|
||||
|
||||
/* Check if it is a link-local address */
|
||||
static inline int ip6_is_linklocal(ip6_addr_t *ip)
|
||||
{
|
||||
return (ip->part.prefix & IPV6_LL_PREFIX_MASK) == IPV6_LL_PREFIX;
|
||||
}
|
||||
|
||||
/* Check if prefix is already in our list */
|
||||
int8_t unknown_prefix (ip6_addr_t *ip);
|
||||
|
||||
|
|
Loading…
Reference in New Issue