Skip to content

Commit

Permalink
ipv6: addrconf: fix 48 bit 6lowpan autoconfiguration
Browse files Browse the repository at this point in the history
This patch adds support for 48 bit 6LoWPAN address length
autoconfiguration which is the case for BTLE 6LoWPAN.

Signed-off-by: Alexander Aring <[email protected]>
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
Reviewed-by: Stefan Schmidt <[email protected]>
Acked-by: David S. Miller <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
  • Loading branch information
Alexander Aring authored and holtmann committed Apr 12, 2017
1 parent 94e4a68 commit 8a7a4b4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2073,12 +2073,19 @@ static void addrconf_leave_anycast(struct inet6_ifaddr *ifp)
__ipv6_dev_ac_dec(ifp->idev, &addr);
}

static int addrconf_ifid_eui64(u8 *eui, struct net_device *dev)
static int addrconf_ifid_6lowpan(u8 *eui, struct net_device *dev)
{
if (dev->addr_len != EUI64_ADDR_LEN)
switch (dev->addr_len) {
case ETH_ALEN:
return addrconf_ifid_eui48(eui, dev);
case EUI64_ADDR_LEN:
memcpy(eui, dev->dev_addr, EUI64_ADDR_LEN);
eui[0] ^= 2;
break;
default:
return -1;
memcpy(eui, dev->dev_addr, EUI64_ADDR_LEN);
eui[0] ^= 2;
}

return 0;
}

Expand Down Expand Up @@ -2170,7 +2177,7 @@ static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
case ARPHRD_TUNNEL:
return addrconf_ifid_gre(eui, dev);
case ARPHRD_6LOWPAN:
return addrconf_ifid_eui64(eui, dev);
return addrconf_ifid_6lowpan(eui, dev);
case ARPHRD_IEEE1394:
return addrconf_ifid_ieee1394(eui, dev);
case ARPHRD_TUNNEL6:
Expand Down

0 comments on commit 8a7a4b4

Please sign in to comment.