2016-08-02 14:37:50

by Alexander Aring

[permalink] [raw]
Subject: [PATCH linux-wpan/radvd for-upstream 0/2] radvd: upstream patches

Hi,

this patch series has some overdue updates for radvd upstream version.
It doesn't contain rework of 6CO handling, since we don't have a stable
UAPI to provide stateful compression to userspace.

Anyway radvd has actually 6CO handling which is ?broken? don't know what
it should do at the moment. 6CO without stateful compression setting
makes no sense for me. If you like to use 6CO over debugfs use
linux-wpan/radvd "6lowpan" branch.

---

I will update the "6lowpan" branch also with Patch 2/2 which adds support
to get address length via sysfs. This patch will prepare correct handling
for the new BTLE 6LoWPAN handling to use the correct address and
address length (not 8 bytes, with U/L bit). It will not work with the
current mainline version because the address option will set the address
length with U/L bitflip in NS/NA/RS, but radvd will not do this because
it's simple wrong to do it. :-)

Everbody which wants to have this bug compatible stuff should change
radvd in their own source code.

- Alex

Alexander Aring (2):
device-linux: replace ARPHRD_IEEE802154 to ARPHRD_6LOWPAN
device-linux: get address length via sysfs

device-linux.c | 49 ++++++++++++++++++++++++++++++++++++++++++++-----
pathnames.h | 1 +
2 files changed, 45 insertions(+), 5 deletions(-)

--
2.9.0



2016-08-04 09:34:04

by Alexander Aring

[permalink] [raw]
Subject: Re: [PATCH linux-wpan/radvd for-upstream 1/2] device-linux: replace ARPHRD_IEEE802154 to ARPHRD_6LOWPAN


Hi,

On 08/04/2016 10:26 AM, Luiz Augusto von Dentz wrote:
> Hi Alex,
>
> On Tue, Aug 2, 2016 at 5:37 PM, Alexander Aring <[email protected]> wrote:
>> This patch changes the ARPHRD_IEEE802154 to ARPHRD_6LOWPAN. The IEEE
>> 802.15.4 6lowpan module changed the ARPHRD_IEEE802154 type to
>> ARPHRD_6LOWPAN. Nowadays it's use ARPHRD_6LOWPAN which is also used by
>> BTLE 6LoWPAN. Both interfaces uses an EUI64 address and the handling to
>> get the link-layer address should be the same.
>
> Bluetooth MAC addresses are 48 bits long, it could be converted to 64
> bits to generate the so called IID but that is only to generate the
> link-local address:
>
> https://tools.ietf.org/html/rfc7668#section-3.2.2
>

Ah, yes sorry. This commit msg was created in a time when I just looked
into the bluetooth code ans saw dev->addr_len = 8 and trust it. :-)

Patch 2/2 will care about different address lengths.

btw:

Radvd needs the device address for option:

AdvSourceLLAddress on|off

see [0].

However Patch 2/2 will fix it, I just need to convert to a netlink
handling. I have it running now, but it looks ugly (maybe that's normal
when doing low-level netlink stuff).

I will fix the commit msg.

- Alex

[0] http://linux.die.net/man/5/radvd.conf

2016-08-04 08:26:05

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH linux-wpan/radvd for-upstream 1/2] device-linux: replace ARPHRD_IEEE802154 to ARPHRD_6LOWPAN

Hi Alex,

On Tue, Aug 2, 2016 at 5:37 PM, Alexander Aring <[email protected]> wrote:
> This patch changes the ARPHRD_IEEE802154 to ARPHRD_6LOWPAN. The IEEE
> 802.15.4 6lowpan module changed the ARPHRD_IEEE802154 type to
> ARPHRD_6LOWPAN. Nowadays it's use ARPHRD_6LOWPAN which is also used by
> BTLE 6LoWPAN. Both interfaces uses an EUI64 address and the handling to
> get the link-layer address should be the same.

Bluetooth MAC addresses are 48 bits long, it could be converted to 64
bits to generate the so called IID but that is only to generate the
link-local address:

https://tools.ietf.org/html/rfc7668#section-3.2.2

> There is no backward compatibility for 802.15.4 6LoWPAN before we
> changed the ARPHRD. Anyway if somebody wants that it should be patched
> manually. When the ARPHRD was ARPHRD_IEEE802154 the 802.15.4 6lowpan was
> anyway in a somehow unusable state.
>
> Signed-off-by: Alexander Aring <[email protected]>
> ---
> device-linux.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/device-linux.c b/device-linux.c
> index de83f2e..7301927 100644
> --- a/device-linux.c
> +++ b/device-linux.c
> @@ -22,6 +22,10 @@
> #define IPV6_ADDR_LINKLOCAL 0x0020U
> #endif
>
> +#ifndef ARPHRD_6LOWPAN
> +#define ARPHRD_6LOWPAN 825 /* IPv6 over LoWPAN */
> +#endif
> +
> static char const *hwstr(unsigned short sa_family);
>
> /*
> @@ -79,12 +83,10 @@ int update_device_info(int sock, struct Interface *iface)
> iface->sllao.if_maxmtu = -1;
> break;
> #endif /* ARPHDR_ARCNET */
> -#ifdef ARPHRD_IEEE802154
> - case ARPHRD_IEEE802154:
> + case ARPHRD_6LOWPAN:
> iface->sllao.if_hwaddr_len = 64;
> iface->sllao.if_prefix_len = 64;
> break;
> -#endif
> default:
> iface->sllao.if_hwaddr_len = -1;
> iface->sllao.if_prefix_len = -1;
> @@ -382,6 +384,9 @@ static char const *hwstr(unsigned short sa_family)
> rc = "ARPHRD_IEEE802154_PHY";
> break;
> #endif
> + case ARPHRD_6LOWPAN:
> + rc = "ARPHRD_6LOWPAN";
> + break;
> case ARPHRD_VOID:
> rc = "ARPHRD_VOID";
> break;
> --
> 2.9.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html



--
Luiz Augusto von Dentz

2016-08-02 14:59:28

by Alexander Aring

[permalink] [raw]
Subject: Re: [PATCH linux-wpan/radvd for-upstream 2/2] device-linux: get address length via sysfs


Hi,

On 08/02/2016 04:37 PM, Alexander Aring wrote:
> This patch will change the behaviour for 6LoWPAN interface to detect the
> linklayer address length via sysfs. The usually way to get the address
> length is via a mapping from ARPHRD device type. This doesn't work for
> 6LoWPAN interfaces, we need at least some other mechanism. This patch
> adds the mechanism to read out the sysfs UAPI to get the addr_len
> attribute of net_device. This will not work if there are two 6LoWPAN
> link-layer types with the same address length but need different
> handling in userspace. For that reason I think a linklayer type would be
> better, this requires a 6lowpan netlink API which doesn't exist right
> now. So we use this simple way now.
>
> Signed-off-by: Alexander Aring <[email protected]>

I need to remove this signed off. That's not radvd commit style. :-)

---

After talking shortly with Marcel, RTNL netlink has already the same
stuff what we can get from sysfs entry here. See [0] kernel and [1]
userspace.

Over RTA_PAYLOAD(tb[IFLA_ADDRESS]) [1], we should be able to get the
dev->addr_len which is given by [0]... I make now a new version with
netlink as UAPI mechanism.

- Alex

[0] http://lxr.free-electrons.com/source/net/core/rtnetlink.c#L1247
[1] https://github.com/shemminger/iproute2/blob/master/lib/ll_map.c#L84

2016-08-02 14:37:52

by Alexander Aring

[permalink] [raw]
Subject: [PATCH linux-wpan/radvd for-upstream 2/2] device-linux: get address length via sysfs

This patch will change the behaviour for 6LoWPAN interface to detect the
linklayer address length via sysfs. The usually way to get the address
length is via a mapping from ARPHRD device type. This doesn't work for
6LoWPAN interfaces, we need at least some other mechanism. This patch
adds the mechanism to read out the sysfs UAPI to get the addr_len
attribute of net_device. This will not work if there are two 6LoWPAN
link-layer types with the same address length but need different
handling in userspace. For that reason I think a linklayer type would be
better, this requires a 6lowpan netlink API which doesn't exist right
now. So we use this simple way now.

Signed-off-by: Alexander Aring <[email protected]>
---
device-linux.c | 38 ++++++++++++++++++++++++++++++++++++--
pathnames.h | 1 +
2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/device-linux.c b/device-linux.c
index 7301927..c483952 100644
--- a/device-linux.c
+++ b/device-linux.c
@@ -29,6 +29,34 @@
static char const *hwstr(unsigned short sa_family);

/*
+ * get interface address length over sysfs
+ */
+static int get_device_addr_len(struct Interface *iface)
+{
+ char path[PATH_MAX];
+ uint32_t addr_len;
+ FILE *f;
+ int ret;
+
+ ret = sprintf(path, SYS_CLASS_NET_ADDRLEN, iface->props.name);
+ if (ret < 0)
+ return -1;
+
+ f = fopen(path, "r");
+ if (!f)
+ return -1;
+
+ ret = fscanf(f, "%u", &addr_len);
+ if (ferror(f)) {
+ fclose(f);
+ return -1;
+ }
+
+ fclose(f);
+ return addr_len;
+}
+
+/*
* this function gets the hardware type and address of an interface,
* determines the link layer token length and checks it against
* the defined prefixes
@@ -84,8 +112,14 @@ int update_device_info(int sock, struct Interface *iface)
break;
#endif /* ARPHDR_ARCNET */
case ARPHRD_6LOWPAN:
- iface->sllao.if_hwaddr_len = 64;
- iface->sllao.if_prefix_len = 64;
+ iface->sllao.if_hwaddr_len = get_device_addr_len(iface);
+ if (iface->sllao.if_hwaddr_len != -1) {
+ iface->sllao.if_hwaddr_len *= 8;
+ iface->sllao.if_prefix_len = 64;
+ } else {
+ iface->sllao.if_prefix_len = -1;
+ }
+
break;
default:
iface->sllao.if_hwaddr_len = -1;
diff --git a/pathnames.h b/pathnames.h
index 580e2b2..152bb7a 100644
--- a/pathnames.h
+++ b/pathnames.h
@@ -40,6 +40,7 @@
#define PROC_SYS_IP6_BASEREACHTIME "/proc/sys/net/ipv6/neigh/%s/base_reachable_time"
#define PROC_SYS_IP6_RETRANSTIMER_MS "/proc/sys/net/ipv6/neigh/%s/retrans_time_ms"
#define PROC_SYS_IP6_RETRANSTIMER "/proc/sys/net/ipv6/neigh/%s/retrans_time"
+#define SYS_CLASS_NET_ADDRLEN "/sys/class/net/%s/addr_len"
#else /* BSD */
#define SYSCTL_IP6_FORWARDING CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_FORWARDING
#endif
--
2.9.0


2016-08-02 14:37:51

by Alexander Aring

[permalink] [raw]
Subject: [PATCH linux-wpan/radvd for-upstream 1/2] device-linux: replace ARPHRD_IEEE802154 to ARPHRD_6LOWPAN

This patch changes the ARPHRD_IEEE802154 to ARPHRD_6LOWPAN. The IEEE
802.15.4 6lowpan module changed the ARPHRD_IEEE802154 type to
ARPHRD_6LOWPAN. Nowadays it's use ARPHRD_6LOWPAN which is also used by
BTLE 6LoWPAN. Both interfaces uses an EUI64 address and the handling to
get the link-layer address should be the same.

There is no backward compatibility for 802.15.4 6LoWPAN before we
changed the ARPHRD. Anyway if somebody wants that it should be patched
manually. When the ARPHRD was ARPHRD_IEEE802154 the 802.15.4 6lowpan was
anyway in a somehow unusable state.

Signed-off-by: Alexander Aring <[email protected]>
---
device-linux.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/device-linux.c b/device-linux.c
index de83f2e..7301927 100644
--- a/device-linux.c
+++ b/device-linux.c
@@ -22,6 +22,10 @@
#define IPV6_ADDR_LINKLOCAL 0x0020U
#endif

+#ifndef ARPHRD_6LOWPAN
+#define ARPHRD_6LOWPAN 825 /* IPv6 over LoWPAN */
+#endif
+
static char const *hwstr(unsigned short sa_family);

/*
@@ -79,12 +83,10 @@ int update_device_info(int sock, struct Interface *iface)
iface->sllao.if_maxmtu = -1;
break;
#endif /* ARPHDR_ARCNET */
-#ifdef ARPHRD_IEEE802154
- case ARPHRD_IEEE802154:
+ case ARPHRD_6LOWPAN:
iface->sllao.if_hwaddr_len = 64;
iface->sllao.if_prefix_len = 64;
break;
-#endif
default:
iface->sllao.if_hwaddr_len = -1;
iface->sllao.if_prefix_len = -1;
@@ -382,6 +384,9 @@ static char const *hwstr(unsigned short sa_family)
rc = "ARPHRD_IEEE802154_PHY";
break;
#endif
+ case ARPHRD_6LOWPAN:
+ rc = "ARPHRD_6LOWPAN";
+ break;
case ARPHRD_VOID:
rc = "ARPHRD_VOID";
break;
--
2.9.0