6lowpan: introduce 6lowpan-nd
Subsystems (6)
v4 cover 6lowpan: introduce 6lowpan-nd
Hi,
David can you please pick-up this patch-serie for your net-next tree? Thanks in advance.
This patch series introduces the ndisc ops callback structure to add different handling for IPv6 neighbour discovery cache functionality. It implements at first the two following use-cases:
- 6CO handling as userspace option (For all 6LoWPAN layers, BTLE/802.15.4) [0]
- short address handling for 802.15.4 6LoWPAN only [1]
Since my last patch series, I completely changed the whole ndisc_ops callback structure to not replace the whole ndisc functionality at recv/send level of NS/NA/RS/RA which I send in my previous patch-series "6lowpan: introduce basic 6lowpan-nd". I changed it now to add different handling in a very low-level way of ndisc functionality.
The ndisc_ops don't must be registered to dev->ndisc_ops anymore, if they are not set, then no additional ipv6 ndisc handling will be done.
This patch series now introduce a complete handling of short address for 802.15.4 6LoWPAN in case of send/recv of NA/NS/RS and RA. In case of RA (receive only) and PIO we also need a second prefix + short-address based address.
This callback structure can be used later (I hope) for RFC 6775 [0]. This RFC defines some new option fields and messages for 6LoWPAN-ND. This patch series does not implement RFC 6775 (except we decide now to handle 6CO in userspace).
Additional we can use the current ops for parse/fill ndisc options for kernel handled ndisc messages to add 6CIO, see [2].
I tested RA/NS/NA/RS messages with short address which seems to work, what I didn't test is the redirect messages since I don't know how to generate them. The short address for redirect messages are also some special case here, because the short address by a L3 target address lookuped by neighbour cache need to be added.
btw:
According to [3] sending redirect messages should be also disabled by default on 6lowpan interfaces, but can be activated afterwards. This is maybe something for the ipv6_devconf structure. There is a "accept_redirects" but no "disable_redirects".
- Alex
[0] https://tools.ietf.org/html/rfc6775
[1] https://tools.ietf.org/html/rfc4944#section-8
[2] https://tools.ietf.org/html/rfc7400
changes since v3:
- add acked-by and reviewed-by tags
- fix url references in cover-letter
- add cover-letter that this patch series is okay to go through net-next tree
changes since RFC:
- add lowlevel functions __ndisc_opt_addr_space, __ndisc_opt_addr_data and __ndisc_fill_addr_option for corresponding functions which doesn't requires net_device argument.
- move ndisc_ops e.g. ndisc_ops_fill_addr_option function call into the corresponding device argument function ndisc_fill_addr_option. (Introduced a special static inline function for redirect handling).
- fix error handling in addrconf_prefix_rcv_add_addr.
(Please see, introduce new API handling that second address registration
(in case of 802.15.4 6LoWPAN) will still be notified if failed, because dev->addr was successful.
- add ieee802154 sub-directory in short address entry for 6lowpan UAPI.
- add lowpan_802154_is_valid_src_short_addr, because 802.15.4 6lowpan defines the first bit as multicast (don't know how this can be working at the end, because some hardware addresses will handle such addresses in L2 as unicast. See:
https://www.iana.org/assignments/_6lowpan-parameters/_6lowpan-parameters.xhtml#_6lowpan-parameters-2
changes since v2:
- Introduce ndisc_ops to have our own implementation for dealing with NS/NA which allows also to support RFC6775 (e.g. ARO).
- add handling for handling 6CO as userspace option for RA messages in case of 6LoWPAN interfaces.
- change lowpan_is_ll to check on linklayer type only.
- added some reviewed-by's.
- move short addr slaac to net/6lowpan instead ipv6 handling.
- add handling for context based address compression in case for short address as link-layer address.
- change strategy to use short address, a short address will always be used when it's available.
- Handle override flag in NA messages to update short address information or not.
Alexander Aring (12):
6lowpan: add private neighbour data
6lowpan: add 802.15.4 short addr slaac 6lowpan: remove ipv6 module request
ndisc: add __ndisc_opt_addr_space function
ndisc: add __ndisc_opt_addr_data function
ndisc: add __ndisc_fill_addr_option function
addrconf: put prefix address add in an own function
ipv6: introduce neighbour discovery ops
ipv6: export several functions
6lowpan: introduce 6lowpan-nd
6lowpan: add support for getting short address 6lowpan: add support for 802.15.4 short addr handling
include/linux/netdevice.h | 8 +- include/net/6lowpan.h | 16 +++ include/net/addrconf.h | 10 ++ include/net/ndisc.h | 248 +++++++++++++++++++++++++++++++++++++++--- net/6lowpan/6lowpan_i.h | 4 + net/6lowpan/Makefile | 2 +- net/6lowpan/core.c | 50 ++++++++- net/6lowpan/debugfs.c | 39 +++++++ net/6lowpan/iphc.c | 167 +++++++++++++++++++++++----- net/6lowpan/ndisc.c | 234 +++++++++++++++++++++++++++++++++++++++ net/ieee802154/6lowpan/core.c | 12 ++ net/ieee802154/6lowpan/tx.c | 113 +++++++++---------- net/ipv6/addrconf.c | 218 +++++++++++++++++++++---------------- net/ipv6/ndisc.c | 123 +++++++++++++-------- net/ipv6/route.c | 8 +- 15 files changed, 1004 insertions(+), 248 deletions(-) create mode 100644 net/6lowpan/ndisc.c
Signature · 1 line
2.8.3
A message that is not in the archive (sent off-list or not yet received): 20160615192027.4064-1-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
PATCH v4 1/12 6lowpan: add private neighbour data
This patch will introduce a 6lowpan neighbour private data. Like the interface private data we handle private data for generic 6lowpan and for link-layer specific 6lowpan.
The current first use case if to save the short address for a 802.15.4 6lowpan neighbour.
--- include/linux/netdevice.h | 3 +-- include/net/6lowpan.h | 10 ++++++++++ net/ieee802154/6lowpan/core.c | 12 ++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-)
include/linux/netdevice.h +1 -2
@@ -1483,8 +1483,7 @@ enum netdev_priv_flags {* @perm_addr: Permanent hw address * @addr_assign_type: Hw address assignment type * @addr_len: Hardware address length -* @neigh_priv_len; Used in neigh_alloc(), -* initialized only in atm/clip.c +* @neigh_priv_len: Used in neigh_alloc() * @dev_id: Used to differentiate devices that share * the same link layer address * @dev_port: Used to differentiate devices that share
include/net/6lowpan.h +10 -0
@@ -141,6 +141,16 @@ struct lowpan_dev {u8 priv[0 ]__aligned(sizeof(void *)) ; }; +struct lowpan_802154_neigh { +__le16 short_addr; +}; + +static inline +struct lowpan_802154_neigh *lowpan_802154_neigh (void *neigh_priv) +{ +return neigh_priv; +} +static inline struct lowpan_dev *lowpan_dev (const struct net_device *dev) {
net/ieee802154/6lowpan/core.c +12 -0
@@ -81,11 +81,21 @@ static int lowpan_stop(struct net_device *dev)return 0 ; } +static int lowpan_neigh_construct (struct neighbour *n) +{ +struct lowpan_802154_neigh *neigh =lowpan_802154_neigh (neighbour_priv (n)); + +/* default no short_addr is available for a neighbour */ + neigh->short_addr =cpu_to_le16 (IEEE802154_ADDR_SHORT_UNSPEC ); +return 0 ; +} +static const struct net_device_ops lowpan_netdev_ops = { .ndo_init = lowpan_dev_init, .ndo_start_xmit = lowpan_xmit, .ndo_open = lowpan_open, .ndo_stop = lowpan_stop, + .ndo_neigh_construct = lowpan_neigh_construct, };static void lowpan_setup (struct net_device *ldev)
@@ -150,6 +160,8 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev, wdev->needed_headroom; ldev->needed_tailroom = wdev->needed_tailroom; + ldev->neigh_priv_len =sizeof (struct lowpan_802154_neigh ); + ret =lowpan_register_netdevice (ldev,LOWPAN_LLTYPE_IEEE802154 );if (ret <0 ) {dev_put (wdev);
Signature · 1 line
2.8.3
PATCH v4 4/12 ndisc: add __ndisc_opt_addr_space function
In reply to a message not in the archiveThis patch adds __ndisc_opt_addr_space as low-level function for ndisc_opt_addr_space which doesn't depend on net_device parameter.
--- include/net/ndisc.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
include/net/ndisc.h +7 -2
@@ -127,10 +127,15 @@ static inline int ndisc_addr_option_pad(unsigned short type) } } +static inline int __ndisc_opt_addr_space (unsigned char addr_len,int pad) +{ +return NDISC_OPT_SPACE (addr_len + pad); +} +static inline int ndisc_opt_addr_space (struct net_device *dev) { -return NDISC_OPT_SPACE (dev->addr_len + -ndisc_addr_option_pad (dev->type)); +return __ndisc_opt_addr_space (dev->addr_len, +ndisc_addr_option_pad (dev->type)); } static inline u8 *ndisc_opt_addr_data(struct nd_opt_hdr *p,
Signature · 1 line
2.8.3
A message that is not in the archive (sent off-list or not yet received): 20160615192027.4064-5-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Hannes Frederic Sowa
Acked-byRe: [PATCHv4 net-next 04/12] ndisc: add __ndisc_opt_addr_space function
Quoted 11 lines · Alexander Aring
This patch adds
__ndisc_opt_addr_spaceas low-level function forndisc_opt_addr_spacewhich doesn't depend onnet_deviceparameter.Cc David S. Miller <[email protected]>Cc Alexey Kuznetsov <[email protected]>Cc James Morris <[email protected]>Cc Hideaki YOSHIFUJI <[email protected]>Cc Patrick McHardy <[email protected]>Reviewed-by Stefan Schmidt <[email protected]>Signed-off-by Alexander Aring <[email protected]>
[note, patchworks picks up the acks automatically, you don't need to repost]
Thanks,
Hannes
PATCH v4 5/12 ndisc: add __ndisc_opt_addr_data function
In reply to a message not in the archiveThis patch adds __ndisc_opt_addr_data as low-level function for ndisc_opt_addr_data which doesn't depend on net_device parameter.
--- include/net/ndisc.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
include/net/ndisc.h +10 -4
@@ -138,17 +138,23 @@ static inline int ndisc_opt_addr_space(struct net_device *dev) ndisc_addr_option_pad(dev->type)); } -static inline u8 *ndisc_opt_addr_data (struct nd_opt_hdr *p, -struct net_device *dev) +static inline u8 *__ndisc_opt_addr_data (struct nd_opt_hdr *p, +unsigned char addr_len,int prepad) {u8 *lladdr = (u8 *)(p +1 );int lladdrlen = p->nd_opt_len <<3 ; -int prepad =ndisc_addr_option_pad (dev->type); -if (lladdrlen !=ndisc_opt_addr_space (dev)) +if (lladdrlen !=__ndisc_opt_addr_space (addr_len, prepad))return NULL ;return lladdr + prepad; } +static inline u8 *ndisc_opt_addr_data (struct nd_opt_hdr *p, +struct net_device *dev) +{ +return __ndisc_opt_addr_data (p, dev->addr_len, +ndisc_addr_option_pad (dev->type)); +} +static inline u32 ndisc_hashfn (const void *pkey,const struct net_device *dev,__u32 *hash_rnd) {const u32 *p32 = pkey;
Signature · 1 line
2.8.3
A message that is not in the archive (sent off-list or not yet received): 20160615192027.4064-6-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Hannes Frederic Sowa
Acked-byRe: [PATCHv4 net-next 05/12] ndisc: add __ndisc_opt_addr_data function
Quoted 11 lines · Alexander Aring
This patch adds
__ndisc_opt_addr_dataas low-level function forndisc_opt_addr_datawhich doesn't depend onnet_deviceparameter.Cc David S. Miller <[email protected]>Cc Alexey Kuznetsov <[email protected]>Cc James Morris <[email protected]>Cc Hideaki YOSHIFUJI <[email protected]>Cc Patrick McHardy <[email protected]>Reviewed-by Stefan Schmidt <[email protected]>Signed-off-by Alexander Aring <[email protected]>
PATCH v4 8/12 ipv6: introduce neighbour discovery ops
In reply to a message not in the archiveThis patch introduces neighbour discovery ops callback structure. The idea is to separate the handling for 6LoWPAN into the 6lowpan module.
These callback offers 6lowpan different handling, such as 802.15.4 short address handling or RFC6775 (Neighbor Discovery Optimization for IPv6 over 6LoWPANs).
--- include/linux/netdevice.h | 5 ++ include/net/ndisc.h | 197 +++++++++++++++++++++++++++++++++++++++++++++- net/ipv6/addrconf.c | 13 ++- net/ipv6/ndisc.c | 101 ++++++++++++++++-------- net/ipv6/route.c | 8 +- 5 files changed, 284 insertions(+), 40 deletions(-)
include/linux/netdevice.h +5 -0
@@ -1456,6 +1456,8 @@ enum netdev_priv_flags {* @netdev_ops: Includes several pointers to callbacks, * if one wants to override the ndo_*() functions * @ethtool_ops: Management operations +* @ndisc_ops: Includes callbacks for different IPv6 neighbour +* discovery handling. Necessary for e.g. 6LoWPAN. * @header_ops: Includes callbacks for creating,parsing,caching,etc * of Layer 2 headers. *
@@ -1672,6 +1674,9 @@ struct net_device {#ifdef CONFIG_NET_L3_MASTER_DEV const struct l3mdev_ops *l3mdev_ops;#endif +#if IS_ENABLED (CONFIG_IPV6 ) +const struct ndisc_ops *ndisc_ops; +#endif const struct header_ops *header_ops;
include/net/ndisc.h +194 -3
226 lines not on this page · raw message
net/ipv6/addrconf.c +12 -1
@@ -2531,7 +2531,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)if (pinfo->autoconf && in6_dev->cnf.autoconf) {struct in6_addr addr; -bool tokenized = false; +bool tokenized = false, dev_addr_generated = false;if (pinfo->prefix_len ==64 ) {memcpy (&addr, &pinfo->prefix,8 );
@@ -2550,6 +2550,8 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao) }else if (ipv6_generate_eui64 (addr.s6_addr +8 , dev) &&ipv6_inherit_eui64 (addr.s6_addr +8 , in6_dev)) { goto put; + }else { + dev_addr_generated = true; } goto ok; }
@@ -2565,6 +2567,15 @@ ok: prefered_lft);if (err) goto put; + +/* Ignore error case here because previous prefix add addr was +* successful which will be notified. +*/ +ndisc_ops_prefix_rcv_add_addr (net, dev, pinfo, in6_dev, &addr, + addr_type, addr_flags, sllao, + tokenized, valid_lft, + prefered_lft, + dev_addr_generated); }inet6_prefix_notify (RTM_NEWPREFIX , in6_dev, pinfo); put:
net/ipv6/ndisc.c +69 -32
276 lines not on this page · raw message
net/ipv6/route.c +4 -4
@@ -2200,7 +2200,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu* first-hop router for the specified ICMP Destination Address. */ -if (!ndisc_parse_options (msg->opt, optlen, &ndopts)) { +if (!ndisc_parse_options (skb->dev, msg->opt, optlen, &ndopts)) {net_dbg_ratelimited ("rt6_redirect: invalid ND options\n" );return ; }
@@ -2235,12 +2235,12 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu* We have finally decided to accept it. */ -neigh_update (neigh, lladdr,NUD_STALE , +ndisc_update (skb->dev, neigh, lladdr,NUD_STALE ,NEIGH_UPDATE_F_WEAK_OVERRIDE |NEIGH_UPDATE_F_OVERRIDE | (on_link ?0 : (NEIGH_UPDATE_F_OVERRIDE_ISROUTER | -NEIGH_UPDATE_F_ISROUTER )) - ); +NEIGH_UPDATE_F_ISROUTER )), +NDISC_REDIRECT , &ndopts); nrt =ip6_rt_cache_alloc (rt, &msg->dest,NULL );if (!nrt)
Signature · 1 line
2.8.3
PATCH v4 9/12 ipv6: export several functions
In reply to a message not in the archiveThis patch exports some neighbour discovery functions which can be used by 6lowpan neighbour discovery ops functionality then.
--- include/net/addrconf.h | 7 +++++++ include/net/ndisc.h | 12 ++++++++++++ net/ipv6/addrconf.c | 15 +++++++-------- net/ipv6/ndisc.c | 14 +++----------- 4 files changed, 29 insertions(+), 19 deletions(-)
include/net/addrconf.h +7 -0
@@ -97,6 +97,13 @@ void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr);void addrconf_add_linklocal (struct inet6_dev *idev,const struct in6_addr *addr,u32 flags); +int addrconf_prefix_rcv_add_addr (struct net *net,struct net_device *dev, +const struct prefix_info *pinfo, +struct inet6_dev *in6_dev, +const struct in6_addr *addr,int addr_type, +u32 addr_flags,bool sllao,bool tokenized, +__u32 valid_lft,u32 prefered_lft); +static inline int addrconf_ifid_eui48 (u8 *eui,struct net_device *dev) {if (dev->addr_len !=ETH_ALEN )
include/net/ndisc.h +12 -0
@@ -53,6 +53,15 @@ enum {#include <net/neighbour.h> +/* Set to 3 to get tracing... */ +#define ND_DEBUG 1 + +#define ND_PRINTK (val, level, fmt, ...) \ +do { \ + if (val <= ND_DEBUG) \ + net_##level##_ratelimited(fmt, ##__VA_ARGS__); \ +} while (0) +struct ctl_table ;struct inet6_dev ;struct net_device ;
@@ -115,6 +124,9 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev, u8 *opt, int opt_len, struct ndisc_options *ndopts); +void __ndisc_fill_addr_option (struct sk_buff *skb,int type,void *data, +int data_len,int pad); +#define NDISC_OPS_REDIRECT_DATA_SPACE 2/*
net/ipv6/addrconf.c +7 -8
@@ -2333,14 +2333,12 @@ static bool is_addr_mode_generate_stable(struct inet6_dev *idev) idev->addr_gen_mode ==IN6_ADDR_GEN_MODE_RANDOM ; } -static int addrconf_prefix_rcv_add_addr (struct net *net, -struct net_device *dev, -const struct prefix_info *pinfo, -struct inet6_dev *in6_dev, -const struct in6_addr *addr, -int addr_type,u32 addr_flags, -bool sllao,bool tokenized, -__u32 valid_lft,u32 prefered_lft) +int addrconf_prefix_rcv_add_addr (struct net *net,struct net_device *dev, +const struct prefix_info *pinfo, +struct inet6_dev *in6_dev, +const struct in6_addr *addr,int addr_type, +u32 addr_flags,bool sllao,bool tokenized, +__u32 valid_lft,u32 prefered_lft) {struct inet6_ifaddr *ifp =ipv6_get_ifaddr (net, addr, dev,1 );int create =0 , update_lft =0 ;
@@ -2430,6 +2428,7 @@ static int addrconf_prefix_rcv_add_addr(struct net *net,return 0 ; } +EXPORT_SYMBOL_GPL (addrconf_prefix_rcv_add_addr);void addrconf_prefix_rcv (struct net_device *dev,u8 *opt,int len,bool sllao) {
net/ipv6/ndisc.c +3 -11
@@ -73,15 +73,6 @@#include <linux/netfilter.h> #include <linux/netfilter_ipv6.h> -/* Set to 3 to get tracing... */ -#define ND_DEBUG 1 - -#define ND_PRINTK (val, level, fmt, ...) \ -do { \ - if (val <= ND_DEBUG) \ - net_##level##_ratelimited(fmt, ##__VA_ARGS__); \ -} while (0) -static u32 ndisc_hash (const void *pkey,const struct net_device *dev,__u32 *hash_rnd);
@@ -150,8 +141,8 @@ struct neigh_table nd_tbl = { };EXPORT_SYMBOL_GPL (nd_tbl); -static void __ndisc_fill_addr_option (struct sk_buff *skb,int type,void *data, -int data_len,int pad) +void __ndisc_fill_addr_option (struct sk_buff *skb,int type,void *data, +int data_len,int pad) {int space =__ndisc_opt_addr_space (data_len, pad);u8 *opt =skb_put (skb, space);
@@ -170,6 +161,7 @@ static void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,if (space >0 )memset (opt,0 , space); } +EXPORT_SYMBOL_GPL (__ndisc_fill_addr_option);static inline void ndisc_fill_addr_option (struct sk_buff *skb,int type,void *data,u8 icmp6_type)
Signature · 1 line
2.8.3
PATCH v4 2/12 6lowpan: add 802.15.4 short addr slaac
In reply to Alexander AringThis patch adds the autoconfiguration if a valid 802.15.4 short address is available for 802.15.4 6LoWPAN interfaces.
--- include/net/6lowpan.h | 6 ++++++ include/net/addrconf.h | 3 +++ net/6lowpan/core.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ net/ipv6/addrconf.c | 5 +++-- 4 files changed, 58 insertions(+), 2 deletions(-)
include/net/6lowpan.h +6 -0
@@ -254,6 +254,12 @@ static inline bool lowpan_fetch_skb(struct sk_buff *skb, void *data,return false; } +static inline bool lowpan_802154_is_valid_src_short_addr (__le16 addr) +{ +/* First bit of addr is multicast, reserved or 802.15.4 specific */ +return !(addr &cpu_to_le16 (0x8000 )); +} +static inline void lowpan_push_hc_data (u8 **hc_ptr,const void *data,const size_t len) {
include/net/addrconf.h +3 -0
@@ -94,6 +94,9 @@ int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2,void addrconf_join_solict (struct net_device *dev,const struct in6_addr *addr);void addrconf_leave_solict (struct inet6_dev *idev,const struct in6_addr *addr); +void addrconf_add_linklocal (struct inet6_dev *idev, +const struct in6_addr *addr,u32 flags); +static inline int addrconf_ifid_eui48 (u8 *eui,struct net_device *dev) {if (dev->addr_len !=ETH_ALEN )
net/6lowpan/core.c +46 -0
68 lines not on this page · raw message
net/ipv6/addrconf.c +3 -2
@@ -2947,8 +2947,8 @@ static void init_loopback(struct net_device *dev) } } -static void addrconf_add_linklocal (struct inet6_dev *idev, -const struct in6_addr *addr,u32 flags) +void addrconf_add_linklocal (struct inet6_dev *idev, +const struct in6_addr *addr,u32 flags) {struct inet6_ifaddr *ifp;u32 addr_flags = flags |IFA_F_PERMANENT ;
@@ -2967,6 +2967,7 @@ static void addrconf_add_linklocal(struct inet6_dev *idev,in6_ifa_put (ifp); } } +EXPORT_SYMBOL_GPL (addrconf_add_linklocal);static bool ipv6_reserved_interfaceid (struct in6_addr address) {
Signature · 1 line
2.8.3
PATCH v4 3/12 6lowpan: remove ipv6 module request
In reply to Alexander AringSince we use exported function from ipv6 kernel module we don't need to request the module anymore to have ipv6 functionality.
--- net/6lowpan/core.c | 2 -- 1 file changed, 2 deletions(-)
net/6lowpan/core.c +0 -2
@@ -158,8 +158,6 @@ static int __init lowpan_module_init(void)return ret; } -request_module_nowait ("ipv6" ); -request_module_nowait ("nhc_dest" );request_module_nowait ("nhc_fragment" );request_module_nowait ("nhc_hop" );
Signature · 1 line
2.8.3
PATCH v4 6/12 ndisc: add __ndisc_fill_addr_option function
In reply to Alexander AringThis patch adds __ndisc_fill_addr_option as low-level function for ndisc_fill_addr_option which doesn't depend on net_device parameter.
--- net/ipv6/ndisc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/ipv6/ndisc.c +10 -4
@@ -150,11 +150,10 @@ struct neigh_table nd_tbl = { };EXPORT_SYMBOL_GPL (nd_tbl); -static void ndisc_fill_addr_option (struct sk_buff *skb,int type,void *data) +static void __ndisc_fill_addr_option (struct sk_buff *skb,int type,void *data, +int data_len,int pad) { -int pad =ndisc_addr_option_pad (skb->dev->type); -int data_len = skb->dev->addr_len; -int space =ndisc_opt_addr_space (skb->dev); +int space =__ndisc_opt_addr_space (data_len, pad);u8 *opt =skb_put (skb, space); opt[0 ] = type;
@@ -172,6 +171,13 @@ static void ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data)memset (opt,0 , space); } +static inline void ndisc_fill_addr_option (struct sk_buff *skb,int type, +void *data) +{ +__ndisc_fill_addr_option (skb, type, data, skb->dev->addr_len, +ndisc_addr_option_pad (skb->dev->type)); +} +static struct nd_opt_hdr *ndisc_next_option (struct nd_opt_hdr *cur,struct nd_opt_hdr *end) {
Signature · 1 line
2.8.3
A message that is not in the archive (sent off-list or not yet received): 20160615192027.4064-7-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Hannes Frederic Sowa
Acked-byRe: [PATCHv4 net-next 06/12] ndisc: add __ndisc_fill_addr_option function
Quoted 11 lines · Alexander Aring
This patch adds
__ndisc_fill_addr_optionas low-level function forndisc_fill_addr_optionwhich doesn't depend onnet_deviceparameter.Cc David S. Miller <[email protected]>Cc Alexey Kuznetsov <[email protected]>Cc James Morris <[email protected]>Cc Hideaki YOSHIFUJI <[email protected]>Cc Patrick McHardy <[email protected]>Reviewed-by Stefan Schmidt <[email protected]>Signed-off-by Alexander Aring <[email protected]>
PATCH v4 7/12 addrconf: put prefix address add in an own function
In reply to Alexander AringThis patch moves the functionality to add a RA PIO prefix generated address in an own function. This move prepares to add a hook for adding a second address for a second link-layer address. E.g. short address for 802.15.4 6LoWPAN.
--- net/ipv6/addrconf.c | 203 ++++++++++++++++++++++++++++------------------------ 1 file changed, 109 insertions(+), 94 deletions(-)
net/ipv6/addrconf.c +109 -94
@@ -2333,12 +2333,110 @@ static bool is_addr_mode_generate_stable(struct inet6_dev *idev) idev->addr_gen_mode ==IN6_ADDR_GEN_MODE_RANDOM ; } +static int addrconf_prefix_rcv_add_addr (struct net *net, +struct net_device *dev, +const struct prefix_info *pinfo, +struct inet6_dev *in6_dev, +const struct in6_addr *addr, +int addr_type,u32 addr_flags, +bool sllao,bool tokenized, +__u32 valid_lft,u32 prefered_lft) +{ +struct inet6_ifaddr *ifp =ipv6_get_ifaddr (net, addr, dev,1 ); +int create =0 , update_lft =0 ; + +if (!ifp && valid_lft) { +int max_addresses = in6_dev->cnf.max_addresses; + +#ifdef CONFIG_IPV6_OPTIMISTIC_DAD +if (in6_dev->cnf.optimistic_dad && + !net->ipv6.devconf_all->forwarding && sllao) + addr_flags |=IFA_F_OPTIMISTIC ; +#endif + +/* Do not allow to create too much of autoconfigured +* addresses; this would be too easy way to crash kernel. +*/ +if (!max_addresses || +ipv6_count_addresses (in6_dev) < max_addresses) + ifp =ipv6_add_addr (in6_dev, addr,NULL , + pinfo->prefix_len, + addr_type&IPV6_ADDR_SCOPE_MASK , + addr_flags, valid_lft, + prefered_lft); + +if (IS_ERR_OR_NULL (ifp)) +return -1 ; + + update_lft =0 ; + create =1 ; +spin_lock_bh (&ifp->lock); + ifp->flags |=IFA_F_MANAGETEMPADDR ; + ifp->cstamp = jiffies; + ifp->tokenized = tokenized; +spin_unlock_bh (&ifp->lock); +addrconf_dad_start (ifp); + } + +if (ifp) { +u32 flags; +unsigned long now; +u32 stored_lft; + +/* update lifetime (RFC2462 5.5.3 e) */ +spin_lock_bh (&ifp->lock); + now = jiffies; +if (ifp->valid_lft > (now - ifp->tstamp) /HZ ) + stored_lft = ifp->valid_lft - (now - ifp->tstamp) /HZ ; +else + stored_lft =0 ; +if (!update_lft && !create && stored_lft) { +const u32 minimum_lft =min_t (u32, + stored_lft,MIN_VALID_LIFETIME ); + valid_lft =max (valid_lft, minimum_lft); + +/* RFC4862 Section 5.5.3e: +* "Note that the preferred lifetime of the +* corresponding address is always reset to +* the Preferred Lifetime in the received +* Prefix Information option, regardless of +* whether the valid lifetime is also reset or +* ignored." +* +* So we should always update prefered_lft here. +*/ + update_lft =1 ; + } + +if (update_lft) { + ifp->valid_lft = valid_lft; + ifp->prefered_lft = prefered_lft; + ifp->tstamp = now; + flags = ifp->flags; + ifp->flags &= ~IFA_F_DEPRECATED ; +spin_unlock_bh (&ifp->lock); + +if (!(flags&IFA_F_TENTATIVE )) +ipv6_ifa_notify (0 , ifp); + }else +spin_unlock_bh (&ifp->lock); + +manage_tempaddrs (in6_dev, ifp, valid_lft, prefered_lft, + create, now); + +in6_ifa_put (ifp); +addrconf_verify (); + } + +return 0 ; +} +void addrconf_prefix_rcv (struct net_device *dev,u8 *opt,int len,bool sllao) {struct prefix_info *pinfo;__u32 valid_lft;__u32 prefered_lft; -int addr_type; +int addr_type, err;u32 addr_flags =0 ;struct inet6_dev *in6_dev;struct net *net =dev_net (dev);
@@ -2432,9 +2530,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)/* Try to figure out our local address for this prefix */ if (pinfo->autoconf && in6_dev->cnf.autoconf) { -struct inet6_ifaddr *ifp;struct in6_addr addr; -int create =0 , update_lft =0 ;bool tokenized = false;if (pinfo->prefix_len ==64 ) {
@@ -2453,106 +2549,25 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao) goto ok; }else if (ipv6_generate_eui64 (addr.s6_addr +8 , dev) &&ipv6_inherit_eui64 (addr.s6_addr +8 , in6_dev)) { -in6_dev_put (in6_dev); -return ; + goto put; } goto ok; }net_dbg_ratelimited ("IPv6 addrconf: prefix with wrong length %d\n" , pinfo->prefix_len); -in6_dev_put (in6_dev); -return ; + goto put; ok: - - ifp =ipv6_get_ifaddr (net, &addr, dev,1 ); - -if (!ifp && valid_lft) { -int max_addresses = in6_dev->cnf.max_addresses; - -#ifdef CONFIG_IPV6_OPTIMISTIC_DAD -if (in6_dev->cnf.optimistic_dad && - !net->ipv6.devconf_all->forwarding && sllao) - addr_flags |=IFA_F_OPTIMISTIC ; -#endif - -/* Do not allow to create too much of autoconfigured -* addresses; this would be too easy way to crash kernel. -*/ -if (!max_addresses || -ipv6_count_addresses (in6_dev) < max_addresses) - ifp =ipv6_add_addr (in6_dev, &addr,NULL , - pinfo->prefix_len, - addr_type&IPV6_ADDR_SCOPE_MASK , - addr_flags, valid_lft, - prefered_lft); - -if (IS_ERR_OR_NULL (ifp)) { -in6_dev_put (in6_dev); -return ; - } - - update_lft =0 ; - create =1 ; -spin_lock_bh (&ifp->lock); - ifp->flags |=IFA_F_MANAGETEMPADDR ; - ifp->cstamp = jiffies; - ifp->tokenized = tokenized; -spin_unlock_bh (&ifp->lock); -addrconf_dad_start (ifp); - } - -if (ifp) { -u32 flags; -unsigned long now; -u32 stored_lft; - -/* update lifetime (RFC2462 5.5.3 e) */ -spin_lock_bh (&ifp->lock); - now = jiffies; -if (ifp->valid_lft > (now - ifp->tstamp) /HZ ) - stored_lft = ifp->valid_lft - (now - ifp->tstamp) /HZ ; -else - stored_lft =0 ; -if (!update_lft && !create && stored_lft) { -const u32 minimum_lft =min_t (u32, - stored_lft,MIN_VALID_LIFETIME ); - valid_lft =max (valid_lft, minimum_lft); - -/* RFC4862 Section 5.5.3e: -* "Note that the preferred lifetime of the -* corresponding address is always reset to -* the Preferred Lifetime in the received -* Prefix Information option, regardless of -* whether the valid lifetime is also reset or -* ignored." -* -* So we should always update prefered_lft here. -*/ - update_lft =1 ; - } - -if (update_lft) { - ifp->valid_lft = valid_lft; - ifp->prefered_lft = prefered_lft; - ifp->tstamp = now; - flags = ifp->flags; - ifp->flags &= ~IFA_F_DEPRECATED ; -spin_unlock_bh (&ifp->lock); - -if (!(flags&IFA_F_TENTATIVE )) -ipv6_ifa_notify (0 , ifp); - }else -spin_unlock_bh (&ifp->lock); - -manage_tempaddrs (in6_dev, ifp, valid_lft, prefered_lft, - create, now); - -in6_ifa_put (ifp); -addrconf_verify (); - } + err =addrconf_prefix_rcv_add_addr (net, dev, pinfo, in6_dev, + &addr, addr_type, + addr_flags, sllao, + tokenized, valid_lft, + prefered_lft); +if (err) + goto put; }inet6_prefix_notify (RTM_NEWPREFIX , in6_dev, pinfo); +put:in6_dev_put (in6_dev); }
Signature · 1 line
2.8.3
Re: [PATCHv4 net-next 07/12] addrconf: put prefix address add in an own function
Quoted 5 lines · Alexander Aring
This patch moves the functionality to add a RA PIO prefix generated address in an own function. This move prepares to add a hook for adding a second address for a second link-layer address. E.g. short address for 802.15.4 6LoWPAN.
Quoted 8 lines
Cc David S. Miller <[email protected]>Cc Alexey Kuznetsov <[email protected]>Cc James Morris <[email protected]>Cc Hideaki YOSHIFUJI <[email protected]>Cc Patrick McHardy <[email protected]>Reviewed-by Stefan Schmidt <[email protected]>Signed-off-by Alexander Aring <[email protected]>
Ah, I noticed I am too late for the Acks but go through the rest of the series anyway. :)
PATCH v4 10/12 6lowpan: introduce 6lowpan-nd
In reply to Alexander AringThis patch introduce different 6lowpan handling for receive and transmit NS/NA messages for the ipv6 neighbour discovery. The first use-case is for supporting 802.15.4 short addresses inside the option fields and handling for RFC6775 6CO option field as userspace option.
--- include/net/ndisc.h | 18 ++-- net/6lowpan/6lowpan_i.h | 4 + net/6lowpan/Makefile | 2 +- net/6lowpan/core.c | 4 +- net/6lowpan/ndisc.c | 234 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 254 insertions(+), 8 deletions(-) create mode 100644 net/6lowpan/ndisc.c
include/net/ndisc.h +12 -6
@@ -35,6 +35,7 @@ enum {ND_OPT_ROUTE_INFO =24 ,/* RFC4191 */ ND_OPT_RDNSS =25 ,/* RFC5006 */ ND_OPT_DNSSL =31 ,/* RFC6106 */ +ND_OPT_6CO =34 ,/* RFC6775 */ __ND_OPT_MAX };
@@ -109,14 +110,19 @@ struct ndisc_options {#endif struct nd_opt_hdr *nd_useropts;struct nd_opt_hdr *nd_useropts_end; +#if IS_ENABLED (CONFIG_IEEE802154_6LOWPAN ) +struct nd_opt_hdr *nd_802154_opt_array[ND_OPT_TARGET_LL_ADDR +1 ]; +#endif }; -#define nd_opts_src_lladdr nd_opt_array[ND_OPT_SOURCE_LL_ADDR] -#define nd_opts_tgt_lladdr nd_opt_array[ND_OPT_TARGET_LL_ADDR] -#define nd_opts_pi nd_opt_array[ND_OPT_PREFIX_INFO] -#define nd_opts_pi_end nd_opt_array[__ND_OPT_PREFIX_INFO_END] -#define nd_opts_rh nd_opt_array[ND_OPT_REDIRECT_HDR] -#define nd_opts_mtu nd_opt_array[ND_OPT_MTU] +#define nd_opts_src_lladdr nd_opt_array[ND_OPT_SOURCE_LL_ADDR] +#define nd_opts_tgt_lladdr nd_opt_array[ND_OPT_TARGET_LL_ADDR] +#define nd_opts_pi nd_opt_array[ND_OPT_PREFIX_INFO] +#define nd_opts_pi_end nd_opt_array[__ND_OPT_PREFIX_INFO_END] +#define nd_opts_rh nd_opt_array[ND_OPT_REDIRECT_HDR] +#define nd_opts_mtu nd_opt_array[ND_OPT_MTU] +#define nd_802154_opts_src_lladdr nd_802154_opt_array[ND_OPT_SOURCE_LL_ADDR] +#define nd_802154_opts_tgt_lladdr nd_802154_opt_array[ND_OPT_TARGET_LL_ADDR]#define NDISC_OPT_SPACE (len) (((len)+2+7)&~7)
net/6lowpan/6lowpan_i.h +4 -0
@@ -12,6 +12,10 @@ static inline bool lowpan_is_ll(const struct net_device *dev,return lowpan_dev (dev)->lltype == lltype; } +extern const struct ndisc_ops lowpan_ndisc_ops; + +int addrconf_ifid_802154_6lowpan (u8 *eui,struct net_device *dev); +#ifdef CONFIG_6LOWPAN_DEBUGFS int lowpan_dev_debugfs_init (struct net_device *dev);void lowpan_dev_debugfs_exit (struct net_device *dev);
net/6lowpan/Makefile +1 -1
@@ -1,6 +1,6 @@ obj-$(CONFIG_6LOWPAN) += 6lowpan.o -6lowpan-y := core.o iphc.o nhc.o +6lowpan-y := core.o iphc.o nhc.o ndisc.o 6lowpan-$(CONFIG_6LOWPAN_DEBUGFS) += debugfs.o #rfc6282 nhcs
net/6lowpan/core.c +3 -1
@@ -34,6 +34,8 @@ int lowpan_register_netdevice(struct net_device *dev,for (i =0 ; i <LOWPAN_IPHC_CTX_TABLE_SIZE ; i++)lowpan_dev (dev)->ctx.table[i].id = i; + dev->ndisc_ops = &lowpan_ndisc_ops; + ret =register_netdevice (dev);if (ret <0 )return ret;
@@ -73,7 +75,7 @@ void lowpan_unregister_netdev(struct net_device *dev) }EXPORT_SYMBOL (lowpan_unregister_netdev); -static int addrconf_ifid_802154_6lowpan (u8 *eui,struct net_device *dev) +int addrconf_ifid_802154_6lowpan (u8 *eui,struct net_device *dev) {struct wpan_dev *wpan_dev =lowpan_802154_dev (dev)->wdev->ieee802154_ptr;
net/6lowpan/ndisc.c new file +234 -0
234 lines not on this page · raw message
Signature · 1 line
2.8.3
PATCH v4 11/12 6lowpan: add support for getting short address
In reply to Alexander AringIn case of sending RA messages we need some way to get the short address from an 802.15.4 6LoWPAN interface. This patch will add a temporary debugfs entry for experimental userspace api.
--- net/6lowpan/debugfs.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
net/6lowpan/debugfs.c +39 -0
@@ -245,6 +245,41 @@ static const struct file_operations lowpan_context_fops = { .release = single_release, }; +static int lowpan_short_addr_get (void *data,u64 *val) +{ +struct wpan_dev *wdev = data; + +rtnl_lock (); + *val =le16_to_cpu (wdev->short_addr); +rtnl_unlock (); + +return 0 ; +} + +DEFINE_SIMPLE_ATTRIBUTE (lowpan_short_addr_fops, lowpan_short_addr_get, +NULL ,"0x%04llx\n" ); + +static int lowpan_dev_debugfs_802154_init (const struct net_device *dev, +struct lowpan_dev *ldev) +{ +struct dentry *dentry, *root; + +if (!lowpan_is_ll (dev,LOWPAN_LLTYPE_IEEE802154 )) +return 0 ; + + root =debugfs_create_dir ("ieee802154" , ldev->iface_debugfs); +if (!root) +return -EINVAL ; + + dentry =debugfs_create_file ("short_addr" ,0444 , root, +lowpan_802154_dev (dev)->wdev->ieee802154_ptr, + &lowpan_short_addr_fops); +if (!dentry) +return -EINVAL ; + +return 0 ; +} +int lowpan_dev_debugfs_init (struct net_device *dev) {struct lowpan_dev *ldev =lowpan_dev (dev);
@@ -272,6 +307,10 @@ int lowpan_dev_debugfs_init(struct net_device *dev) goto remove_root; } + ret =lowpan_dev_debugfs_802154_init (dev, ldev); +if (ret <0 ) + goto remove_root; +return 0 ; remove_root:
Signature · 1 line
2.8.3
PATCH v4 12/12 6lowpan: add support for 802.15.4 short addr handling
In reply to Alexander AringThis patch adds necessary handling for use the short address for 802.15.4 6lowpan. It contains support for IPHC address compression and new matching algorithmn to decide which link layer address will be used for 802.15.4 frame.
--- net/6lowpan/iphc.c | 167 ++++++++++++++++++++++++++++++++++++-------- net/ieee802154/6lowpan/tx.c | 113 +++++++++++++++--------------- 2 files changed, 195 insertions(+), 85 deletions(-)
net/6lowpan/iphc.c +138 -29
@@ -761,22 +761,75 @@ static const u8 lowpan_iphc_dam_to_sam_value[] = { [LOWPAN_IPHC_DAM_11] = LOWPAN_IPHC_SAM_11, }; -static u8 lowpan_compress_ctx_addr (u8 **hc_ptr,const struct in6_addr *ipaddr, +static inline bool +lowpan_iphc_compress_ctx_802154_lladdr (const struct in6_addr *ipaddr, +const struct lowpan_iphc_ctx *ctx, +const void *lladdr) +{ +const struct ieee802154_addr *addr = lladdr; +unsigned char extended_addr[EUI64_ADDR_LEN ]; +bool lladdr_compress = false; +struct in6_addr tmp = {}; + +switch (addr->mode) { +case IEEE802154_ADDR_LONG : +ieee802154_le64_to_be64 (&extended_addr, &addr->extended_addr); +/* check for SAM/DAM = 11 */ +memcpy (&tmp.s6_addr[8 ], &extended_addr,EUI64_ADDR_LEN ); +/* second bit-flip (Universe/Local) is done according RFC2464 */ + tmp.s6_addr[8 ] ^=0x02 ; +/* context information are always used */ +ipv6_addr_prefix_copy (&tmp, &ctx->pfx, ctx->plen); +if (ipv6_addr_equal (&tmp, ipaddr)) + lladdr_compress = true; +break ; +case IEEE802154_ADDR_SHORT : + tmp.s6_addr[11 ] =0xFF ; + tmp.s6_addr[12 ] =0xFE ; +ieee802154_le16_to_be16 (&tmp.s6_addr16[7 ], + &addr->short_addr); +/* context information are always used */ +ipv6_addr_prefix_copy (&tmp, &ctx->pfx, ctx->plen); +if (ipv6_addr_equal (&tmp, ipaddr)) + lladdr_compress = true; +break ; +default : +/* should never handled and filtered by 802154 6lowpan */ +WARN_ON_ONCE (1 ); +break ; + } + +return lladdr_compress; +} + +static u8 lowpan_compress_ctx_addr (u8 **hc_ptr,const struct net_device *dev, +const struct in6_addr *ipaddr,const struct lowpan_iphc_ctx *ctx,const unsigned char *lladdr,bool sam) {struct in6_addr tmp = {};u8 dam; -/* check for SAM/DAM = 11 */ -memcpy (&tmp.s6_addr[8 ], lladdr,8 ); -/* second bit-flip (Universe/Local) is done according RFC2464 */ - tmp.s6_addr[8 ] ^=0x02 ; -/* context information are always used */ -ipv6_addr_prefix_copy (&tmp, &ctx->pfx, ctx->plen); -if (ipv6_addr_equal (&tmp, ipaddr)) { - dam =LOWPAN_IPHC_DAM_11 ; - goto out; +switch (lowpan_dev (dev)->lltype) { +case LOWPAN_LLTYPE_IEEE802154 : +if (lowpan_iphc_compress_ctx_802154_lladdr (ipaddr, ctx, + lladdr)) { + dam =LOWPAN_IPHC_DAM_11 ; + goto out; + } +break ; +default : +/* check for SAM/DAM = 11 */ +memcpy (&tmp.s6_addr[8 ], lladdr,EUI64_ADDR_LEN ); +/* second bit-flip (Universe/Local) is done according RFC2464 */ + tmp.s6_addr[8 ] ^=0x02 ; +/* context information are always used */ +ipv6_addr_prefix_copy (&tmp, &ctx->pfx, ctx->plen); +if (ipv6_addr_equal (&tmp, ipaddr)) { + dam =LOWPAN_IPHC_DAM_11 ; + goto out; + } +break ; }memset (&tmp,0 ,sizeof (tmp));
@@ -813,28 +866,85 @@ out:return dam; } -static u8 lowpan_compress_addr_64 (u8 **hc_ptr,const struct in6_addr *ipaddr, +static inline bool +lowpan_iphc_compress_802154_lladdr (const struct in6_addr *ipaddr, +const void *lladdr) +{ +const struct ieee802154_addr *addr = lladdr; +unsigned char extended_addr[EUI64_ADDR_LEN ]; +bool lladdr_compress = false; +struct in6_addr tmp = {}; + +switch (addr->mode) { +case IEEE802154_ADDR_LONG : +ieee802154_le64_to_be64 (&extended_addr, &addr->extended_addr); +if (is_addr_mac_addr_based (ipaddr, extended_addr)) + lladdr_compress = true; +break ; +case IEEE802154_ADDR_SHORT : +/* fe:80::ff:fe00:XXXX +* \__/ +* short_addr +* +* Universe/Local bit is zero. +*/ + tmp.s6_addr[0 ] =0xFE ; + tmp.s6_addr[1 ] =0x80 ; + tmp.s6_addr[11 ] =0xFF ; + tmp.s6_addr[12 ] =0xFE ; +ieee802154_le16_to_be16 (&tmp.s6_addr16[7 ], + &addr->short_addr); +if (ipv6_addr_equal (&tmp, ipaddr)) + lladdr_compress = true; +break ; +default : +/* should never handled and filtered by 802154 6lowpan */ +WARN_ON_ONCE (1 ); +break ; + } + +return lladdr_compress; +} + +static u8 lowpan_compress_addr_64 (u8 **hc_ptr,const struct net_device *dev, +const struct in6_addr *ipaddr,const unsigned char *lladdr,bool sam) { -u8 dam =LOWPAN_IPHC_DAM_00 ; +u8 dam =LOWPAN_IPHC_DAM_01 ; -if (is_addr_mac_addr_based (ipaddr, lladdr)) { - dam =LOWPAN_IPHC_DAM_11 ;/* 0-bits */ -pr_debug ("address compression 0 bits\n" ); - }else if (lowpan_is_iid_16_bit_compressable (ipaddr)) { +switch (lowpan_dev (dev)->lltype) { +case LOWPAN_LLTYPE_IEEE802154 : +if (lowpan_iphc_compress_802154_lladdr (ipaddr, lladdr)) { + dam =LOWPAN_IPHC_DAM_11 ;/* 0-bits */ +pr_debug ("address compression 0 bits\n" ); + goto out; + } +break ; +default : +if (is_addr_mac_addr_based (ipaddr, lladdr)) { + dam =LOWPAN_IPHC_DAM_11 ;/* 0-bits */ +pr_debug ("address compression 0 bits\n" ); + goto out; + } +break ; + } + +if (lowpan_is_iid_16_bit_compressable (ipaddr)) {/* compress IID to 16 bits xxxx::XXXX */ lowpan_push_hc_data (hc_ptr, &ipaddr->s6_addr16[7 ],2 ); dam =LOWPAN_IPHC_DAM_10 ;/* 16-bits */ raw_dump_inline (NULL ,"Compressed ipv6 addr is (16 bits)" , *hc_ptr -2 ,2 ); - }else { -/* do not compress IID => xxxx::IID */ -lowpan_push_hc_data (hc_ptr, &ipaddr->s6_addr16[4 ],8 ); - dam =LOWPAN_IPHC_DAM_01 ;/* 64-bits */ -raw_dump_inline (NULL ,"Compressed ipv6 addr is (64 bits)" , - *hc_ptr -8 ,8 ); + goto out; } +/* do not compress IID => xxxx::IID */ +lowpan_push_hc_data (hc_ptr, &ipaddr->s6_addr16[4 ],8 ); +raw_dump_inline (NULL ,"Compressed ipv6 addr is (64 bits)" , + *hc_ptr -8 ,8 ); + +out: +if (sam)return lowpan_iphc_dam_to_sam_value[dam];else
@@ -1013,9 +1123,6 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev, iphc0 =LOWPAN_DISPATCH_IPHC ; iphc1 =0 ; -raw_dump_inline (__func__,"saddr" , saddr,EUI64_ADDR_LEN ); -raw_dump_inline (__func__,"daddr" , daddr,EUI64_ADDR_LEN ); -raw_dump_table (__func__,"sending raw skb network uncompressed packet" , skb->data, skb->len);
@@ -1088,14 +1195,15 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev, iphc1 |=LOWPAN_IPHC_SAC ; }else {if (sci) { - iphc1 |=lowpan_compress_ctx_addr (&hc_ptr, &hdr->saddr, + iphc1 |=lowpan_compress_ctx_addr (&hc_ptr, dev, + &hdr->saddr, &sci_entry, saddr, true); iphc1 |=LOWPAN_IPHC_SAC ; }else {if (ipv6_saddr_type &IPV6_ADDR_LINKLOCAL &&lowpan_is_linklocal_zero_padded (hdr->saddr)) { - iphc1 |=lowpan_compress_addr_64 (&hc_ptr, + iphc1 |=lowpan_compress_addr_64 (&hc_ptr, dev, &hdr->saddr, saddr, true); pr_debug("source address unicast link-local %pI6c iphc1 0x%02x\n",
@@ -1123,14 +1231,15 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev, } }else {if (dci) { - iphc1 |=lowpan_compress_ctx_addr (&hc_ptr, &hdr->daddr, + iphc1 |=lowpan_compress_ctx_addr (&hc_ptr, dev, + &hdr->daddr, &dci_entry, daddr, false); iphc1 |=LOWPAN_IPHC_DAC ; }else {if (ipv6_daddr_type &IPV6_ADDR_LINKLOCAL &&lowpan_is_linklocal_zero_padded (hdr->daddr)) { - iphc1 |=lowpan_compress_addr_64 (&hc_ptr, + iphc1 |=lowpan_compress_addr_64 (&hc_ptr, dev, &hdr->daddr, daddr, false); pr_debug("dest address unicast link-local %pI6c iphc1 0x%02x\n",
net/ieee802154/6lowpan/tx.c +57 -56
162 lines not on this page · raw message
Signature · 1 line
2.8.3
David Miller
maintainerFrom: Alexander Aring <[email protected]>
Date: Wed, 15 Jun 2016 21:20:15 +0200
Quoted 2 lines
David can you please pick-up this patch-serie for your net-next tree? Thanks in advance.
Series applied to net-next, thanks.