radvd: 6lowpan 6CO testing patches
Subsystems (4)
Alexander Aring
maintainercover radvd: 6lowpan 6CO testing patches
Hi,
this patch is for testing 6CO fields in RA messages with the help of radvd.
I tested it with the following configuration and two or more nodes which can directly reach each other.
On one node (6LBR, if more 6LBR they need to have the same context information!):
interface lowpan0
{
Adv6LBR on;
AdvSendAdvert on;
UnicastOnly on;
AdvCurHopLimit 255;
prefix 2001::/64 {
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
};
lowpanco {
ctx 0 {
AdvContextCompressionFlag on;
AdvContextLength 64;
AdvContextPrefix 2001::;
AdvLifeTime 1000;
};
};
};On other nodes:
interface lowpan0
{
Adv6LBR off;
AdvSendAdvert off;
};Then you can see that the assigned global link 2001::/64 address will be compressed. Tested with: ping6 and wireshark on $WPAN interface, when using 802.15.4 6LoWPAN.
- Alex
Alexander Aring (2):
device-linux: replace ARPHRD_IEEE802154 to ARPHRD_6LOWPAN
radvd: rework 6CO handling
defaults.h | 3 +++ device-bsd44.c | 6 ++++++ device-linux.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- gram.y | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- pathnames.h | 1 + privsep-linux.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- process.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ radvd.c | 6 ++++++ radvd.h | 21 +++++++++++++++++++-- scanner.l | 4 +++- send.c | 33 ++++++++++++++++++++++++--------- 11 files changed, 253 insertions(+), 25 deletions(-)
Signature · 1 line
2.6.1
Alexander Aring
maintainerRFC 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.
--- device-linux.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
device-linux.c +8 -3
@@ -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 ;
Signature · 1 line
2.6.1
A message that is not in the archive (sent off-list or not yet received): 1450102056-23107-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
RFC 2/2 radvd: rework 6CO handling
Current issues with the 6CO handling:
- Doesn't work on little endian at my side because forgotten byteordering handling at bitfields.
- There can be multiple 6CO options. Up to 16 6CO options at maximum.
- It doesn't work as it should. Maybe for some use-case somebody need that, but 6CO contains information for header parsing and this need functionality to tell it the kernel. Currently we have a debugfs entry for that.
As an example, RFC6775 describes the 6LBR should be configurated and managed the context entries of RFC6282.
interface lowpan0
{
Adv6LBR on;
AdvSendAdvert on;
UnicastOnly on;
AdvCurHopLimit 255;
prefix 2001::/64 {
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
};
lowpanco {
ctx 0 {
AdvContextCompressionFlag on;
AdvContextLength 64;
AdvContextPrefix 2001::;
AdvLifeTime 1000;
};
};
};If we set "Adv6LBR" to on, then the "lowpanco" contexts will be setup during startup of radvd, otherwise all contexts are empty (non active).
I changed the parsing of contexts:
- lowpanco contains up-to 16 contexts with _unique_ id's.
- The id is after "ctx" specified.
What doesn't work:
- Lifetime handling.
- AdvContextCompressionFlag should be 0 at first to propagate "safety" the context inside the context. RFC6775 says here:
New context information SHOULD be introduced into the LoWPAN with C=0, to ensure that it is known by all nodes that may have to perform header decompression based on this context information. Only when it is reasonable to assume that this information was successfully disseminated SHOULD an option with C=1 be sent, enabling the actual use of the context information for compression
I know what this means, but then don't know "when" we can do "C=1", maybe this is out-of-scope in RFC6775.
Note:
I ignore the ABRO for now. The ABRO need to be included and the version fields indicates if new context or old context information. This is just to begin with something to handle 6CO.
--- defaults.h | 3 +++ device-bsd44.c | 6 ++++++ device-linux.c | 35 +++++++++++++++++++++++++++++++++++ gram.y | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- pathnames.h | 1 + privsep-linux.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- process.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ radvd.c | 6 ++++++ radvd.h | 21 +++++++++++++++++++-- scanner.l | 4 +++- send.c | 33 ++++++++++++++++++++++++--------- 11 files changed, 245 insertions(+), 22 deletions(-)
defaults.h +3 -0
@@ -125,6 +125,9 @@#define MAX_PrefixLen 128 +/* RFC6282 Constraints */ +#define MAX_CIDLen 16 +/* SLAAC (RFC4862) Constants and Derived Values */ #define MIN_AdvValidLifetime 7200/* 2 hours in secs */
device-bsd44.c +6 -0
@@ -143,6 +143,12 @@ int set_interface_retranstimer(const char *iface, uint32_t rettimer)return -1 ; } +int set_interface_6ctx (const struct Interface *iface,struct AdvLowpanCtx ctx) +{ +dlog (LOG_DEBUG ,4 ,"update 6LoWPAN context not supported" ); +return 0 ; +} +int check_ip6_forwarding (void ) {dlog (LOG_DEBUG ,4 ,"checking ipv6 forwarding not supported" );
device-linux.c +35 -0
@@ -86,6 +86,30 @@ int update_device_info(int sock, struct Interface *iface)case ARPHRD_6LOWPAN : iface->sllao.if_hwaddr_len =64 ; iface->sllao.if_prefix_len =64 ; + +if (iface->state_info.configured) +break ; + +/* if nothing specified use a empy AdvLowpanCoList as default */ +if (!iface->AdvLowpanCoList) { + iface->AdvLowpanCoList =malloc (sizeof (struct AdvLowpanCo )); +if (iface->AdvLowpanCoList ==NULL ) { +flog (LOG_ERR ,"AdvLowpanCo allocation failed" ); +return -2 ; + } + +memset (iface->AdvLowpanCoList,0 ,sizeof (struct AdvLowpanCo )); + }else { +/* If the LoWPAN uses header compression [RFC6282] with context, then +* the 6LBR must be configured with context information and related +* CIDs. Zero all if non 6LBR. +*/ +if (!iface->Adv6LBR) +memset (iface->AdvLowpanCoList,0 ,sizeof (struct AdvLowpanCo )); + } + +for (int i =0 ; i < MAX_CIDLen -1 ; i++) + iface->AdvLowpanCoList->table[i].AdvContextID = i;break ;default : iface->sllao.if_hwaddr_len =-1 ;
@@ -147,6 +171,17 @@ int setup_allrouters_membership(int sock, struct Interface *iface)return 0 ; } +int set_interface_6ctx (const struct Interface *iface,struct AdvLowpanCtx ctx) +{ +int ret; + + ret =privsep_interface_6ctx (iface->props.name, ctx); +if (ret ==0 ) + iface->AdvLowpanCoList->table[ctx.AdvContextID] = ctx; + +return ret; +} +int set_interface_linkmtu (const char *iface,uint32_t mtu) {return privsep_interface_linkmtu (iface, mtu);
gram.y +46 -9
112 lines not on this page · raw message
pathnames.h +1 -0
@@ -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 DEBUGFS_6LOWPAN_CTX_TABLE "/sys/kernel/debug/6lowpan/%s/ctx_table"#else /* BSD */ #define SYSCTL_IP6_FORWARDING CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_FORWARDING#endif
privsep-linux.c +54 -1
81 lines not on this page · raw message
process.c +48 -0
54 lines not on this page · raw message
radvd.c +6 -0
@@ -710,6 +710,12 @@ static void config_interface(struct Interface *iface)set_interface_reachtime (iface->props.name, iface->ra_header_info.AdvReachableTime);if (iface->ra_header_info.AdvRetransTimer)set_interface_retranstimer (iface->props.name, iface->ra_header_info.AdvRetransTimer); +if (iface->AdvLowpanCoList) { +for (int i =0 ; i < MAX_CIDLen -1 ; i++) +set_interface_6ctx (iface, iface->AdvLowpanCoList->table[i]); + } + + iface->state_info.configured =1 ; }/*
radvd.h +19 -2
@@ -60,6 +60,7 @@ struct Interface {int ready;/* Info whether this interface has been initialized successfully */ int changed;/* Info whether this interface's settings have changed */ int cease_adv; +int configured;uint32_t racount; } state_info;
@@ -112,6 +113,7 @@ struct Interface {int AdvMobRtrSupportFlag; } mipv6; +int Adv6LBR;struct AdvLowpanCo *AdvLowpanCoList;struct AdvAbro *AdvAbroList;
@@ -187,15 +189,20 @@ struct AdvDNSSL {struct AdvDNSSL *next; }; -/* Options for 6lopan configuration */ +/* Options for 6lowpan configuration */ -struct AdvLowpanCo { +struct AdvLowpanCtx {uint8_t ContextLength;uint8_t ContextCompressionFlag;uint8_t AdvContextID;uint16_t AdvLifeTime;struct in6_addr AdvContextPrefix; +int active; +}; + +struct AdvLowpanCo { +struct AdvLowpanCtx table[MAX_CIDLen];struct AdvLowpanCo *next; };
@@ -242,9 +249,17 @@ struct nd_opt_6co {uint8_t nd_opt_6co_type;uint8_t nd_opt_6co_len;uint8_t nd_opt_6co_context_len; +#if __BYTE_ORDER == __LITTLE_ENDIAN + uint8_t nd_opt_6co_cid:4; + uint8_t nd_opt_6co_c:1; + uint8_t nd_opt_6co_res:3; +#elif __BYTE_ORDER == __BIG_ENDIAN uint8_t nd_opt_6co_res:3; uint8_t nd_opt_6co_c:1; uint8_t nd_opt_6co_cid:4; +#else +#error "no byte order specified!" +#endif uint16_t nd_opt_6co_reserved;uint16_t nd_opt_6co_valid_lifetime;struct in6_addr nd_opt_6co_con_prefix;
@@ -269,6 +284,7 @@ int set_interface_curhlim(const char *, uint8_t);int set_interface_linkmtu (const char *,uint32_t );int set_interface_reachtime (const char *,uint32_t );int set_interface_retranstimer (const char *,uint32_t ); +int set_interface_6ctx (const struct Interface *iface,struct AdvLowpanCtx ctx);int setup_allrouters_membership (int sock,struct Interface *);int setup_linklocal_addr (struct Interface *);int setup_linklocal_addr (struct Interface *iface);
@@ -321,6 +337,7 @@ int privsep_interface_curhlim(const char *iface, uint32_t hlim);int privsep_interface_linkmtu (const char *iface,uint32_t mtu);int privsep_interface_reachtime (const char *iface,uint32_t rtime);int privsep_interface_retranstimer (const char *iface,uint32_t rettimer); +int privsep_interface_6ctx (const char *iface,struct AdvLowpanCtx ctx);void privsep_init (int );void privsep_set_write_fd (int );
scanner.l +3 -1
@@ -49,6 +49,7 @@ RDNSS { return T_RDNSS; } DNSSL { return T_DNSSL; } clients { return T_CLIENTS; } lowpanco { return T_LOWPANCO; } +ctx { return T_CTX; } abro { return T_ABRO; } IgnoreIfMissing { return T_IgnoreIfMissing; }
@@ -100,9 +101,10 @@ MinDelayBetweenRAs { return T_MinDelayBetweenRAs; } AdvMobRtrSupportFlag { return T_AdvMobRtrSupportFlag; } +Adv6LBR { return T_Adv6LBR; } + AdvContextLength { return T_AdvContextLength; } AdvContextCompressionFlag { return T_AdvContextCompressionFlag; } -AdvContextID { return T_AdvContextID; } AdvLifeTime { return T_AdvLifeTime; } AdvContextPrefix { return T_AdvContextPrefix; }
send.c +24 -9
@@ -543,18 +543,33 @@ static void add_mipv6_home_agent_info(struct safe_buffer * sb, struct mipv6 consstatic void add_lowpanco (struct safe_buffer * sb,struct AdvLowpanCo const *lowpanco) {struct nd_opt_6co co; +size_t nd_opt_6co_size; -memset (&co,0 ,sizeof (co)); +for (int i =0 ; i < MAX_CIDLen; i++) { +struct AdvLowpanCtx const *ctx = &lowpanco->table[i]; - co.nd_opt_6co_type =ND_OPT_6CO ; - co.nd_opt_6co_len =3 ; - co.nd_opt_6co_context_len = lowpanco->ContextLength; - co.nd_opt_6co_c = lowpanco->ContextCompressionFlag; - co.nd_opt_6co_cid = lowpanco->AdvContextID; - co.nd_opt_6co_valid_lifetime = lowpanco->AdvLifeTime; - co.nd_opt_6co_con_prefix = lowpanco->AdvContextPrefix; +if (!ctx->active) +continue ; + +memset (&co,0 ,sizeof (co)); -safe_buffer_append (sb, &co,sizeof (co)); + co.nd_opt_6co_type =ND_OPT_6CO ; + co.nd_opt_6co_context_len = ctx->ContextLength; +if (co.nd_opt_6co_context_len >64 ) { + co.nd_opt_6co_len =3 ; + nd_opt_6co_size =sizeof (co); + }else { + co.nd_opt_6co_len =2 ; + nd_opt_6co_size =sizeof (co) -8 ; + } + co.nd_opt_6co_c = ctx->ContextCompressionFlag; + co.nd_opt_6co_cid = ctx->AdvContextID; + co.nd_opt_6co_valid_lifetime = ctx->AdvLifeTime; + co.nd_opt_6co_con_prefix = ctx->AdvContextPrefix; + +safe_buffer_append (sb, &co, nd_opt_6co_size); + + } }static void add_abro (struct safe_buffer * sb,struct AdvAbro const *abroo)
Signature · 1 line
2.6.1