aboutsummaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2016-01-14 00:10:35 +0100
committerAlexey Kardashevskiy <aik@ozlabs.ru>2016-01-14 11:25:51 +1100
commit7dc047e600063e13915a81d05713769d96fdcf7c (patch)
treebf8535c65b2c6dfd8a0204f22f4d58578f1fd3dd /clients
parentcaf83092499fd07035b05a108c423f0cda17caae (diff)
downloadSLOF-7dc047e600063e13915a81d05713769d96fdcf7c.zip
SLOF-7dc047e600063e13915a81d05713769d96fdcf7c.tar.gz
SLOF-7dc047e600063e13915a81d05713769d96fdcf7c.tar.bz2
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>
Diffstat (limited to 'clients')
-rw-r--r--clients/net-snk/app/netlib/icmpv6.c4
-rw-r--r--clients/net-snk/app/netlib/ipv6.h7
2 files changed, 9 insertions, 2 deletions
diff --git a/clients/net-snk/app/netlib/icmpv6.c b/clients/net-snk/app/netlib/icmpv6.c
index be6cc11..940b834 100644
--- a/clients/net-snk/app/netlib/icmpv6.c
+++ b/clients/net-snk/app/netlib/icmpv6.c
@@ -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)
diff --git a/clients/net-snk/app/netlib/ipv6.h b/clients/net-snk/app/netlib/ipv6.h
index b496364..963a1b0 100644
--- a/clients/net-snk/app/netlib/ipv6.h
+++ b/clients/net-snk/app/netlib/ipv6.h
@@ -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);