* [RFC 01/16] ieee802154: 6lowpan: change dev vars to wdev and ldev
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 8:49 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 02/16] ieee802154: 6lowpan: remove set to zero Alexander Aring
` (15 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
Inside the IEEE 802.15.4 6LoWPAN subsystem we use two interfaces which
are wpan and lowpan interfaces. Instead of using always the variable
name "dev" for both we rename the "dev" variable to wdev which means the
wpan net_device and ldev which means a lowpan net_device. This avoids
confusing and always looking back to see which net_device is meant by
the variable name "dev".
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/6lowpan_i.h | 2 +-
net/ieee802154/6lowpan/core.c | 85 ++++++++++++++++++-------------------
net/ieee802154/6lowpan/reassembly.c | 14 +++---
net/ieee802154/6lowpan/rx.c | 20 ++++-----
net/ieee802154/6lowpan/tx.c | 39 +++++++++--------
5 files changed, 79 insertions(+), 81 deletions(-)
diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
index ff727aa..d62046e 100644
--- a/net/ieee802154/6lowpan/6lowpan_i.h
+++ b/net/ieee802154/6lowpan/6lowpan_i.h
@@ -40,7 +40,7 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
/* private device info */
struct lowpan_dev_info {
- struct net_device *real_dev; /* real WPAN device ptr */
+ struct net_device *wdev; /* real WPAN device ptr */
u16 fragment_tag;
};
diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
index ef17c6a..46efaca 100644
--- a/net/ieee802154/6lowpan/core.c
+++ b/net/ieee802154/6lowpan/core.c
@@ -59,7 +59,7 @@ static struct header_ops lowpan_header_ops = {
static struct lock_class_key lowpan_tx_busylock;
static struct lock_class_key lowpan_netdev_xmit_lock_key;
-static void lowpan_set_lockdep_class_one(struct net_device *dev,
+static void lowpan_set_lockdep_class_one(struct net_device *ldev,
struct netdev_queue *txq,
void *_unused)
{
@@ -67,10 +67,10 @@ static void lowpan_set_lockdep_class_one(struct net_device *dev,
&lowpan_netdev_xmit_lock_key);
}
-static int lowpan_dev_init(struct net_device *dev)
+static int lowpan_dev_init(struct net_device *ldev)
{
- netdev_for_each_tx_queue(dev, lowpan_set_lockdep_class_one, NULL);
- dev->qdisc_tx_busylock = &lowpan_tx_busylock;
+ netdev_for_each_tx_queue(ldev, lowpan_set_lockdep_class_one, NULL);
+ ldev->qdisc_tx_busylock = &lowpan_tx_busylock;
return 0;
}
@@ -79,23 +79,23 @@ static const struct net_device_ops lowpan_netdev_ops = {
.ndo_start_xmit = lowpan_xmit,
};
-static void lowpan_setup(struct net_device *dev)
+static void lowpan_setup(struct net_device *ldev)
{
- dev->addr_len = IEEE802154_ADDR_LEN;
- memset(dev->broadcast, 0xff, IEEE802154_ADDR_LEN);
- dev->type = ARPHRD_6LOWPAN;
+ ldev->addr_len = IEEE802154_ADDR_LEN;
+ memset(ldev->broadcast, 0xff, IEEE802154_ADDR_LEN);
+ ldev->type = ARPHRD_6LOWPAN;
/* Frame Control + Sequence Number + Address fields + Security Header */
- dev->hard_header_len = 2 + 1 + 20 + 14;
- dev->needed_tailroom = 2; /* FCS */
- dev->mtu = IPV6_MIN_MTU;
- dev->tx_queue_len = 0;
- dev->flags = IFF_BROADCAST | IFF_MULTICAST;
- dev->watchdog_timeo = 0;
-
- dev->netdev_ops = &lowpan_netdev_ops;
- dev->header_ops = &lowpan_header_ops;
- dev->destructor = free_netdev;
- dev->features |= NETIF_F_NETNS_LOCAL;
+ ldev->hard_header_len = 2 + 1 + 20 + 14;
+ ldev->needed_tailroom = 2; /* FCS */
+ ldev->mtu = IPV6_MIN_MTU;
+ ldev->tx_queue_len = 0;
+ ldev->flags = IFF_BROADCAST | IFF_MULTICAST;
+ ldev->watchdog_timeo = 0;
+
+ ldev->netdev_ops = &lowpan_netdev_ops;
+ ldev->header_ops = &lowpan_header_ops;
+ ldev->destructor = free_netdev;
+ ldev->features |= NETIF_F_NETNS_LOCAL;
}
static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -107,10 +107,10 @@ static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
return 0;
}
-static int lowpan_newlink(struct net *src_net, struct net_device *dev,
+static int lowpan_newlink(struct net *src_net, struct net_device *ldev,
struct nlattr *tb[], struct nlattr *data[])
{
- struct net_device *real_dev;
+ struct net_device *wdev;
int ret;
ASSERT_RTNL();
@@ -118,48 +118,47 @@ static int lowpan_newlink(struct net *src_net, struct net_device *dev,
pr_debug("adding new link\n");
if (!tb[IFLA_LINK] ||
- !net_eq(dev_net(dev), &init_net))
+ !net_eq(dev_net(ldev), &init_net))
return -EINVAL;
/* find and hold real wpan device */
- real_dev = dev_get_by_index(dev_net(dev), nla_get_u32(tb[IFLA_LINK]));
- if (!real_dev)
+ wdev = dev_get_by_index(dev_net(ldev), nla_get_u32(tb[IFLA_LINK]));
+ if (!wdev)
return -ENODEV;
- if (real_dev->type != ARPHRD_IEEE802154) {
- dev_put(real_dev);
+ if (wdev->type != ARPHRD_IEEE802154) {
+ dev_put(wdev);
return -EINVAL;
}
- if (real_dev->ieee802154_ptr->lowpan_dev) {
- dev_put(real_dev);
+ if (wdev->ieee802154_ptr->lowpan_dev) {
+ dev_put(wdev);
return -EBUSY;
}
- lowpan_dev_info(dev)->real_dev = real_dev;
+ lowpan_dev_info(ldev)->wdev = wdev;
/* Set the lowpan hardware address to the wpan hardware address. */
- memcpy(dev->dev_addr, real_dev->dev_addr, IEEE802154_ADDR_LEN);
+ memcpy(ldev->dev_addr, wdev->dev_addr, IEEE802154_ADDR_LEN);
- lowpan_priv(dev)->lltype = LOWPAN_LLTYPE_IEEE802154;
+ lowpan_priv(ldev)->lltype = LOWPAN_LLTYPE_IEEE802154;
- ret = register_netdevice(dev);
+ ret = register_netdevice(ldev);
if (ret >= 0) {
- real_dev->ieee802154_ptr->lowpan_dev = dev;
+ wdev->ieee802154_ptr->lowpan_dev = ldev;
lowpan_rx_init();
}
return ret;
}
-static void lowpan_dellink(struct net_device *dev, struct list_head *head)
+static void lowpan_dellink(struct net_device *ldev, struct list_head *head)
{
- struct lowpan_dev_info *lowpan_dev = lowpan_dev_info(dev);
- struct net_device *real_dev = lowpan_dev->real_dev;
+ struct net_device *wdev = lowpan_dev_info(ldev)->wdev;
ASSERT_RTNL();
lowpan_rx_exit();
- real_dev->ieee802154_ptr->lowpan_dev = NULL;
- unregister_netdevice(dev);
- dev_put(real_dev);
+ wdev->ieee802154_ptr->lowpan_dev = NULL;
+ unregister_netdevice(ldev);
+ dev_put(wdev);
}
static struct rtnl_link_ops lowpan_link_ops __read_mostly = {
@@ -185,9 +184,9 @@ static inline void lowpan_netlink_fini(void)
static int lowpan_device_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
- struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+ struct net_device *wdev = netdev_notifier_info_to_dev(ptr);
- if (dev->type != ARPHRD_IEEE802154)
+ if (wdev->type != ARPHRD_IEEE802154)
goto out;
switch (event) {
@@ -196,8 +195,8 @@ static int lowpan_device_event(struct notifier_block *unused,
* also delete possible lowpan interfaces which belongs
* to the wpan interface.
*/
- if (dev->ieee802154_ptr && dev->ieee802154_ptr->lowpan_dev)
- lowpan_dellink(dev->ieee802154_ptr->lowpan_dev, NULL);
+ if (wdev->ieee802154_ptr && wdev->ieee802154_ptr->lowpan_dev)
+ lowpan_dellink(wdev->ieee802154_ptr->lowpan_dev, NULL);
break;
default:
break;
diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
index f46e4d1..c9f77f7 100644
--- a/net/ieee802154/6lowpan/reassembly.c
+++ b/net/ieee802154/6lowpan/reassembly.c
@@ -46,7 +46,7 @@ static struct lowpan_frag_info *lowpan_cb(struct sk_buff *skb)
static struct inet_frags lowpan_frags;
static int lowpan_frag_reasm(struct lowpan_frag_queue *fq,
- struct sk_buff *prev, struct net_device *dev);
+ struct sk_buff *prev, struct net_device *ldev);
static unsigned int lowpan_hash_frag(u16 tag, u16 d_size,
const struct ieee802154_addr *saddr,
@@ -141,7 +141,7 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq,
struct sk_buff *skb, const u8 frag_type)
{
struct sk_buff *prev, *next;
- struct net_device *dev;
+ struct net_device *ldev;
int end, offset;
if (fq->q.flags & INET_FRAG_COMPLETE)
@@ -195,8 +195,8 @@ found:
else
fq->q.fragments = skb;
- dev = skb->dev;
- if (dev)
+ ldev = skb->dev;
+ if (ldev)
skb->dev = NULL;
fq->q.stamp = skb->tstamp;
@@ -215,7 +215,7 @@ found:
unsigned long orefdst = skb->_skb_refdst;
skb->_skb_refdst = 0UL;
- res = lowpan_frag_reasm(fq, prev, dev);
+ res = lowpan_frag_reasm(fq, prev, ldev);
skb->_skb_refdst = orefdst;
return res;
}
@@ -235,7 +235,7 @@ err:
* the last and the first frames arrived and all the bits are here.
*/
static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
- struct net_device *dev)
+ struct net_device *ldev)
{
struct sk_buff *fp, *head = fq->q.fragments;
int sum_truesize;
@@ -313,7 +313,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
sub_frag_mem_limit(&fq->q, sum_truesize);
head->next = NULL;
- head->dev = dev;
+ head->dev = ldev;
head->tstamp = fq->q.stamp;
fq->q.fragments = NULL;
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index d6f5e8e..6302b94 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -16,9 +16,9 @@
#include "6lowpan_i.h"
static int lowpan_give_skb_to_device(struct sk_buff *skb,
- struct net_device *dev)
+ struct net_device *wdev)
{
- skb->dev = dev->ieee802154_ptr->lowpan_dev;
+ skb->dev = wdev->ieee802154_ptr->lowpan_dev;
skb->protocol = htons(ETH_P_IPV6);
skb->pkt_type = PACKET_HOST;
@@ -61,8 +61,8 @@ iphc_decompress(struct sk_buff *skb, const struct ieee802154_hdr *hdr)
IEEE802154_ADDR_LEN, iphc0, iphc1);
}
-static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
- struct packet_type *pt, struct net_device *orig_dev)
+static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
+ struct packet_type *pt, struct net_device *orig_wdev)
{
struct ieee802154_hdr hdr;
int ret;
@@ -71,13 +71,13 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
if (!skb)
goto drop;
- if (!netif_running(dev))
+ if (!netif_running(wdev))
goto drop_skb;
if (skb->pkt_type == PACKET_OTHERHOST)
goto drop_skb;
- if (dev->type != ARPHRD_IEEE802154)
+ if (wdev->type != ARPHRD_IEEE802154)
goto drop_skb;
if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
@@ -87,7 +87,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
if (skb->data[0] == LOWPAN_DISPATCH_IPV6) {
/* Pull off the 1-byte of 6lowpan header. */
skb_pull(skb, 1);
- return lowpan_give_skb_to_device(skb, dev);
+ return lowpan_give_skb_to_device(skb, wdev);
} else {
switch (skb->data[0] & 0xe0) {
case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */
@@ -95,7 +95,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
if (ret < 0)
goto drop_skb;
- return lowpan_give_skb_to_device(skb, dev);
+ return lowpan_give_skb_to_device(skb, wdev);
case LOWPAN_DISPATCH_FRAG1: /* first fragment header */
ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAG1);
if (ret == 1) {
@@ -103,7 +103,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
if (ret < 0)
goto drop_skb;
- return lowpan_give_skb_to_device(skb, dev);
+ return lowpan_give_skb_to_device(skb, wdev);
} else if (ret == -1) {
return NET_RX_DROP;
} else {
@@ -116,7 +116,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
if (ret < 0)
goto drop_skb;
- return lowpan_give_skb_to_device(skb, dev);
+ return lowpan_give_skb_to_device(skb, wdev);
} else if (ret == -1) {
return NET_RX_DROP;
} else {
diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c
index 1bf4a30..564e973 100644
--- a/net/ieee802154/6lowpan/tx.c
+++ b/net/ieee802154/6lowpan/tx.c
@@ -36,7 +36,7 @@ lowpan_addr_info *lowpan_skb_priv(const struct sk_buff *skb)
sizeof(struct lowpan_addr_info));
}
-int lowpan_header_create(struct sk_buff *skb, struct net_device *dev,
+int lowpan_header_create(struct sk_buff *skb, struct net_device *ldev,
unsigned short type, const void *_daddr,
const void *_saddr, unsigned int len)
{
@@ -51,7 +51,7 @@ int lowpan_header_create(struct sk_buff *skb, struct net_device *dev,
return 0;
if (!saddr)
- saddr = dev->dev_addr;
+ saddr = ldev->dev_addr;
raw_dump_inline(__func__, "saddr", (unsigned char *)saddr, 8);
raw_dump_inline(__func__, "daddr", (unsigned char *)daddr, 8);
@@ -73,22 +73,21 @@ static struct sk_buff*
lowpan_alloc_frag(struct sk_buff *skb, int size,
const struct ieee802154_hdr *master_hdr)
{
- struct net_device *real_dev = lowpan_dev_info(skb->dev)->real_dev;
+ struct net_device *wdev = lowpan_dev_info(skb->dev)->wdev;
struct sk_buff *frag;
int rc;
- frag = alloc_skb(real_dev->hard_header_len +
- real_dev->needed_tailroom + size,
+ frag = alloc_skb(wdev->hard_header_len + wdev->needed_tailroom + size,
GFP_ATOMIC);
if (likely(frag)) {
- frag->dev = real_dev;
+ frag->dev = wdev;
frag->priority = skb->priority;
- skb_reserve(frag, real_dev->hard_header_len);
+ skb_reserve(frag, wdev->hard_header_len);
skb_reset_network_header(frag);
*mac_cb(frag) = *mac_cb(skb);
- rc = dev_hard_header(frag, real_dev, 0, &master_hdr->dest,
+ rc = dev_hard_header(frag, wdev, 0, &master_hdr->dest,
&master_hdr->source, size);
if (rc < 0) {
kfree_skb(frag);
@@ -123,7 +122,7 @@ lowpan_xmit_fragment(struct sk_buff *skb, const struct ieee802154_hdr *wpan_hdr,
}
static int
-lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *dev,
+lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *ldev,
const struct ieee802154_hdr *wpan_hdr)
{
u16 dgram_size, dgram_offset;
@@ -134,8 +133,8 @@ lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *dev,
dgram_size = lowpan_uncompress_size(skb, &dgram_offset) -
skb->mac_len;
- frag_tag = htons(lowpan_dev_info(dev)->fragment_tag);
- lowpan_dev_info(dev)->fragment_tag++;
+ frag_tag = htons(lowpan_dev_info(ldev)->fragment_tag);
+ lowpan_dev_info(ldev)->fragment_tag++;
frag_hdr[0] = LOWPAN_DISPATCH_FRAG1 | ((dgram_size >> 8) & 0x07);
frag_hdr[1] = dgram_size & 0xff;
@@ -188,9 +187,9 @@ err:
return rc;
}
-static int lowpan_header(struct sk_buff *skb, struct net_device *dev)
+static int lowpan_header(struct sk_buff *skb, struct net_device *ldev)
{
- struct wpan_dev *wpan_dev = lowpan_dev_info(dev)->real_dev->ieee802154_ptr;
+ struct wpan_dev *wpan_dev = lowpan_dev_info(ldev)->wdev->ieee802154_ptr;
struct ieee802154_addr sa, da;
struct ieee802154_mac_cb *cb = mac_cb_init(skb);
struct lowpan_addr_info info;
@@ -202,7 +201,7 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *dev)
daddr = &info.daddr.u.extended_addr;
saddr = &info.saddr.u.extended_addr;
- lowpan_header_compress(skb, dev, ETH_P_IPV6, daddr, saddr, skb->len);
+ lowpan_header_compress(skb, ldev, ETH_P_IPV6, daddr, saddr, skb->len);
cb->type = IEEE802154_FC_TYPE_DATA;
@@ -227,11 +226,11 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *dev)
cb->ackreq = wpan_dev->ackreq;
}
- return dev_hard_header(skb, lowpan_dev_info(dev)->real_dev,
- ETH_P_IPV6, (void *)&da, (void *)&sa, 0);
+ return dev_hard_header(skb, lowpan_dev_info(ldev)->wdev, ETH_P_IPV6,
+ (void *)&da, (void *)&sa, 0);
}
-netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev)
+netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev)
{
struct ieee802154_hdr wpan_hdr;
int max_single, ret;
@@ -245,7 +244,7 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev)
if (!skb)
return NET_XMIT_DROP;
- ret = lowpan_header(skb, dev);
+ ret = lowpan_header(skb, ldev);
if (ret < 0) {
kfree_skb(skb);
return NET_XMIT_DROP;
@@ -259,13 +258,13 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev)
max_single = ieee802154_max_payload(&wpan_hdr);
if (skb_tail_pointer(skb) - skb_network_header(skb) <= max_single) {
- skb->dev = lowpan_dev_info(dev)->real_dev;
+ skb->dev = lowpan_dev_info(ldev)->wdev;
return dev_queue_xmit(skb);
} else {
netdev_tx_t rc;
pr_debug("frame is too big, fragmentation is needed\n");
- rc = lowpan_xmit_fragmented(skb, dev, &wpan_hdr);
+ rc = lowpan_xmit_fragmented(skb, ldev, &wpan_hdr);
return rc < 0 ? NET_XMIT_DROP : rc;
}
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 01/16] ieee802154: 6lowpan: change dev vars to wdev and ldev
2015-08-03 6:23 ` [RFC 01/16] ieee802154: 6lowpan: change dev vars to wdev and ldev Alexander Aring
@ 2015-08-12 8:49 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 8:49 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> Inside the IEEE 802.15.4 6LoWPAN subsystem we use two interfaces which
> are wpan and lowpan interfaces. Instead of using always the variable
> name "dev" for both we rename the "dev" variable to wdev which means the
> wpan net_device and ldev which means a lowpan net_device. This avoids
> confusing and always looking back to see which net_device is meant by
> the variable name "dev".
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/6lowpan_i.h | 2 +-
> net/ieee802154/6lowpan/core.c | 85 ++++++++++++++++++-------------------
> net/ieee802154/6lowpan/reassembly.c | 14 +++---
> net/ieee802154/6lowpan/rx.c | 20 ++++-----
> net/ieee802154/6lowpan/tx.c | 39 +++++++++--------
> 5 files changed, 79 insertions(+), 81 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
> index ff727aa..d62046e 100644
> --- a/net/ieee802154/6lowpan/6lowpan_i.h
> +++ b/net/ieee802154/6lowpan/6lowpan_i.h
> @@ -40,7 +40,7 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
>
> /* private device info */
> struct lowpan_dev_info {
> - struct net_device *real_dev; /* real WPAN device ptr */
> + struct net_device *wdev; /* real WPAN device ptr */
Maybe remove the real also from the comment here.
> u16 fragment_tag;
> };
>
> diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
> index ef17c6a..46efaca 100644
> --- a/net/ieee802154/6lowpan/core.c
> +++ b/net/ieee802154/6lowpan/core.c
> @@ -59,7 +59,7 @@ static struct header_ops lowpan_header_ops = {
> static struct lock_class_key lowpan_tx_busylock;
> static struct lock_class_key lowpan_netdev_xmit_lock_key;
>
> -static void lowpan_set_lockdep_class_one(struct net_device *dev,
> +static void lowpan_set_lockdep_class_one(struct net_device *ldev,
> struct netdev_queue *txq,
> void *_unused)
> {
> @@ -67,10 +67,10 @@ static void lowpan_set_lockdep_class_one(struct net_device *dev,
> &lowpan_netdev_xmit_lock_key);
> }
>
> -static int lowpan_dev_init(struct net_device *dev)
> +static int lowpan_dev_init(struct net_device *ldev)
> {
> - netdev_for_each_tx_queue(dev, lowpan_set_lockdep_class_one, NULL);
> - dev->qdisc_tx_busylock = &lowpan_tx_busylock;
> + netdev_for_each_tx_queue(ldev, lowpan_set_lockdep_class_one, NULL);
> + ldev->qdisc_tx_busylock = &lowpan_tx_busylock;
> return 0;
> }
>
> @@ -79,23 +79,23 @@ static const struct net_device_ops lowpan_netdev_ops = {
> .ndo_start_xmit = lowpan_xmit,
> };
>
> -static void lowpan_setup(struct net_device *dev)
> +static void lowpan_setup(struct net_device *ldev)
> {
> - dev->addr_len = IEEE802154_ADDR_LEN;
> - memset(dev->broadcast, 0xff, IEEE802154_ADDR_LEN);
> - dev->type = ARPHRD_6LOWPAN;
> + ldev->addr_len = IEEE802154_ADDR_LEN;
> + memset(ldev->broadcast, 0xff, IEEE802154_ADDR_LEN);
> + ldev->type = ARPHRD_6LOWPAN;
> /* Frame Control + Sequence Number + Address fields + Security Header */
> - dev->hard_header_len = 2 + 1 + 20 + 14;
> - dev->needed_tailroom = 2; /* FCS */
> - dev->mtu = IPV6_MIN_MTU;
> - dev->tx_queue_len = 0;
> - dev->flags = IFF_BROADCAST | IFF_MULTICAST;
> - dev->watchdog_timeo = 0;
> -
> - dev->netdev_ops = &lowpan_netdev_ops;
> - dev->header_ops = &lowpan_header_ops;
> - dev->destructor = free_netdev;
> - dev->features |= NETIF_F_NETNS_LOCAL;
> + ldev->hard_header_len = 2 + 1 + 20 + 14;
> + ldev->needed_tailroom = 2; /* FCS */
> + ldev->mtu = IPV6_MIN_MTU;
> + ldev->tx_queue_len = 0;
> + ldev->flags = IFF_BROADCAST | IFF_MULTICAST;
> + ldev->watchdog_timeo = 0;
> +
> + ldev->netdev_ops = &lowpan_netdev_ops;
> + ldev->header_ops = &lowpan_header_ops;
> + ldev->destructor = free_netdev;
> + ldev->features |= NETIF_F_NETNS_LOCAL;
> }
>
> static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
> @@ -107,10 +107,10 @@ static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
> return 0;
> }
>
> -static int lowpan_newlink(struct net *src_net, struct net_device *dev,
> +static int lowpan_newlink(struct net *src_net, struct net_device *ldev,
> struct nlattr *tb[], struct nlattr *data[])
> {
> - struct net_device *real_dev;
> + struct net_device *wdev;
> int ret;
>
> ASSERT_RTNL();
> @@ -118,48 +118,47 @@ static int lowpan_newlink(struct net *src_net, struct net_device *dev,
> pr_debug("adding new link\n");
>
> if (!tb[IFLA_LINK] ||
> - !net_eq(dev_net(dev), &init_net))
> + !net_eq(dev_net(ldev), &init_net))
> return -EINVAL;
> /* find and hold real wpan device */
> - real_dev = dev_get_by_index(dev_net(dev), nla_get_u32(tb[IFLA_LINK]));
> - if (!real_dev)
> + wdev = dev_get_by_index(dev_net(ldev), nla_get_u32(tb[IFLA_LINK]));
> + if (!wdev)
> return -ENODEV;
> - if (real_dev->type != ARPHRD_IEEE802154) {
> - dev_put(real_dev);
> + if (wdev->type != ARPHRD_IEEE802154) {
> + dev_put(wdev);
> return -EINVAL;
> }
>
> - if (real_dev->ieee802154_ptr->lowpan_dev) {
> - dev_put(real_dev);
> + if (wdev->ieee802154_ptr->lowpan_dev) {
> + dev_put(wdev);
> return -EBUSY;
> }
>
> - lowpan_dev_info(dev)->real_dev = real_dev;
> + lowpan_dev_info(ldev)->wdev = wdev;
> /* Set the lowpan hardware address to the wpan hardware address. */
> - memcpy(dev->dev_addr, real_dev->dev_addr, IEEE802154_ADDR_LEN);
> + memcpy(ldev->dev_addr, wdev->dev_addr, IEEE802154_ADDR_LEN);
>
> - lowpan_priv(dev)->lltype = LOWPAN_LLTYPE_IEEE802154;
> + lowpan_priv(ldev)->lltype = LOWPAN_LLTYPE_IEEE802154;
>
> - ret = register_netdevice(dev);
> + ret = register_netdevice(ldev);
> if (ret >= 0) {
> - real_dev->ieee802154_ptr->lowpan_dev = dev;
> + wdev->ieee802154_ptr->lowpan_dev = ldev;
> lowpan_rx_init();
> }
>
> return ret;
> }
>
> -static void lowpan_dellink(struct net_device *dev, struct list_head *head)
> +static void lowpan_dellink(struct net_device *ldev, struct list_head *head)
> {
> - struct lowpan_dev_info *lowpan_dev = lowpan_dev_info(dev);
> - struct net_device *real_dev = lowpan_dev->real_dev;
> + struct net_device *wdev = lowpan_dev_info(ldev)->wdev;
>
> ASSERT_RTNL();
>
> lowpan_rx_exit();
> - real_dev->ieee802154_ptr->lowpan_dev = NULL;
> - unregister_netdevice(dev);
> - dev_put(real_dev);
> + wdev->ieee802154_ptr->lowpan_dev = NULL;
> + unregister_netdevice(ldev);
> + dev_put(wdev);
> }
>
> static struct rtnl_link_ops lowpan_link_ops __read_mostly = {
> @@ -185,9 +184,9 @@ static inline void lowpan_netlink_fini(void)
> static int lowpan_device_event(struct notifier_block *unused,
> unsigned long event, void *ptr)
> {
> - struct net_device *dev = netdev_notifier_info_to_dev(ptr);
> + struct net_device *wdev = netdev_notifier_info_to_dev(ptr);
>
> - if (dev->type != ARPHRD_IEEE802154)
> + if (wdev->type != ARPHRD_IEEE802154)
> goto out;
>
> switch (event) {
> @@ -196,8 +195,8 @@ static int lowpan_device_event(struct notifier_block *unused,
> * also delete possible lowpan interfaces which belongs
> * to the wpan interface.
> */
> - if (dev->ieee802154_ptr && dev->ieee802154_ptr->lowpan_dev)
> - lowpan_dellink(dev->ieee802154_ptr->lowpan_dev, NULL);
> + if (wdev->ieee802154_ptr && wdev->ieee802154_ptr->lowpan_dev)
> + lowpan_dellink(wdev->ieee802154_ptr->lowpan_dev, NULL);
> break;
> default:
> break;
> diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
> index f46e4d1..c9f77f7 100644
> --- a/net/ieee802154/6lowpan/reassembly.c
> +++ b/net/ieee802154/6lowpan/reassembly.c
> @@ -46,7 +46,7 @@ static struct lowpan_frag_info *lowpan_cb(struct sk_buff *skb)
> static struct inet_frags lowpan_frags;
>
> static int lowpan_frag_reasm(struct lowpan_frag_queue *fq,
> - struct sk_buff *prev, struct net_device *dev);
> + struct sk_buff *prev, struct net_device *ldev);
>
> static unsigned int lowpan_hash_frag(u16 tag, u16 d_size,
> const struct ieee802154_addr *saddr,
> @@ -141,7 +141,7 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq,
> struct sk_buff *skb, const u8 frag_type)
> {
> struct sk_buff *prev, *next;
> - struct net_device *dev;
> + struct net_device *ldev;
> int end, offset;
>
> if (fq->q.flags & INET_FRAG_COMPLETE)
> @@ -195,8 +195,8 @@ found:
> else
> fq->q.fragments = skb;
>
> - dev = skb->dev;
> - if (dev)
> + ldev = skb->dev;
> + if (ldev)
> skb->dev = NULL;
>
> fq->q.stamp = skb->tstamp;
> @@ -215,7 +215,7 @@ found:
> unsigned long orefdst = skb->_skb_refdst;
>
> skb->_skb_refdst = 0UL;
> - res = lowpan_frag_reasm(fq, prev, dev);
> + res = lowpan_frag_reasm(fq, prev, ldev);
> skb->_skb_refdst = orefdst;
> return res;
> }
> @@ -235,7 +235,7 @@ err:
> * the last and the first frames arrived and all the bits are here.
> */
> static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
> - struct net_device *dev)
> + struct net_device *ldev)
> {
> struct sk_buff *fp, *head = fq->q.fragments;
> int sum_truesize;
> @@ -313,7 +313,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
> sub_frag_mem_limit(&fq->q, sum_truesize);
>
> head->next = NULL;
> - head->dev = dev;
> + head->dev = ldev;
> head->tstamp = fq->q.stamp;
>
> fq->q.fragments = NULL;
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index d6f5e8e..6302b94 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -16,9 +16,9 @@
> #include "6lowpan_i.h"
>
> static int lowpan_give_skb_to_device(struct sk_buff *skb,
> - struct net_device *dev)
> + struct net_device *wdev)
> {
> - skb->dev = dev->ieee802154_ptr->lowpan_dev;
> + skb->dev = wdev->ieee802154_ptr->lowpan_dev;
> skb->protocol = htons(ETH_P_IPV6);
> skb->pkt_type = PACKET_HOST;
>
> @@ -61,8 +61,8 @@ iphc_decompress(struct sk_buff *skb, const struct ieee802154_hdr *hdr)
> IEEE802154_ADDR_LEN, iphc0, iphc1);
> }
>
> -static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
> - struct packet_type *pt, struct net_device *orig_dev)
> +static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> + struct packet_type *pt, struct net_device *orig_wdev)
> {
> struct ieee802154_hdr hdr;
> int ret;
> @@ -71,13 +71,13 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
> if (!skb)
> goto drop;
>
> - if (!netif_running(dev))
> + if (!netif_running(wdev))
> goto drop_skb;
>
> if (skb->pkt_type == PACKET_OTHERHOST)
> goto drop_skb;
>
> - if (dev->type != ARPHRD_IEEE802154)
> + if (wdev->type != ARPHRD_IEEE802154)
> goto drop_skb;
>
> if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
> @@ -87,7 +87,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
> if (skb->data[0] == LOWPAN_DISPATCH_IPV6) {
> /* Pull off the 1-byte of 6lowpan header. */
> skb_pull(skb, 1);
> - return lowpan_give_skb_to_device(skb, dev);
> + return lowpan_give_skb_to_device(skb, wdev);
> } else {
> switch (skb->data[0] & 0xe0) {
> case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */
> @@ -95,7 +95,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
> if (ret < 0)
> goto drop_skb;
>
> - return lowpan_give_skb_to_device(skb, dev);
> + return lowpan_give_skb_to_device(skb, wdev);
> case LOWPAN_DISPATCH_FRAG1: /* first fragment header */
> ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAG1);
> if (ret == 1) {
> @@ -103,7 +103,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
> if (ret < 0)
> goto drop_skb;
>
> - return lowpan_give_skb_to_device(skb, dev);
> + return lowpan_give_skb_to_device(skb, wdev);
> } else if (ret == -1) {
> return NET_RX_DROP;
> } else {
> @@ -116,7 +116,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
> if (ret < 0)
> goto drop_skb;
>
> - return lowpan_give_skb_to_device(skb, dev);
> + return lowpan_give_skb_to_device(skb, wdev);
> } else if (ret == -1) {
> return NET_RX_DROP;
> } else {
> diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c
> index 1bf4a30..564e973 100644
> --- a/net/ieee802154/6lowpan/tx.c
> +++ b/net/ieee802154/6lowpan/tx.c
> @@ -36,7 +36,7 @@ lowpan_addr_info *lowpan_skb_priv(const struct sk_buff *skb)
> sizeof(struct lowpan_addr_info));
> }
>
> -int lowpan_header_create(struct sk_buff *skb, struct net_device *dev,
> +int lowpan_header_create(struct sk_buff *skb, struct net_device *ldev,
> unsigned short type, const void *_daddr,
> const void *_saddr, unsigned int len)
> {
> @@ -51,7 +51,7 @@ int lowpan_header_create(struct sk_buff *skb, struct net_device *dev,
> return 0;
>
> if (!saddr)
> - saddr = dev->dev_addr;
> + saddr = ldev->dev_addr;
>
> raw_dump_inline(__func__, "saddr", (unsigned char *)saddr, 8);
> raw_dump_inline(__func__, "daddr", (unsigned char *)daddr, 8);
> @@ -73,22 +73,21 @@ static struct sk_buff*
> lowpan_alloc_frag(struct sk_buff *skb, int size,
> const struct ieee802154_hdr *master_hdr)
> {
> - struct net_device *real_dev = lowpan_dev_info(skb->dev)->real_dev;
> + struct net_device *wdev = lowpan_dev_info(skb->dev)->wdev;
> struct sk_buff *frag;
> int rc;
>
> - frag = alloc_skb(real_dev->hard_header_len +
> - real_dev->needed_tailroom + size,
> + frag = alloc_skb(wdev->hard_header_len + wdev->needed_tailroom + size,
> GFP_ATOMIC);
>
> if (likely(frag)) {
> - frag->dev = real_dev;
> + frag->dev = wdev;
> frag->priority = skb->priority;
> - skb_reserve(frag, real_dev->hard_header_len);
> + skb_reserve(frag, wdev->hard_header_len);
> skb_reset_network_header(frag);
> *mac_cb(frag) = *mac_cb(skb);
>
> - rc = dev_hard_header(frag, real_dev, 0, &master_hdr->dest,
> + rc = dev_hard_header(frag, wdev, 0, &master_hdr->dest,
> &master_hdr->source, size);
> if (rc < 0) {
> kfree_skb(frag);
> @@ -123,7 +122,7 @@ lowpan_xmit_fragment(struct sk_buff *skb, const struct ieee802154_hdr *wpan_hdr,
> }
>
> static int
> -lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *dev,
> +lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *ldev,
> const struct ieee802154_hdr *wpan_hdr)
> {
> u16 dgram_size, dgram_offset;
> @@ -134,8 +133,8 @@ lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *dev,
>
> dgram_size = lowpan_uncompress_size(skb, &dgram_offset) -
> skb->mac_len;
> - frag_tag = htons(lowpan_dev_info(dev)->fragment_tag);
> - lowpan_dev_info(dev)->fragment_tag++;
> + frag_tag = htons(lowpan_dev_info(ldev)->fragment_tag);
> + lowpan_dev_info(ldev)->fragment_tag++;
>
> frag_hdr[0] = LOWPAN_DISPATCH_FRAG1 | ((dgram_size >> 8) & 0x07);
> frag_hdr[1] = dgram_size & 0xff;
> @@ -188,9 +187,9 @@ err:
> return rc;
> }
>
> -static int lowpan_header(struct sk_buff *skb, struct net_device *dev)
> +static int lowpan_header(struct sk_buff *skb, struct net_device *ldev)
> {
> - struct wpan_dev *wpan_dev = lowpan_dev_info(dev)->real_dev->ieee802154_ptr;
> + struct wpan_dev *wpan_dev = lowpan_dev_info(ldev)->wdev->ieee802154_ptr;
> struct ieee802154_addr sa, da;
> struct ieee802154_mac_cb *cb = mac_cb_init(skb);
> struct lowpan_addr_info info;
> @@ -202,7 +201,7 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *dev)
> daddr = &info.daddr.u.extended_addr;
> saddr = &info.saddr.u.extended_addr;
>
> - lowpan_header_compress(skb, dev, ETH_P_IPV6, daddr, saddr, skb->len);
> + lowpan_header_compress(skb, ldev, ETH_P_IPV6, daddr, saddr, skb->len);
>
> cb->type = IEEE802154_FC_TYPE_DATA;
>
> @@ -227,11 +226,11 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *dev)
> cb->ackreq = wpan_dev->ackreq;
> }
>
> - return dev_hard_header(skb, lowpan_dev_info(dev)->real_dev,
> - ETH_P_IPV6, (void *)&da, (void *)&sa, 0);
> + return dev_hard_header(skb, lowpan_dev_info(ldev)->wdev, ETH_P_IPV6,
> + (void *)&da, (void *)&sa, 0);
> }
>
> -netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev)
> +netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev)
> {
> struct ieee802154_hdr wpan_hdr;
> int max_single, ret;
> @@ -245,7 +244,7 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev)
> if (!skb)
> return NET_XMIT_DROP;
>
> - ret = lowpan_header(skb, dev);
> + ret = lowpan_header(skb, ldev);
> if (ret < 0) {
> kfree_skb(skb);
> return NET_XMIT_DROP;
> @@ -259,13 +258,13 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev)
> max_single = ieee802154_max_payload(&wpan_hdr);
>
> if (skb_tail_pointer(skb) - skb_network_header(skb) <= max_single) {
> - skb->dev = lowpan_dev_info(dev)->real_dev;
> + skb->dev = lowpan_dev_info(ldev)->wdev;
> return dev_queue_xmit(skb);
> } else {
> netdev_tx_t rc;
>
> pr_debug("frame is too big, fragmentation is needed\n");
> - rc = lowpan_xmit_fragmented(skb, dev, &wpan_hdr);
> + rc = lowpan_xmit_fragmented(skb, ldev, &wpan_hdr);
>
> return rc < 0 ? NET_XMIT_DROP : rc;
> }
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 02/16] ieee802154: 6lowpan: remove set to zero
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
2015-08-03 6:23 ` [RFC 01/16] ieee802154: 6lowpan: change dev vars to wdev and ldev Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 8:49 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 03/16] ieee802154: 6lowpan: remove EXPORT_SYMBOL Alexander Aring
` (14 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
Internal mechanism by calling netdev_alloc which use kzalloc already
sets these variables to zero. This patch cleanup the setup of net_device.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/core.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
index 46efaca..ca331bc 100644
--- a/net/ieee802154/6lowpan/core.c
+++ b/net/ieee802154/6lowpan/core.c
@@ -88,9 +88,7 @@ static void lowpan_setup(struct net_device *ldev)
ldev->hard_header_len = 2 + 1 + 20 + 14;
ldev->needed_tailroom = 2; /* FCS */
ldev->mtu = IPV6_MIN_MTU;
- ldev->tx_queue_len = 0;
ldev->flags = IFF_BROADCAST | IFF_MULTICAST;
- ldev->watchdog_timeo = 0;
ldev->netdev_ops = &lowpan_netdev_ops;
ldev->header_ops = &lowpan_header_ops;
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 02/16] ieee802154: 6lowpan: remove set to zero
2015-08-03 6:23 ` [RFC 02/16] ieee802154: 6lowpan: remove set to zero Alexander Aring
@ 2015-08-12 8:49 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 8:49 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> Internal mechanism by calling netdev_alloc which use kzalloc already
> sets these variables to zero. This patch cleanup the setup of net_device.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/core.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
> index 46efaca..ca331bc 100644
> --- a/net/ieee802154/6lowpan/core.c
> +++ b/net/ieee802154/6lowpan/core.c
> @@ -88,9 +88,7 @@ static void lowpan_setup(struct net_device *ldev)
> ldev->hard_header_len = 2 + 1 + 20 + 14;
> ldev->needed_tailroom = 2; /* FCS */
> ldev->mtu = IPV6_MIN_MTU;
> - ldev->tx_queue_len = 0;
> ldev->flags = IFF_BROADCAST | IFF_MULTICAST;
> - ldev->watchdog_timeo = 0;
>
> ldev->netdev_ops = &lowpan_netdev_ops;
> ldev->header_ops = &lowpan_header_ops;
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 03/16] ieee802154: 6lowpan: remove EXPORT_SYMBOL
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
2015-08-03 6:23 ` [RFC 01/16] ieee802154: 6lowpan: change dev vars to wdev and ldev Alexander Aring
2015-08-03 6:23 ` [RFC 02/16] ieee802154: 6lowpan: remove set to zero Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 8:49 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 04/16] ieee802154: 6lowpan: remove check on wdev is running Alexander Aring
` (13 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This function is used internally inside of ieee802154 6lowpan module
only and not outside of any other module. We don't need to export this
function then.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/reassembly.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
index c9f77f7..cfb8443 100644
--- a/net/ieee802154/6lowpan/reassembly.c
+++ b/net/ieee802154/6lowpan/reassembly.c
@@ -387,7 +387,6 @@ err:
kfree_skb(skb);
return -1;
}
-EXPORT_SYMBOL(lowpan_frag_rcv);
#ifdef CONFIG_SYSCTL
static int zero;
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 03/16] ieee802154: 6lowpan: remove EXPORT_SYMBOL
2015-08-03 6:23 ` [RFC 03/16] ieee802154: 6lowpan: remove EXPORT_SYMBOL Alexander Aring
@ 2015-08-12 8:49 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 8:49 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This function is used internally inside of ieee802154 6lowpan module
> only and not outside of any other module. We don't need to export this
> function then.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/reassembly.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
> index c9f77f7..cfb8443 100644
> --- a/net/ieee802154/6lowpan/reassembly.c
> +++ b/net/ieee802154/6lowpan/reassembly.c
> @@ -387,7 +387,6 @@ err:
> kfree_skb(skb);
> return -1;
> }
> -EXPORT_SYMBOL(lowpan_frag_rcv);
>
> #ifdef CONFIG_SYSCTL
> static int zero;
Reviewed-by: Stefan Schmidt<stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 04/16] ieee802154: 6lowpan: remove check on wdev is running
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (2 preceding siblings ...)
2015-08-03 6:23 ` [RFC 03/16] ieee802154: 6lowpan: remove EXPORT_SYMBOL Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 8:49 ` Stefan Schmidt
2015-08-15 11:50 ` Alexander Aring
2015-08-03 6:23 ` [RFC 05/16] ieee802154: 6lowpan: cleanup pull of iphc bytes Alexander Aring
` (12 subsequent siblings)
16 siblings, 2 replies; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
We don't need to check if the wpan interface is running because the
lowpan_rcv is the packet layer receive handler for thw wpan interface.
This means for the check if the wpan interface is running ends always in
true.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index 6302b94..99aeb56 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -71,9 +71,6 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
if (!skb)
goto drop;
- if (!netif_running(wdev))
- goto drop_skb;
-
if (skb->pkt_type == PACKET_OTHERHOST)
goto drop_skb;
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 04/16] ieee802154: 6lowpan: remove check on wdev is running
2015-08-03 6:23 ` [RFC 04/16] ieee802154: 6lowpan: remove check on wdev is running Alexander Aring
@ 2015-08-12 8:49 ` Stefan Schmidt
2015-08-15 11:50 ` Alexander Aring
1 sibling, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 8:49 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> We don't need to check if the wpan interface is running because the
> lowpan_rcv is the packet layer receive handler for thw wpan interface.
Typo. s/thw/the/
> This means for the check if the wpan interface is running ends always in
> true.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 6302b94..99aeb56 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -71,9 +71,6 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> if (!skb)
> goto drop;
>
> - if (!netif_running(wdev))
> - goto drop_skb;
> -
> if (skb->pkt_type == PACKET_OTHERHOST)
> goto drop_skb;
>
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [RFC 04/16] ieee802154: 6lowpan: remove check on wdev is running
2015-08-03 6:23 ` [RFC 04/16] ieee802154: 6lowpan: remove check on wdev is running Alexander Aring
2015-08-12 8:49 ` Stefan Schmidt
@ 2015-08-15 11:50 ` Alexander Aring
1 sibling, 0 replies; 44+ messages in thread
From: Alexander Aring @ 2015-08-15 11:50 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel
On Mon, Aug 03, 2015 at 08:23:43AM +0200, Alexander Aring wrote:
> We don't need to check if the wpan interface is running because the
> lowpan_rcv is the packet layer receive handler for thw wpan interface.
> This means for the check if the wpan interface is running ends always in
> true.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 6302b94..99aeb56 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -71,9 +71,6 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> if (!skb)
> goto drop;
>
> - if (!netif_running(wdev))
> - goto drop_skb;
> -
>
I think this check should be converted to check if lowpan_dev (which
belongs to the wdev) is running. Then we can drop it earlier. I think it
currently works because netif_rx handles that then when the interface is
down which belongs to the skb->dev.
There is a small window when the lowpan is down and while doing 6lowpan
stuff. It could be that the lowpan is set to up while doing the 6lowpan
stuff.
Vice versa it could be that the lowpan interface is up and then down
while doing 6lowpan stuff, but then again netif_rx will handle that
then right (I hope, since commit
e9e4dd3267d0c5234c5c0f47440456b10875dec9 "net: do not process device
backlog during unregistration" it does that with netif_running, but I
think there must be some machanism for that before otherwise we should
got issues when a lowpan_dev was down and receive skb's).
With changing this to netif_running according the lowpan_dev, we have
the second case only. Both cases are very unlikely.
It's just a likely case to have lowpan interface down and then we always
do 6lowpan adaptation layer and then netif_rx will drop it because
netif_running is false. We should check this earlier.
- Alex
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 05/16] ieee802154: 6lowpan: cleanup pull of iphc bytes
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (3 preceding siblings ...)
2015-08-03 6:23 ` [RFC 04/16] ieee802154: 6lowpan: remove check on wdev is running Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 9:03 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 06/16] ieee802154: 6lowpan: trivial checks at first Alexander Aring
` (11 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch cleanups the pull of the iphc bytes. We don't need to check
if the skb->len contains two bytes, this will be checked by
lowpan_fetch_skb_u8.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index 99aeb56..7b6b038 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -33,14 +33,9 @@ iphc_decompress(struct sk_buff *skb, const struct ieee802154_hdr *hdr)
void *sap, *dap;
raw_dump_table(__func__, "raw skb data dump", skb->data, skb->len);
- /* at least two bytes will be used for the encoding */
- if (skb->len < 2)
- return -EINVAL;
-
- if (lowpan_fetch_skb_u8(skb, &iphc0))
- return -EINVAL;
- if (lowpan_fetch_skb_u8(skb, &iphc1))
+ if (lowpan_fetch_skb_u8(skb, &iphc0) ||
+ lowpan_fetch_skb_u8(skb, &iphc1))
return -EINVAL;
ieee802154_addr_to_sa(&sa, &hdr->source);
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 05/16] ieee802154: 6lowpan: cleanup pull of iphc bytes
2015-08-03 6:23 ` [RFC 05/16] ieee802154: 6lowpan: cleanup pull of iphc bytes Alexander Aring
@ 2015-08-12 9:03 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 9:03 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This patch cleanups the pull of the iphc bytes. We don't need to check
> if the skb->len contains two bytes, this will be checked by
> lowpan_fetch_skb_u8.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 99aeb56..7b6b038 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -33,14 +33,9 @@ iphc_decompress(struct sk_buff *skb, const struct ieee802154_hdr *hdr)
> void *sap, *dap;
>
> raw_dump_table(__func__, "raw skb data dump", skb->data, skb->len);
> - /* at least two bytes will be used for the encoding */
> - if (skb->len < 2)
> - return -EINVAL;
> -
> - if (lowpan_fetch_skb_u8(skb, &iphc0))
> - return -EINVAL;
>
> - if (lowpan_fetch_skb_u8(skb, &iphc1))
> + if (lowpan_fetch_skb_u8(skb, &iphc0) ||
> + lowpan_fetch_skb_u8(skb, &iphc1))
> return -EINVAL;
>
> ieee802154_addr_to_sa(&sa, &hdr->source);
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 06/16] ieee802154: 6lowpan: trivial checks at first
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (4 preceding siblings ...)
2015-08-03 6:23 ` [RFC 05/16] ieee802154: 6lowpan: cleanup pull of iphc bytes Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 9:04 ` Stefan Schmidt
2015-08-15 9:15 ` Alexander Aring
2015-08-03 6:23 ` [RFC 07/16] ieee802154: 6lowpan: change skb->dev earlier Alexander Aring
` (10 subsequent siblings)
16 siblings, 2 replies; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch moves some trivial checks at first before calling
skb_share_check which could do some memcpy if the buffer is shared.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index 7b6b038..11a5629 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -62,16 +62,14 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
struct ieee802154_hdr hdr;
int ret;
+ if (skb->pkt_type == PACKET_OTHERHOST ||
+ wdev->type != ARPHRD_IEEE802154)
+ goto drop;
+
skb = skb_share_check(skb, GFP_ATOMIC);
if (!skb)
goto drop;
- if (skb->pkt_type == PACKET_OTHERHOST)
- goto drop_skb;
-
- if (wdev->type != ARPHRD_IEEE802154)
- goto drop_skb;
-
if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
goto drop_skb;
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 06/16] ieee802154: 6lowpan: trivial checks at first
2015-08-03 6:23 ` [RFC 06/16] ieee802154: 6lowpan: trivial checks at first Alexander Aring
@ 2015-08-12 9:04 ` Stefan Schmidt
2015-08-12 9:21 ` Alexander Aring
2015-08-15 9:15 ` Alexander Aring
1 sibling, 1 reply; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 9:04 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This patch moves some trivial checks at first before calling
> skb_share_check which could do some memcpy if the buffer is shared.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 7b6b038..11a5629 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -62,16 +62,14 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> struct ieee802154_hdr hdr;
> int ret;
>
> + if (skb->pkt_type == PACKET_OTHERHOST ||
> + wdev->type != ARPHRD_IEEE802154)
> + goto drop;
> +
> skb = skb_share_check(skb, GFP_ATOMIC);
> if (!skb)
> goto drop;
>
> - if (skb->pkt_type == PACKET_OTHERHOST)
> - goto drop_skb;
> -
> - if (wdev->type != ARPHRD_IEEE802154)
> - goto drop_skb;
> -
> if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
> goto drop_skb;
>
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [RFC 06/16] ieee802154: 6lowpan: trivial checks at first
2015-08-12 9:04 ` Stefan Schmidt
@ 2015-08-12 9:21 ` Alexander Aring
0 siblings, 0 replies; 44+ messages in thread
From: Alexander Aring @ 2015-08-12 9:21 UTC (permalink / raw)
To: Stefan Schmidt; +Cc: linux-wpan, kernel
On Wed, Aug 12, 2015 at 11:04:18AM +0200, Stefan Schmidt wrote:
> Hello.
>
> On 03/08/15 08:23, Alexander Aring wrote:
> >This patch moves some trivial checks at first before calling
> >skb_share_check which could do some memcpy if the buffer is shared.
> >
> >Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> >---
> > net/ieee802154/6lowpan/rx.c | 10 ++++------
> > 1 file changed, 4 insertions(+), 6 deletions(-)
> >
> >diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> >index 7b6b038..11a5629 100644
> >--- a/net/ieee802154/6lowpan/rx.c
> >+++ b/net/ieee802154/6lowpan/rx.c
> >@@ -62,16 +62,14 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> > struct ieee802154_hdr hdr;
> > int ret;
> >+ if (skb->pkt_type == PACKET_OTHERHOST ||
> >+ wdev->type != ARPHRD_IEEE802154)
> >+ goto drop;
> >+
> > skb = skb_share_check(skb, GFP_ATOMIC);
> > if (!skb)
> > goto drop;
> >- if (skb->pkt_type == PACKET_OTHERHOST)
> >- goto drop_skb;
> >-
> >- if (wdev->type != ARPHRD_IEEE802154)
> >- goto drop_skb;
> >-
> > if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
> > goto drop_skb;
>
> Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
>
Maybe I should switch also the conditions, means first check on
wdev-type. Because this function is called for all registered net_devices
(in my opinion) and do first check on type ARPHRD_IEEE802154 sounds more
resonable. We don't care about the other stuff (means different types).
In short: I think "wdev->type != ARPHRD_IEEE802154" is a more likely case
than "skb->pkt_type == PACKET_OTHERHOST".
- Alex
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [RFC 06/16] ieee802154: 6lowpan: trivial checks at first
2015-08-03 6:23 ` [RFC 06/16] ieee802154: 6lowpan: trivial checks at first Alexander Aring
2015-08-12 9:04 ` Stefan Schmidt
@ 2015-08-15 9:15 ` Alexander Aring
1 sibling, 0 replies; 44+ messages in thread
From: Alexander Aring @ 2015-08-15 9:15 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel
On Mon, Aug 03, 2015 at 08:23:45AM +0200, Alexander Aring wrote:
> This patch moves some trivial checks at first before calling
> skb_share_check which could do some memcpy if the buffer is shared.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 7b6b038..11a5629 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -62,16 +62,14 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> struct ieee802154_hdr hdr;
> int ret;
>
> + if (skb->pkt_type == PACKET_OTHERHOST ||
> + wdev->type != ARPHRD_IEEE802154)
> + goto drop;
> +
> skb = skb_share_check(skb, GFP_ATOMIC);
> if (!skb)
> goto drop;
mhhh, nothing according to the patch but I think "skb_share_check" is
wrong here and this depends on the dispatch value.
Why it's wrong?
When we do iphc_decompress we manipulate the buffer but "skb_share_check"
unshare the "skb structure" only.
That's the different between skb_clone and skb_copy. skb_clone doesn't
"copy" the buffer, the buffer is still shared afterwards when it's
shared.
Sometimes like ipv6 dispatch we only run skb_pull, then we need
"skb_share_check" only, because skb_pull doesn't manipulate the buffer,
it's doing only some pointer moving inside "skb structure" so skb_clone
if it's shared is enough, skb_clone is too much.
I would remove this from the lowpan_rcv and we need to care that this
function does read_only on "skb buffer" and "skb structure", then we
don't need to call anything.
To do "skb_share_check" (skb_clone if shared) or "skb_unshare" (skb_copy
if shared), should be handled by the dispatch handlers lowpan_rx_h_ipv6,
lowpan_rx_h_iphc, lowpan_rx_h_....
- Alex
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 07/16] ieee802154: 6lowpan: change skb->dev earlier
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (5 preceding siblings ...)
2015-08-03 6:23 ` [RFC 06/16] ieee802154: 6lowpan: trivial checks at first Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 9:13 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 08/16] ieee802154: 6lowpan: change frag return value handling Alexander Aring
` (9 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
We should change the skb->dev pointer earlier to the lowpan interface.
Sometimes we call iphc_decompress which also use some netdev printout
functionality. This patch will change that the correct interface will be
displayed in this case, which should be the lowpan interface.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index 11a5629..3871804a 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -15,10 +15,8 @@
#include "6lowpan_i.h"
-static int lowpan_give_skb_to_device(struct sk_buff *skb,
- struct net_device *wdev)
+static int lowpan_give_skb_to_device(struct sk_buff *skb)
{
- skb->dev = wdev->ieee802154_ptr->lowpan_dev;
skb->protocol = htons(ETH_P_IPV6);
skb->pkt_type = PACKET_HOST;
@@ -73,11 +71,13 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
goto drop_skb;
+ skb->dev = wdev->ieee802154_ptr->lowpan_dev;
+
/* check that it's our buffer */
if (skb->data[0] == LOWPAN_DISPATCH_IPV6) {
/* Pull off the 1-byte of 6lowpan header. */
skb_pull(skb, 1);
- return lowpan_give_skb_to_device(skb, wdev);
+ return lowpan_give_skb_to_device(skb);
} else {
switch (skb->data[0] & 0xe0) {
case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */
@@ -85,7 +85,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
if (ret < 0)
goto drop_skb;
- return lowpan_give_skb_to_device(skb, wdev);
+ return lowpan_give_skb_to_device(skb);
case LOWPAN_DISPATCH_FRAG1: /* first fragment header */
ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAG1);
if (ret == 1) {
@@ -93,7 +93,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
if (ret < 0)
goto drop_skb;
- return lowpan_give_skb_to_device(skb, wdev);
+ return lowpan_give_skb_to_device(skb);
} else if (ret == -1) {
return NET_RX_DROP;
} else {
@@ -106,7 +106,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
if (ret < 0)
goto drop_skb;
- return lowpan_give_skb_to_device(skb, wdev);
+ return lowpan_give_skb_to_device(skb);
} else if (ret == -1) {
return NET_RX_DROP;
} else {
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 07/16] ieee802154: 6lowpan: change skb->dev earlier
2015-08-03 6:23 ` [RFC 07/16] ieee802154: 6lowpan: change skb->dev earlier Alexander Aring
@ 2015-08-12 9:13 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 9:13 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> We should change the skb->dev pointer earlier to the lowpan interface.
> Sometimes we call iphc_decompress which also use some netdev printout
> functionality. This patch will change that the correct interface will be
> displayed in this case, which should be the lowpan interface.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 11a5629..3871804a 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -15,10 +15,8 @@
>
> #include "6lowpan_i.h"
>
> -static int lowpan_give_skb_to_device(struct sk_buff *skb,
> - struct net_device *wdev)
> +static int lowpan_give_skb_to_device(struct sk_buff *skb)
> {
> - skb->dev = wdev->ieee802154_ptr->lowpan_dev;
> skb->protocol = htons(ETH_P_IPV6);
> skb->pkt_type = PACKET_HOST;
>
> @@ -73,11 +71,13 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
> goto drop_skb;
>
> + skb->dev = wdev->ieee802154_ptr->lowpan_dev;
> +
> /* check that it's our buffer */
> if (skb->data[0] == LOWPAN_DISPATCH_IPV6) {
> /* Pull off the 1-byte of 6lowpan header. */
> skb_pull(skb, 1);
> - return lowpan_give_skb_to_device(skb, wdev);
> + return lowpan_give_skb_to_device(skb);
> } else {
> switch (skb->data[0] & 0xe0) {
> case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */
> @@ -85,7 +85,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> if (ret < 0)
> goto drop_skb;
>
> - return lowpan_give_skb_to_device(skb, wdev);
> + return lowpan_give_skb_to_device(skb);
> case LOWPAN_DISPATCH_FRAG1: /* first fragment header */
> ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAG1);
> if (ret == 1) {
> @@ -93,7 +93,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> if (ret < 0)
> goto drop_skb;
>
> - return lowpan_give_skb_to_device(skb, wdev);
> + return lowpan_give_skb_to_device(skb);
> } else if (ret == -1) {
> return NET_RX_DROP;
> } else {
> @@ -106,7 +106,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> if (ret < 0)
> goto drop_skb;
>
> - return lowpan_give_skb_to_device(skb, wdev);
> + return lowpan_give_skb_to_device(skb);
> } else if (ret == -1) {
> return NET_RX_DROP;
> } else {
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 08/16] ieee802154: 6lowpan: change frag return value handling
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (6 preceding siblings ...)
2015-08-03 6:23 ` [RFC 07/16] ieee802154: 6lowpan: change skb->dev earlier Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 9:14 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 09/16] ieee820154: 6lowpan: dispatch evaluation rework Alexander Aring
` (8 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
The function lowpan_frag_rcv does return only:
- "1": skb is reassmbled
- "-1": skb is putted into the frag bucket or failure.
Other values can't happend. This patch will change that we return on "1"
the return value of netif_rx and "-1" to NET_RX_DROP, which means that
the packet doesn't reach the next layer.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index 3871804a..bf6e857 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -94,11 +94,9 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
goto drop_skb;
return lowpan_give_skb_to_device(skb);
- } else if (ret == -1) {
- return NET_RX_DROP;
- } else {
- return NET_RX_SUCCESS;
}
+
+ return NET_RX_DROP;
case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */
ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAGN);
if (ret == 1) {
@@ -107,11 +105,9 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
goto drop_skb;
return lowpan_give_skb_to_device(skb);
- } else if (ret == -1) {
- return NET_RX_DROP;
- } else {
- return NET_RX_SUCCESS;
}
+
+ return NET_RX_DROP;
default:
break;
}
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 08/16] ieee802154: 6lowpan: change frag return value handling
2015-08-03 6:23 ` [RFC 08/16] ieee802154: 6lowpan: change frag return value handling Alexander Aring
@ 2015-08-12 9:14 ` Stefan Schmidt
2015-08-12 9:26 ` Alexander Aring
0 siblings, 1 reply; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 9:14 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> The function lowpan_frag_rcv does return only:
>
> - "1": skb is reassmbled
> - "-1": skb is putted into the frag bucket or failure.
>
> Other values can't happend. This patch will change that we return on "1"
> the return value of netif_rx and "-1" to NET_RX_DROP, which means that
> the packet doesn't reach the next layer.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 3871804a..bf6e857 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -94,11 +94,9 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> goto drop_skb;
>
> return lowpan_give_skb_to_device(skb);
> - } else if (ret == -1) {
> - return NET_RX_DROP;
> - } else {
> - return NET_RX_SUCCESS;
> }
> +
> + return NET_RX_DROP;
> case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */
> ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAGN);
> if (ret == 1) {
> @@ -107,11 +105,9 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> goto drop_skb;
>
> return lowpan_give_skb_to_device(skb);
> - } else if (ret == -1) {
> - return NET_RX_DROP;
> - } else {
> - return NET_RX_SUCCESS;
> }
> +
> + return NET_RX_DROP;
> default:
> break;
> }
Looking at the next patch (9) to me it looks like this one could get
folded in it as the part you change here gets a rewrite anyway.
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread* Re: [RFC 08/16] ieee802154: 6lowpan: change frag return value handling
2015-08-12 9:14 ` Stefan Schmidt
@ 2015-08-12 9:26 ` Alexander Aring
0 siblings, 0 replies; 44+ messages in thread
From: Alexander Aring @ 2015-08-12 9:26 UTC (permalink / raw)
To: Stefan Schmidt; +Cc: linux-wpan, kernel
On Wed, Aug 12, 2015 at 11:14:11AM +0200, Stefan Schmidt wrote:
> Hello.
>
> On 03/08/15 08:23, Alexander Aring wrote:
> >The function lowpan_frag_rcv does return only:
> >
> > - "1": skb is reassmbled
> > - "-1": skb is putted into the frag bucket or failure.
> >
> >Other values can't happend. This patch will change that we return on "1"
> >the return value of netif_rx and "-1" to NET_RX_DROP, which means that
> >the packet doesn't reach the next layer.
> >
> >Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> >---
> > net/ieee802154/6lowpan/rx.c | 12 ++++--------
> > 1 file changed, 4 insertions(+), 8 deletions(-)
> >
> >diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> >index 3871804a..bf6e857 100644
> >--- a/net/ieee802154/6lowpan/rx.c
> >+++ b/net/ieee802154/6lowpan/rx.c
> >@@ -94,11 +94,9 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> > goto drop_skb;
> > return lowpan_give_skb_to_device(skb);
> >- } else if (ret == -1) {
> >- return NET_RX_DROP;
> >- } else {
> >- return NET_RX_SUCCESS;
> > }
> >+
> >+ return NET_RX_DROP;
> > case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */
> > ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAGN);
> > if (ret == 1) {
> >@@ -107,11 +105,9 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> > goto drop_skb;
> > return lowpan_give_skb_to_device(skb);
> >- } else if (ret == -1) {
> >- return NET_RX_DROP;
> >- } else {
> >- return NET_RX_SUCCESS;
> > }
> >+
> >+ return NET_RX_DROP;
> > default:
> > break;
> > }
>
> Looking at the next patch (9) to me it looks like this one could get folded
> in it as the part you change here gets a rewrite anyway.
>
ok.
- Alex
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 09/16] ieee820154: 6lowpan: dispatch evaluation rework
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (7 preceding siblings ...)
2015-08-03 6:23 ` [RFC 08/16] ieee802154: 6lowpan: change frag return value handling Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 12:51 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 10/16] ieee802154: 6lowpan: add dispatch evalualtion helpers Alexander Aring
` (7 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch complete reworks the evaluation of 6lowpan dispatch value by
introducing several different handlers for each dispatch value. This
patch also fixes a bug to re-evaluate the dispatch value after reassmble
while fragmentation. Currently we always assume that we have an IPHC
header there.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 155 +++++++++++++++++++++++++++++---------------
1 file changed, 101 insertions(+), 54 deletions(-)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index bf6e857..c7afd4a 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -15,12 +15,42 @@
#include "6lowpan_i.h"
+typedef unsigned __bitwise__ lowpan_rx_result;
+#define RX_CONTINUE ((__force lowpan_rx_result) 0u)
+#define RX_DROP_UNUSABLE ((__force lowpan_rx_result) 1u)
+#define RX_DROP ((__force lowpan_rx_result) 2u)
+#define RX_QUEUED ((__force lowpan_rx_result) 3u)
+
+static int
+lowpan_rx_handlers_result(struct sk_buff *skb, lowpan_rx_result res)
+{
+ switch (res) {
+ /* nobody cared about this packet */
+ case RX_CONTINUE:
+ case RX_DROP_UNUSABLE:
+ kfree_skb(skb);
+ case RX_DROP:
+ return NET_RX_DROP;
+ default:
+ break;
+ }
+
+ return NET_RX_SUCCESS;
+}
+
static int lowpan_give_skb_to_device(struct sk_buff *skb)
{
+ int ret;
+
skb->protocol = htons(ETH_P_IPV6);
skb->pkt_type = PACKET_HOST;
- return netif_rx(skb);
+ ret = netif_rx(skb);
+ /* kfree_skb handled by netif_rx, so RX_DROP on failure */
+ if (ret == NET_RX_SUCCESS)
+ return RX_QUEUED;
+ else
+ return RX_DROP;
}
static int
@@ -54,69 +84,86 @@ iphc_decompress(struct sk_buff *skb, const struct ieee802154_hdr *hdr)
IEEE802154_ADDR_LEN, iphc0, iphc1);
}
-static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
- struct packet_type *pt, struct net_device *orig_wdev)
+static lowpan_rx_result lowpan_rx_h_ipv6(struct sk_buff *skb)
+{
+ if (skb->data[0] != LOWPAN_DISPATCH_IPV6)
+ return RX_CONTINUE;
+
+ /* Pull off the 1-byte of 6lowpan header. */
+ skb_pull(skb, 1);
+ return lowpan_give_skb_to_device(skb);
+}
+
+static lowpan_rx_result lowpan_rx_h_frag(struct sk_buff *skb)
+{
+ int ret;
+
+ if ((skb->data[0] & 0xe0) != LOWPAN_DISPATCH_FRAG1 &&
+ (skb->data[0] & 0xe0) != LOWPAN_DISPATCH_FRAGN)
+ return RX_CONTINUE;
+
+ ret = lowpan_frag_rcv(skb, skb->data[0] & 0xe0);
+ if (ret == 1)
+ return RX_CONTINUE;
+
+ /* packet is dropped and putted into the frag bucket only */
+ return RX_DROP;
+}
+
+static lowpan_rx_result lowpan_rx_h_iphc(struct sk_buff *skb)
{
- struct ieee802154_hdr hdr;
int ret;
+ struct ieee802154_hdr hdr;
+
+ if ((skb->data[0] & 0xe0) != LOWPAN_DISPATCH_IPHC)
+ return RX_CONTINUE;
+
+ if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
+ return RX_DROP_UNUSABLE;
+
+ ret = iphc_decompress(skb, &hdr);
+ if (ret < 0)
+ return RX_DROP_UNUSABLE;
+
+ return lowpan_give_skb_to_device(skb);
+}
+
+int lowpan_invoke_rx_handlers(struct sk_buff *skb)
+{
+ lowpan_rx_result res;
+
+#define CALL_RXH(rxh) \
+ do { \
+ res = rxh(skb); \
+ if (res != RX_CONTINUE) \
+ goto rxh_next; \
+ } while (0)
+
+ /* frag at first, because it contains dispatch value again */
+ CALL_RXH(lowpan_rx_h_frag);
+ /* likely at first */
+ CALL_RXH(lowpan_rx_h_iphc);
+ CALL_RXH(lowpan_rx_h_ipv6);
+
+rxh_next:
+ return lowpan_rx_handlers_result(skb, res);
+#undef CALL_RXH
+}
+
+static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
+ struct packet_type *pt, struct net_device *orig_wdev)
+{
if (skb->pkt_type == PACKET_OTHERHOST ||
wdev->type != ARPHRD_IEEE802154)
- goto drop;
+ return NET_RX_DROP;
skb = skb_share_check(skb, GFP_ATOMIC);
if (!skb)
- goto drop;
-
- if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
- goto drop_skb;
+ return NET_RX_DROP;
skb->dev = wdev->ieee802154_ptr->lowpan_dev;
-
- /* check that it's our buffer */
- if (skb->data[0] == LOWPAN_DISPATCH_IPV6) {
- /* Pull off the 1-byte of 6lowpan header. */
- skb_pull(skb, 1);
- return lowpan_give_skb_to_device(skb);
- } else {
- switch (skb->data[0] & 0xe0) {
- case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */
- ret = iphc_decompress(skb, &hdr);
- if (ret < 0)
- goto drop_skb;
-
- return lowpan_give_skb_to_device(skb);
- case LOWPAN_DISPATCH_FRAG1: /* first fragment header */
- ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAG1);
- if (ret == 1) {
- ret = iphc_decompress(skb, &hdr);
- if (ret < 0)
- goto drop_skb;
-
- return lowpan_give_skb_to_device(skb);
- }
-
- return NET_RX_DROP;
- case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */
- ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAGN);
- if (ret == 1) {
- ret = iphc_decompress(skb, &hdr);
- if (ret < 0)
- goto drop_skb;
-
- return lowpan_give_skb_to_device(skb);
- }
-
- return NET_RX_DROP;
- default:
- break;
- }
- }
-
-drop_skb:
- kfree_skb(skb);
-drop:
- return NET_RX_DROP;
+ return lowpan_invoke_rx_handlers(skb);
}
static struct packet_type lowpan_packet_type = {
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 09/16] ieee820154: 6lowpan: dispatch evaluation rework
2015-08-03 6:23 ` [RFC 09/16] ieee820154: 6lowpan: dispatch evaluation rework Alexander Aring
@ 2015-08-12 12:51 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 12:51 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This patch complete reworks the evaluation of 6lowpan dispatch value by
> introducing several different handlers for each dispatch value. This
> patch also fixes a bug to re-evaluate the dispatch value after reassmble
> while fragmentation. Currently we always assume that we have an IPHC
> header there.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 155 +++++++++++++++++++++++++++++---------------
> 1 file changed, 101 insertions(+), 54 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index bf6e857..c7afd4a 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -15,12 +15,42 @@
>
> #include "6lowpan_i.h"
>
> +typedef unsigned __bitwise__ lowpan_rx_result;
> +#define RX_CONTINUE ((__force lowpan_rx_result) 0u)
> +#define RX_DROP_UNUSABLE ((__force lowpan_rx_result) 1u)
> +#define RX_DROP ((__force lowpan_rx_result) 2u)
> +#define RX_QUEUED ((__force lowpan_rx_result) 3u)
> +
> +static int
> +lowpan_rx_handlers_result(struct sk_buff *skb, lowpan_rx_result res)
> +{
> + switch (res) {
> + /* nobody cared about this packet */
> + case RX_CONTINUE:
> + case RX_DROP_UNUSABLE:
> + kfree_skb(skb);
> + case RX_DROP:
> + return NET_RX_DROP;
> + default:
> + break;
> + }
> +
> + return NET_RX_SUCCESS;
> +}
> +
> static int lowpan_give_skb_to_device(struct sk_buff *skb)
> {
> + int ret;
> +
> skb->protocol = htons(ETH_P_IPV6);
> skb->pkt_type = PACKET_HOST;
>
> - return netif_rx(skb);
> + ret = netif_rx(skb);
> + /* kfree_skb handled by netif_rx, so RX_DROP on failure */
> + if (ret == NET_RX_SUCCESS)
> + return RX_QUEUED;
> + else
> + return RX_DROP;
> }
>
> static int
> @@ -54,69 +84,86 @@ iphc_decompress(struct sk_buff *skb, const struct ieee802154_hdr *hdr)
> IEEE802154_ADDR_LEN, iphc0, iphc1);
> }
>
> -static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> - struct packet_type *pt, struct net_device *orig_wdev)
> +static lowpan_rx_result lowpan_rx_h_ipv6(struct sk_buff *skb)
> +{
> + if (skb->data[0] != LOWPAN_DISPATCH_IPV6)
> + return RX_CONTINUE;
> +
> + /* Pull off the 1-byte of 6lowpan header. */
> + skb_pull(skb, 1);
> + return lowpan_give_skb_to_device(skb);
> +}
> +
> +static lowpan_rx_result lowpan_rx_h_frag(struct sk_buff *skb)
> +{
> + int ret;
> +
> + if ((skb->data[0] & 0xe0) != LOWPAN_DISPATCH_FRAG1 &&
> + (skb->data[0] & 0xe0) != LOWPAN_DISPATCH_FRAGN)
> + return RX_CONTINUE;
> +
> + ret = lowpan_frag_rcv(skb, skb->data[0] & 0xe0);
You fix this mask in patch 11 later one. Maybe its worth merging this
fix in here? At least using 0xf8 as you only introduce the
LOWPAN_DISPATCH_FRAG_MASK in patch 10.
Nothing to problematic but I always wonder about such things when I see
a fix later in a series which was introduced/already touched earlier in
the series.
> + if (ret == 1)
> + return RX_CONTINUE;
> +
> + /* packet is dropped and putted into the frag bucket only */
s/putted/put/
> + return RX_DROP;
> +}
> +
> +static lowpan_rx_result lowpan_rx_h_iphc(struct sk_buff *skb)
> {
> - struct ieee802154_hdr hdr;
> int ret;
> + struct ieee802154_hdr hdr;
> +
> + if ((skb->data[0] & 0xe0) != LOWPAN_DISPATCH_IPHC)
All this use of 0xe0 is a bit annoying as the se magic value misses a
real meaning. Luckily I have just seen that you clean this up in the
next patch and it only is here as you broke up the code below into
pieces. Just keep it as patch 10 fixes this.
> + return RX_CONTINUE;
> +
> + if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
> + return RX_DROP_UNUSABLE;
> +
> + ret = iphc_decompress(skb, &hdr);
> + if (ret < 0)
> + return RX_DROP_UNUSABLE;
> +
> + return lowpan_give_skb_to_device(skb);
> +}
> +
> +int lowpan_invoke_rx_handlers(struct sk_buff *skb)
> +{
> + lowpan_rx_result res;
> +
> +#define CALL_RXH(rxh) \
> + do { \
> + res = rxh(skb); \
> + if (res != RX_CONTINUE) \
> + goto rxh_next; \
> + } while (0)
> +
> + /* frag at first, because it contains dispatch value again */
> + CALL_RXH(lowpan_rx_h_frag);
>
> + /* likely at first */
> + CALL_RXH(lowpan_rx_h_iphc);
> + CALL_RXH(lowpan_rx_h_ipv6);
> +
> +rxh_next:
> + return lowpan_rx_handlers_result(skb, res);
> +#undef CALL_RXH
> +}
> +
> +static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> + struct packet_type *pt, struct net_device *orig_wdev)
> +{
> if (skb->pkt_type == PACKET_OTHERHOST ||
> wdev->type != ARPHRD_IEEE802154)
> - goto drop;
> + return NET_RX_DROP;
>
> skb = skb_share_check(skb, GFP_ATOMIC);
> if (!skb)
> - goto drop;
> -
> - if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
> - goto drop_skb;
> + return NET_RX_DROP;
>
> skb->dev = wdev->ieee802154_ptr->lowpan_dev;
> -
> - /* check that it's our buffer */
> - if (skb->data[0] == LOWPAN_DISPATCH_IPV6) {
> - /* Pull off the 1-byte of 6lowpan header. */
> - skb_pull(skb, 1);
> - return lowpan_give_skb_to_device(skb);
> - } else {
> - switch (skb->data[0] & 0xe0) {
> - case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */
> - ret = iphc_decompress(skb, &hdr);
> - if (ret < 0)
> - goto drop_skb;
> -
> - return lowpan_give_skb_to_device(skb);
> - case LOWPAN_DISPATCH_FRAG1: /* first fragment header */
> - ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAG1);
> - if (ret == 1) {
> - ret = iphc_decompress(skb, &hdr);
> - if (ret < 0)
> - goto drop_skb;
> -
> - return lowpan_give_skb_to_device(skb);
> - }
> -
> - return NET_RX_DROP;
> - case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */
> - ret = lowpan_frag_rcv(skb, LOWPAN_DISPATCH_FRAGN);
> - if (ret == 1) {
> - ret = iphc_decompress(skb, &hdr);
> - if (ret < 0)
> - goto drop_skb;
> -
> - return lowpan_give_skb_to_device(skb);
> - }
> -
> - return NET_RX_DROP;
> - default:
> - break;
> - }
> - }
> -
> -drop_skb:
> - kfree_skb(skb);
> -drop:
> - return NET_RX_DROP;
> + return lowpan_invoke_rx_handlers(skb);
> }
>
> static struct packet_type lowpan_packet_type = {
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 10/16] ieee802154: 6lowpan: add dispatch evalualtion helpers
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (8 preceding siblings ...)
2015-08-03 6:23 ` [RFC 09/16] ieee820154: 6lowpan: dispatch evaluation rework Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 12:51 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 11/16] ieee802154: 6lowpan: fix fragmentation dispatch mask Alexander Aring
` (6 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch introduce some static inline function for checking the right
dispatch value. This also fixes an bug to detect the right fragmentation
dispatch value, we currently use "0xe0" as masking the fragmentation
dispatch. Correct is "0xf8" as mask.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
include/net/6lowpan.h | 18 +++++++++++++-----
net/ieee802154/6lowpan/6lowpan_i.h | 3 +++
net/ieee802154/6lowpan/rx.c | 30 +++++++++++++++++++++++++-----
3 files changed, 41 insertions(+), 10 deletions(-)
diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index e16763f..073c791 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -126,11 +126,19 @@
(((a)[6]) == 0xFF) && \
(((a)[7]) == 0xFF))
-#define LOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
-#define LOWPAN_DISPATCH_HC1 0x42 /* 01000010 = 66 */
-#define LOWPAN_DISPATCH_IPHC 0x60 /* 011xxxxx = ... */
-#define LOWPAN_DISPATCH_FRAG1 0xc0 /* 11000xxx */
-#define LOWPAN_DISPATCH_FRAGN 0xe0 /* 11100xxx */
+#define LOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
+#define LOWPAN_DISPATCH_IPHC 0x60 /* 011xxxxx = ... */
+#define LOWPAN_DISPATCH_IPHC_MASK 0xe0
+
+static inline bool lowpan_is_ipv6(u8 dispatch)
+{
+ return dispatch == LOWPAN_DISPATCH_IPV6;
+}
+
+static inline bool lowpan_is_iphc(u8 dispatch)
+{
+ return (dispatch & LOWPAN_DISPATCH_IPHC_MASK) == LOWPAN_DISPATCH_IPHC;
+}
#define LOWPAN_DISPATCH_MASK 0xf8 /* 11111000 */
diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
index d62046e..e009a4a 100644
--- a/net/ieee802154/6lowpan/6lowpan_i.h
+++ b/net/ieee802154/6lowpan/6lowpan_i.h
@@ -7,6 +7,9 @@
#include <net/inet_frag.h>
#include <net/6lowpan.h>
+#define LOWPAN_DISPATCH_FRAG1 0xc0
+#define LOWPAN_DISPATCH_FRAGN 0xe0
+
struct lowpan_create_arg {
u16 tag;
u16 d_size;
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index c7afd4a..b0066b7 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -21,6 +21,16 @@ typedef unsigned __bitwise__ lowpan_rx_result;
#define RX_DROP ((__force lowpan_rx_result) 2u)
#define RX_QUEUED ((__force lowpan_rx_result) 3u)
+#define LOWPAN_DISPATCH_FIRST 0xc0
+#define LOWPAN_DISPATCH_FRAG_MASK 0xf8
+#define LOWPAN_DISPATCH_IPHC_MASK 0xe0
+
+#define LOWPAN_DISPATCH_NALP 0x00
+#define LOWPAN_DISPATCH_HC1 0x42
+#define LOWPAN_DISPATCH_BC0 0x50
+#define LOWPAN_DISPATCH_ESC 0x7f
+#define LOWPAN_DISPATCH_MESH 0x80
+
static int
lowpan_rx_handlers_result(struct sk_buff *skb, lowpan_rx_result res)
{
@@ -86,7 +96,7 @@ iphc_decompress(struct sk_buff *skb, const struct ieee802154_hdr *hdr)
static lowpan_rx_result lowpan_rx_h_ipv6(struct sk_buff *skb)
{
- if (skb->data[0] != LOWPAN_DISPATCH_IPV6)
+ if (!lowpan_is_ipv6(*skb_network_header(skb)))
return RX_CONTINUE;
/* Pull off the 1-byte of 6lowpan header. */
@@ -94,15 +104,25 @@ static lowpan_rx_result lowpan_rx_h_ipv6(struct sk_buff *skb)
return lowpan_give_skb_to_device(skb);
}
+static inline bool lowpan_is_frag1(u8 dispatch)
+{
+ return (dispatch & LOWPAN_DISPATCH_FRAG_MASK) == LOWPAN_DISPATCH_FRAG1;
+}
+
+static inline bool lowpan_is_fragn(u8 dispatch)
+{
+ return (dispatch & LOWPAN_DISPATCH_FRAG_MASK) == LOWPAN_DISPATCH_FRAGN;
+}
+
static lowpan_rx_result lowpan_rx_h_frag(struct sk_buff *skb)
{
int ret;
- if ((skb->data[0] & 0xe0) != LOWPAN_DISPATCH_FRAG1 &&
- (skb->data[0] & 0xe0) != LOWPAN_DISPATCH_FRAGN)
+ if (!(lowpan_is_frag1(*skb_network_header(skb)) ||
+ lowpan_is_fragn(*skb_network_header(skb))))
return RX_CONTINUE;
- ret = lowpan_frag_rcv(skb, skb->data[0] & 0xe0);
+ ret = lowpan_frag_rcv(skb, *skb_network_header(skb) & 0xe0);
if (ret == 1)
return RX_CONTINUE;
@@ -115,7 +135,7 @@ static lowpan_rx_result lowpan_rx_h_iphc(struct sk_buff *skb)
int ret;
struct ieee802154_hdr hdr;
- if ((skb->data[0] & 0xe0) != LOWPAN_DISPATCH_IPHC)
+ if (!lowpan_is_iphc(*skb_network_header(skb)))
return RX_CONTINUE;
if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 10/16] ieee802154: 6lowpan: add dispatch evalualtion helpers
2015-08-03 6:23 ` [RFC 10/16] ieee802154: 6lowpan: add dispatch evalualtion helpers Alexander Aring
@ 2015-08-12 12:51 ` Stefan Schmidt
2015-08-12 13:20 ` Alexander Aring
0 siblings, 1 reply; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 12:51 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
typo in subject. s/evalualtion/evaluation/
On 03/08/15 08:23, Alexander Aring wrote:
> This patch introduce some static inline function for checking the right
> dispatch value. This also fixes an bug to detect the right fragmentation
> dispatch value, we currently use "0xe0" as masking the fragmentation
> dispatch. Correct is "0xf8" as mask.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> include/net/6lowpan.h | 18 +++++++++++++-----
> net/ieee802154/6lowpan/6lowpan_i.h | 3 +++
> net/ieee802154/6lowpan/rx.c | 30 +++++++++++++++++++++++++-----
> 3 files changed, 41 insertions(+), 10 deletions(-)
>
> diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
> index e16763f..073c791 100644
> --- a/include/net/6lowpan.h
> +++ b/include/net/6lowpan.h
> @@ -126,11 +126,19 @@
> (((a)[6]) == 0xFF) && \
> (((a)[7]) == 0xFF))
>
> -#define LOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
> -#define LOWPAN_DISPATCH_HC1 0x42 /* 01000010 = 66 */
> -#define LOWPAN_DISPATCH_IPHC 0x60 /* 011xxxxx = ... */
> -#define LOWPAN_DISPATCH_FRAG1 0xc0 /* 11000xxx */
> -#define LOWPAN_DISPATCH_FRAGN 0xe0 /* 11100xxx */
> +#define LOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
> +#define LOWPAN_DISPATCH_IPHC 0x60 /* 011xxxxx = ... */
> +#define LOWPAN_DISPATCH_IPHC_MASK 0xe0
> +
> +static inline bool lowpan_is_ipv6(u8 dispatch)
> +{
> + return dispatch == LOWPAN_DISPATCH_IPV6;
> +}
> +
> +static inline bool lowpan_is_iphc(u8 dispatch)
> +{
> + return (dispatch & LOWPAN_DISPATCH_IPHC_MASK) == LOWPAN_DISPATCH_IPHC;
> +}
>
> #define LOWPAN_DISPATCH_MASK 0xf8 /* 11111000 */
>
> diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
> index d62046e..e009a4a 100644
> --- a/net/ieee802154/6lowpan/6lowpan_i.h
> +++ b/net/ieee802154/6lowpan/6lowpan_i.h
> @@ -7,6 +7,9 @@
> #include <net/inet_frag.h>
> #include <net/6lowpan.h>
>
> +#define LOWPAN_DISPATCH_FRAG1 0xc0
> +#define LOWPAN_DISPATCH_FRAGN 0xe0
> +
> struct lowpan_create_arg {
> u16 tag;
> u16 d_size;
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index c7afd4a..b0066b7 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -21,6 +21,16 @@ typedef unsigned __bitwise__ lowpan_rx_result;
> #define RX_DROP ((__force lowpan_rx_result) 2u)
> #define RX_QUEUED ((__force lowpan_rx_result) 3u)
>
> +#define LOWPAN_DISPATCH_FIRST 0xc0
> +#define LOWPAN_DISPATCH_FRAG_MASK 0xf8
> +#define LOWPAN_DISPATCH_IPHC_MASK 0xe0
> +
> +#define LOWPAN_DISPATCH_NALP 0x00
> +#define LOWPAN_DISPATCH_HC1 0x42
> +#define LOWPAN_DISPATCH_BC0 0x50
> +#define LOWPAN_DISPATCH_ESC 0x7f
> +#define LOWPAN_DISPATCH_MESH 0x80
> +
Any specific reason you moved the *_HC1 define here (same for the *_FRAG
defines above)?
I would think having them all in 6lowpan.h would make most sense. You
might need them only in this file for now but later one maybe in another
file. It could be personal taste but having them all in one place should
be easier. imho.
> static int
> lowpan_rx_handlers_result(struct sk_buff *skb, lowpan_rx_result res)
> {
> @@ -86,7 +96,7 @@ iphc_decompress(struct sk_buff *skb, const struct ieee802154_hdr *hdr)
>
> static lowpan_rx_result lowpan_rx_h_ipv6(struct sk_buff *skb)
> {
> - if (skb->data[0] != LOWPAN_DISPATCH_IPV6)
> + if (!lowpan_is_ipv6(*skb_network_header(skb)))
> return RX_CONTINUE;
>
> /* Pull off the 1-byte of 6lowpan header. */
> @@ -94,15 +104,25 @@ static lowpan_rx_result lowpan_rx_h_ipv6(struct sk_buff *skb)
> return lowpan_give_skb_to_device(skb);
> }
>
> +static inline bool lowpan_is_frag1(u8 dispatch)
> +{
> + return (dispatch & LOWPAN_DISPATCH_FRAG_MASK) == LOWPAN_DISPATCH_FRAG1;
> +}
> +
> +static inline bool lowpan_is_fragn(u8 dispatch)
> +{
> + return (dispatch & LOWPAN_DISPATCH_FRAG_MASK) == LOWPAN_DISPATCH_FRAGN;
> +}
> +
> static lowpan_rx_result lowpan_rx_h_frag(struct sk_buff *skb)
> {
> int ret;
>
> - if ((skb->data[0] & 0xe0) != LOWPAN_DISPATCH_FRAG1 &&
> - (skb->data[0] & 0xe0) != LOWPAN_DISPATCH_FRAGN)
> + if (!(lowpan_is_frag1(*skb_network_header(skb)) ||
> + lowpan_is_fragn(*skb_network_header(skb))))
> return RX_CONTINUE;
>
> - ret = lowpan_frag_rcv(skb, skb->data[0] & 0xe0);
> + ret = lowpan_frag_rcv(skb, *skb_network_header(skb) & 0xe0);
> if (ret == 1)
> return RX_CONTINUE;
>
> @@ -115,7 +135,7 @@ static lowpan_rx_result lowpan_rx_h_iphc(struct sk_buff *skb)
> int ret;
> struct ieee802154_hdr hdr;
>
> - if ((skb->data[0] & 0xe0) != LOWPAN_DISPATCH_IPHC)
> + if (!lowpan_is_iphc(*skb_network_header(skb)))
> return RX_CONTINUE;
>
> if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
6lowpan.h
^ permalink raw reply [flat|nested] 44+ messages in thread* Re: [RFC 10/16] ieee802154: 6lowpan: add dispatch evalualtion helpers
2015-08-12 12:51 ` Stefan Schmidt
@ 2015-08-12 13:20 ` Alexander Aring
2015-08-12 13:48 ` Stefan Schmidt
0 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-12 13:20 UTC (permalink / raw)
To: Stefan Schmidt; +Cc: linux-wpan, kernel
On Wed, Aug 12, 2015 at 02:51:10PM +0200, Stefan Schmidt wrote:
> Hello.
>
> typo in subject. s/evalualtion/evaluation/
>
ok.
> On 03/08/15 08:23, Alexander Aring wrote:
> >This patch introduce some static inline function for checking the right
> >dispatch value. This also fixes an bug to detect the right fragmentation
> >dispatch value, we currently use "0xe0" as masking the fragmentation
> >dispatch. Correct is "0xf8" as mask.
> >
> >Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> >---
> > include/net/6lowpan.h | 18 +++++++++++++-----
> > net/ieee802154/6lowpan/6lowpan_i.h | 3 +++
> > net/ieee802154/6lowpan/rx.c | 30 +++++++++++++++++++++++++-----
> > 3 files changed, 41 insertions(+), 10 deletions(-)
> >
> >diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
> >index e16763f..073c791 100644
> >--- a/include/net/6lowpan.h
> >+++ b/include/net/6lowpan.h
> >@@ -126,11 +126,19 @@
> > (((a)[6]) == 0xFF) && \
> > (((a)[7]) == 0xFF))
> >-#define LOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
> >-#define LOWPAN_DISPATCH_HC1 0x42 /* 01000010 = 66 */
> >-#define LOWPAN_DISPATCH_IPHC 0x60 /* 011xxxxx = ... */
> >-#define LOWPAN_DISPATCH_FRAG1 0xc0 /* 11000xxx */
> >-#define LOWPAN_DISPATCH_FRAGN 0xe0 /* 11100xxx */
> >+#define LOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
> >+#define LOWPAN_DISPATCH_IPHC 0x60 /* 011xxxxx = ... */
> >+#define LOWPAN_DISPATCH_IPHC_MASK 0xe0
> >+
> >+static inline bool lowpan_is_ipv6(u8 dispatch)
> >+{
> >+ return dispatch == LOWPAN_DISPATCH_IPV6;
> >+}
> >+
> >+static inline bool lowpan_is_iphc(u8 dispatch)
> >+{
> >+ return (dispatch & LOWPAN_DISPATCH_IPHC_MASK) == LOWPAN_DISPATCH_IPHC;
> >+}
> > #define LOWPAN_DISPATCH_MASK 0xf8 /* 11111000 */
> >diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
> >index d62046e..e009a4a 100644
> >--- a/net/ieee802154/6lowpan/6lowpan_i.h
> >+++ b/net/ieee802154/6lowpan/6lowpan_i.h
> >@@ -7,6 +7,9 @@
> > #include <net/inet_frag.h>
> > #include <net/6lowpan.h>
> >+#define LOWPAN_DISPATCH_FRAG1 0xc0
> >+#define LOWPAN_DISPATCH_FRAGN 0xe0
> >+
> > struct lowpan_create_arg {
> > u16 tag;
> > u16 d_size;
> >diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> >index c7afd4a..b0066b7 100644
> >--- a/net/ieee802154/6lowpan/rx.c
> >+++ b/net/ieee802154/6lowpan/rx.c
> >@@ -21,6 +21,16 @@ typedef unsigned __bitwise__ lowpan_rx_result;
> > #define RX_DROP ((__force lowpan_rx_result) 2u)
> > #define RX_QUEUED ((__force lowpan_rx_result) 3u)
> >+#define LOWPAN_DISPATCH_FIRST 0xc0
> >+#define LOWPAN_DISPATCH_FRAG_MASK 0xf8
> >+#define LOWPAN_DISPATCH_IPHC_MASK 0xe0
> >+
> >+#define LOWPAN_DISPATCH_NALP 0x00
> >+#define LOWPAN_DISPATCH_HC1 0x42
> >+#define LOWPAN_DISPATCH_BC0 0x50
> >+#define LOWPAN_DISPATCH_ESC 0x7f
> >+#define LOWPAN_DISPATCH_MESH 0x80
> >+
>
> Any specific reason you moved the *_HC1 define here (same for the *_FRAG
> defines above)?
>
> I would think having them all in 6lowpan.h would make most sense. You might
> need them only in this file for now but later one maybe in another file. It
> could be personal taste but having them all in one place should be easier.
> imho.
There exists 6LoWPAN functionality which is shared between BTLE 6LoWPAN
and IEEE 802.15.4 6LoWPAN, these are:
- IPHC
- IPV6
they use both the same dispatch values.
The file "include/net/6lowpan.h" is part of the generic 6LoWPAN branch,
so functionality which belongs to "IPHC" and "IPv6" (IPv6 dispatch is
the easiest dispatch, there is only maybe this one inline function).
The other dispatches are not defined for BTLE, e.g. fragmentation is
handled by MAC layer of BTLE so far I know. Also HC1 is not defined for
BTLE 6LoWPAN.
HC1 is also deprecated, I think there will come no other 6LoWPAN
standard which supports this format. (IPHC is the replacement, See [0],
"MAY implement decompression according to Section 10 of [RFC4944] but
SHOULD NOT send packets compressed according to.." with otherwords we
should support receiving of HC1 but not sending HC1 anymore.)
If there comming new 6LoWPAN standards then we can later move these
dispatch values to generic 6LoWPAN branch (and maybe more, like
fragmentation framework) if they share these dispatches and also
implement if it looks almost the same.
Nevertheless 6LoWPAN things which is not shared between two or more
link-layer 6LoWPAN types should NOT go into the 6LoWPAN generic branch.
btw:
This is currently not true, "net/include/6lowpan.h" contains some
defines which we should put into net/6lowpan/iphc.c (all IPHC defines
which is used inside "iphc.c") and some things which are used in
802.15.4 6LoWPAN only.
This is all currently not clear and we need some another round for this
to cleanup. (Usually I do send patch-series under 25 patches to have
some milestones).
- Alex
[0] https://tools.ietf.org/html/rfc6282#section-2
^ permalink raw reply [flat|nested] 44+ messages in thread* Re: [RFC 10/16] ieee802154: 6lowpan: add dispatch evalualtion helpers
2015-08-12 13:20 ` Alexander Aring
@ 2015-08-12 13:48 ` Stefan Schmidt
2015-08-12 13:55 ` Alexander Aring
0 siblings, 1 reply; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 13:48 UTC (permalink / raw)
To: Alexander Aring; +Cc: linux-wpan, kernel
Hello.
On 12/08/15 15:20, Alexander Aring wrote:
> On Wed, Aug 12, 2015 at 02:51:10PM +0200, Stefan Schmidt wrote:
>> Hello.
>>
>> typo in subject. s/evalualtion/evaluation/
>>
> ok.
>
>> On 03/08/15 08:23, Alexander Aring wrote:
>>> This patch introduce some static inline function for checking the right
>>> dispatch value. This also fixes an bug to detect the right fragmentation
>>> dispatch value, we currently use "0xe0" as masking the fragmentation
>>> dispatch. Correct is "0xf8" as mask.
>>>
>>> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
>>> ---
>>> include/net/6lowpan.h | 18 +++++++++++++-----
>>> net/ieee802154/6lowpan/6lowpan_i.h | 3 +++
>>> net/ieee802154/6lowpan/rx.c | 30 +++++++++++++++++++++++++-----
>>> 3 files changed, 41 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
>>> index e16763f..073c791 100644
>>> --- a/include/net/6lowpan.h
>>> +++ b/include/net/6lowpan.h
>>> @@ -126,11 +126,19 @@
>>> (((a)[6]) == 0xFF) && \
>>> (((a)[7]) == 0xFF))
>>> -#define LOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
>>> -#define LOWPAN_DISPATCH_HC1 0x42 /* 01000010 = 66 */
>>> -#define LOWPAN_DISPATCH_IPHC 0x60 /* 011xxxxx = ... */
>>> -#define LOWPAN_DISPATCH_FRAG1 0xc0 /* 11000xxx */
>>> -#define LOWPAN_DISPATCH_FRAGN 0xe0 /* 11100xxx */
>>> +#define LOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
>>> +#define LOWPAN_DISPATCH_IPHC 0x60 /* 011xxxxx = ... */
>>> +#define LOWPAN_DISPATCH_IPHC_MASK 0xe0
>>> +
>>> +static inline bool lowpan_is_ipv6(u8 dispatch)
>>> +{
>>> + return dispatch == LOWPAN_DISPATCH_IPV6;
>>> +}
>>> +
>>> +static inline bool lowpan_is_iphc(u8 dispatch)
>>> +{
>>> + return (dispatch & LOWPAN_DISPATCH_IPHC_MASK) == LOWPAN_DISPATCH_IPHC;
>>> +}
>>> #define LOWPAN_DISPATCH_MASK 0xf8 /* 11111000 */
>>> diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
>>> index d62046e..e009a4a 100644
>>> --- a/net/ieee802154/6lowpan/6lowpan_i.h
>>> +++ b/net/ieee802154/6lowpan/6lowpan_i.h
>>> @@ -7,6 +7,9 @@
>>> #include <net/inet_frag.h>
>>> #include <net/6lowpan.h>
>>> +#define LOWPAN_DISPATCH_FRAG1 0xc0
>>> +#define LOWPAN_DISPATCH_FRAGN 0xe0
>>> +
>>> struct lowpan_create_arg {
>>> u16 tag;
>>> u16 d_size;
>>> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
>>> index c7afd4a..b0066b7 100644
>>> --- a/net/ieee802154/6lowpan/rx.c
>>> +++ b/net/ieee802154/6lowpan/rx.c
>>> @@ -21,6 +21,16 @@ typedef unsigned __bitwise__ lowpan_rx_result;
>>> #define RX_DROP ((__force lowpan_rx_result) 2u)
>>> #define RX_QUEUED ((__force lowpan_rx_result) 3u)
>>> +#define LOWPAN_DISPATCH_FIRST 0xc0
>>> +#define LOWPAN_DISPATCH_FRAG_MASK 0xf8
>>> +#define LOWPAN_DISPATCH_IPHC_MASK 0xe0
>>> +
>>> +#define LOWPAN_DISPATCH_NALP 0x00
>>> +#define LOWPAN_DISPATCH_HC1 0x42
>>> +#define LOWPAN_DISPATCH_BC0 0x50
>>> +#define LOWPAN_DISPATCH_ESC 0x7f
>>> +#define LOWPAN_DISPATCH_MESH 0x80
>>> +
>> Any specific reason you moved the *_HC1 define here (same for the *_FRAG
>> defines above)?
>>
>> I would think having them all in 6lowpan.h would make most sense. You might
>> need them only in this file for now but later one maybe in another file. It
>> could be personal taste but having them all in one place should be easier.
>> imho.
> There exists 6LoWPAN functionality which is shared between BTLE 6LoWPAN
> and IEEE 802.15.4 6LoWPAN, these are:
>
> - IPHC
> - IPV6
>
> they use both the same dispatch values.
>
> The file "include/net/6lowpan.h" is part of the generic 6LoWPAN branch,
> so functionality which belongs to "IPHC" and "IPv6" (IPv6 dispatch is
> the easiest dispatch, there is only maybe this one inline function).
>
>
> The other dispatches are not defined for BTLE, e.g. fragmentation is
> handled by MAC layer of BTLE so far I know. Also HC1 is not defined for
> BTLE 6LoWPAN.
Ah, now I understand why you keep them separate. Just keep it like you
have in this case.
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread* Re: [RFC 10/16] ieee802154: 6lowpan: add dispatch evalualtion helpers
2015-08-12 13:48 ` Stefan Schmidt
@ 2015-08-12 13:55 ` Alexander Aring
0 siblings, 0 replies; 44+ messages in thread
From: Alexander Aring @ 2015-08-12 13:55 UTC (permalink / raw)
To: Stefan Schmidt; +Cc: linux-wpan, kernel
On Wed, Aug 12, 2015 at 03:48:09PM +0200, Stefan Schmidt wrote:
> Hello.
>
> On 12/08/15 15:20, Alexander Aring wrote:
> >On Wed, Aug 12, 2015 at 02:51:10PM +0200, Stefan Schmidt wrote:
> >>Hello.
> >>
> >>typo in subject. s/evalualtion/evaluation/
> >>
> >ok.
> >
> >>On 03/08/15 08:23, Alexander Aring wrote:
> >>>This patch introduce some static inline function for checking the right
> >>>dispatch value. This also fixes an bug to detect the right fragmentation
> >>>dispatch value, we currently use "0xe0" as masking the fragmentation
> >>>dispatch. Correct is "0xf8" as mask.
> >>>
> >>>Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> >>>---
> >>> include/net/6lowpan.h | 18 +++++++++++++-----
> >>> net/ieee802154/6lowpan/6lowpan_i.h | 3 +++
> >>> net/ieee802154/6lowpan/rx.c | 30 +++++++++++++++++++++++++-----
> >>> 3 files changed, 41 insertions(+), 10 deletions(-)
> >>>
> >>>diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
> >>>index e16763f..073c791 100644
> >>>--- a/include/net/6lowpan.h
> >>>+++ b/include/net/6lowpan.h
> >>>@@ -126,11 +126,19 @@
> >>> (((a)[6]) == 0xFF) && \
> >>> (((a)[7]) == 0xFF))
> >>>-#define LOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
> >>>-#define LOWPAN_DISPATCH_HC1 0x42 /* 01000010 = 66 */
> >>>-#define LOWPAN_DISPATCH_IPHC 0x60 /* 011xxxxx = ... */
> >>>-#define LOWPAN_DISPATCH_FRAG1 0xc0 /* 11000xxx */
> >>>-#define LOWPAN_DISPATCH_FRAGN 0xe0 /* 11100xxx */
> >>>+#define LOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
> >>>+#define LOWPAN_DISPATCH_IPHC 0x60 /* 011xxxxx = ... */
> >>>+#define LOWPAN_DISPATCH_IPHC_MASK 0xe0
> >>>+
> >>>+static inline bool lowpan_is_ipv6(u8 dispatch)
> >>>+{
> >>>+ return dispatch == LOWPAN_DISPATCH_IPV6;
> >>>+}
> >>>+
> >>>+static inline bool lowpan_is_iphc(u8 dispatch)
> >>>+{
> >>>+ return (dispatch & LOWPAN_DISPATCH_IPHC_MASK) == LOWPAN_DISPATCH_IPHC;
> >>>+}
> >>> #define LOWPAN_DISPATCH_MASK 0xf8 /* 11111000 */
> >>>diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
> >>>index d62046e..e009a4a 100644
> >>>--- a/net/ieee802154/6lowpan/6lowpan_i.h
> >>>+++ b/net/ieee802154/6lowpan/6lowpan_i.h
> >>>@@ -7,6 +7,9 @@
> >>> #include <net/inet_frag.h>
> >>> #include <net/6lowpan.h>
> >>>+#define LOWPAN_DISPATCH_FRAG1 0xc0
> >>>+#define LOWPAN_DISPATCH_FRAGN 0xe0
> >>>+
> >>> struct lowpan_create_arg {
> >>> u16 tag;
> >>> u16 d_size;
> >>>diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> >>>index c7afd4a..b0066b7 100644
> >>>--- a/net/ieee802154/6lowpan/rx.c
> >>>+++ b/net/ieee802154/6lowpan/rx.c
> >>>@@ -21,6 +21,16 @@ typedef unsigned __bitwise__ lowpan_rx_result;
> >>> #define RX_DROP ((__force lowpan_rx_result) 2u)
> >>> #define RX_QUEUED ((__force lowpan_rx_result) 3u)
> >>>+#define LOWPAN_DISPATCH_FIRST 0xc0
> >>>+#define LOWPAN_DISPATCH_FRAG_MASK 0xf8
> >>>+#define LOWPAN_DISPATCH_IPHC_MASK 0xe0
> >>>+
> >>>+#define LOWPAN_DISPATCH_NALP 0x00
> >>>+#define LOWPAN_DISPATCH_HC1 0x42
> >>>+#define LOWPAN_DISPATCH_BC0 0x50
> >>>+#define LOWPAN_DISPATCH_ESC 0x7f
> >>>+#define LOWPAN_DISPATCH_MESH 0x80
> >>>+
> >>Any specific reason you moved the *_HC1 define here (same for the *_FRAG
> >>defines above)?
> >>
> >>I would think having them all in 6lowpan.h would make most sense. You might
> >>need them only in this file for now but later one maybe in another file. It
> >>could be personal taste but having them all in one place should be easier.
> >>imho.
> >There exists 6LoWPAN functionality which is shared between BTLE 6LoWPAN
> >and IEEE 802.15.4 6LoWPAN, these are:
> >
> > - IPHC
> > - IPV6
> >
> >they use both the same dispatch values.
> >
> >The file "include/net/6lowpan.h" is part of the generic 6LoWPAN branch,
> >so functionality which belongs to "IPHC" and "IPv6" (IPv6 dispatch is
> >the easiest dispatch, there is only maybe this one inline function).
> >
> >
> >The other dispatches are not defined for BTLE, e.g. fragmentation is
> >handled by MAC layer of BTLE so far I know. Also HC1 is not defined for
> >BTLE 6LoWPAN.
>
> Ah, now I understand why you keep them separate. Just keep it like you have
> in this case.
>
yes, I should be more clearly at the commit messages. Writing code is
for me easier than writing commit messages according to the patch.
I will add some notes about that in the commit message.
- Alex
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 11/16] ieee802154: 6lowpan: fix fragmentation dispatch mask
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (9 preceding siblings ...)
2015-08-03 6:23 ` [RFC 10/16] ieee802154: 6lowpan: add dispatch evalualtion helpers Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 12:51 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 12/16] ieee802154: 6lowpan: add generic lowpan header check Alexander Aring
` (5 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch fix the dispatch fragmentation masking. With "0xe" we also
get some reserved dispatch values.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index b0066b7..595830f 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -122,7 +122,8 @@ static lowpan_rx_result lowpan_rx_h_frag(struct sk_buff *skb)
lowpan_is_fragn(*skb_network_header(skb))))
return RX_CONTINUE;
- ret = lowpan_frag_rcv(skb, *skb_network_header(skb) & 0xe0);
+ ret = lowpan_frag_rcv(skb, *skb_network_header(skb) &
+ LOWPAN_DISPATCH_FRAG_MASK);
if (ret == 1)
return RX_CONTINUE;
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 11/16] ieee802154: 6lowpan: fix fragmentation dispatch mask
2015-08-03 6:23 ` [RFC 11/16] ieee802154: 6lowpan: fix fragmentation dispatch mask Alexander Aring
@ 2015-08-12 12:51 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 12:51 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This patch fix the dispatch fragmentation masking. With "0xe" we also
> get some reserved dispatch values.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index b0066b7..595830f 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -122,7 +122,8 @@ static lowpan_rx_result lowpan_rx_h_frag(struct sk_buff *skb)
> lowpan_is_fragn(*skb_network_header(skb))))
> return RX_CONTINUE;
>
> - ret = lowpan_frag_rcv(skb, *skb_network_header(skb) & 0xe0);
> + ret = lowpan_frag_rcv(skb, *skb_network_header(skb) &
> + LOWPAN_DISPATCH_FRAG_MASK);
> if (ret == 1)
> return RX_CONTINUE;
>
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 12/16] ieee802154: 6lowpan: add generic lowpan header check
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (10 preceding siblings ...)
2015-08-03 6:23 ` [RFC 11/16] ieee802154: 6lowpan: fix fragmentation dispatch mask Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 13:37 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 13/16] ieee802154: 6lowpan: add handler for all dispatch values Alexander Aring
` (4 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch introduce an earlier check if a 6LoWPAN can be valid. This
contains at first for checking if the header contains a dispatch byte
and isn't the nalp dispatch value, which means it isn't a 6LoWPAN
packet.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index 595830f..62d181a 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -172,11 +172,34 @@ rxh_next:
#undef CALL_RXH
}
+static inline bool lowpan_is_nalp(u8 dispatch)
+{
+ return (dispatch & LOWPAN_DISPATCH_FIRST) == LOWPAN_DISPATCH_NALP;
+}
+
+/* lowpan_rx_h_check checks on generic 6LoWPAN requirements
+ * in MAC and 6LoWPAN header.
+ *
+ * Don't manipulate the skb here, it could be shared buffer.
+ */
+static bool lowpan_rx_h_check(struct sk_buff *skb)
+{
+ /* check for if we can evaluate the dispatch */
+ if (unlikely(!skb->len))
+ return false;
+
+ if (lowpan_is_nalp(*skb_network_header(skb)))
+ return false;
+
+ return true;
+}
+
static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
struct packet_type *pt, struct net_device *orig_wdev)
{
if (skb->pkt_type == PACKET_OTHERHOST ||
- wdev->type != ARPHRD_IEEE802154)
+ wdev->type != ARPHRD_IEEE802154 ||
+ !lowpan_rx_h_check(skb))
return NET_RX_DROP;
skb = skb_share_check(skb, GFP_ATOMIC);
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 12/16] ieee802154: 6lowpan: add generic lowpan header check
2015-08-03 6:23 ` [RFC 12/16] ieee802154: 6lowpan: add generic lowpan header check Alexander Aring
@ 2015-08-12 13:37 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 13:37 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This patch introduce an earlier check if a 6LoWPAN can be valid. This
Missing the worde frame here? ...6LoWPAN frame can be valid...
> contains at first for checking if the header contains a dispatch byte
> and isn't the nalp dispatch value, which means it isn't a 6LoWPAN
> packet.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 25 ++++++++++++++++++++++++-
> 1 file changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 595830f..62d181a 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -172,11 +172,34 @@ rxh_next:
> #undef CALL_RXH
> }
>
> +static inline bool lowpan_is_nalp(u8 dispatch)
> +{
> + return (dispatch & LOWPAN_DISPATCH_FIRST) == LOWPAN_DISPATCH_NALP;
> +}
> +
> +/* lowpan_rx_h_check checks on generic 6LoWPAN requirements
> + * in MAC and 6LoWPAN header.
> + *
> + * Don't manipulate the skb here, it could be shared buffer.
> + */
> +static bool lowpan_rx_h_check(struct sk_buff *skb)
> +{
> + /* check for if we can evaluate the dispatch */
check if... no need for a for here.
> + if (unlikely(!skb->len))
> + return false;
> +
> + if (lowpan_is_nalp(*skb_network_header(skb)))
> + return false;
> +
> + return true;
> +}
> +
> static int lowpan_rcv(struct sk_buff *skb, struct net_device *wdev,
> struct packet_type *pt, struct net_device *orig_wdev)
> {
> if (skb->pkt_type == PACKET_OTHERHOST ||
> - wdev->type != ARPHRD_IEEE802154)
> + wdev->type != ARPHRD_IEEE802154 ||
> + !lowpan_rx_h_check(skb))
> return NET_RX_DROP;
>
> skb = skb_share_check(skb, GFP_ATOMIC);
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 13/16] ieee802154: 6lowpan: add handler for all dispatch values
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (11 preceding siblings ...)
2015-08-03 6:23 ` [RFC 12/16] ieee802154: 6lowpan: add generic lowpan header check Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 13:37 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 14/16] ieee802154: 6lowpan: add check for reserved dispatch Alexander Aring
` (3 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch adds dummy handlers for all known IEEE 802.15.4 dispatch
values which prints a warning that we don't support these dispatches
right now. Also we add a warning to the RX_CONTINUE case inside of
lowpan_rx_handlers_result which should now never happend.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 71 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index 62d181a..146aa14 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -37,6 +37,9 @@ lowpan_rx_handlers_result(struct sk_buff *skb, lowpan_rx_result res)
switch (res) {
/* nobody cared about this packet */
case RX_CONTINUE:
+ net_warn_ratelimited("%s: %s 0x%02x\n", skb->dev->name,
+ "received unknown dispatch",
+ *skb_network_header(skb));
case RX_DROP_UNUSABLE:
kfree_skb(skb);
case RX_DROP:
@@ -149,6 +152,70 @@ static lowpan_rx_result lowpan_rx_h_iphc(struct sk_buff *skb)
return lowpan_give_skb_to_device(skb);
}
+static inline bool lowpan_is_hc1(u8 dispatch)
+{
+ return dispatch == LOWPAN_DISPATCH_HC1;
+}
+
+static lowpan_rx_result lowpan_rx_h_hc1(struct sk_buff *skb)
+{
+ if (!lowpan_is_hc1(*skb_network_header(skb)))
+ return RX_CONTINUE;
+
+ net_warn_ratelimited("%s: %s\n", skb->dev->name,
+ "6LoWPAN HC1 not supported\n");
+
+ return RX_DROP_UNUSABLE;
+}
+
+static inline bool lowpan_is_bc0(u8 dispatch)
+{
+ return dispatch == LOWPAN_DISPATCH_BC0;
+}
+
+static lowpan_rx_result lowpan_rx_h_bc0(struct sk_buff *skb)
+{
+ if (!lowpan_is_bc0(*skb_network_header(skb)))
+ return RX_CONTINUE;
+
+ net_warn_ratelimited("%s: %s\n", skb->dev->name,
+ "6LoWPAN BC0 not supported\n");
+
+ return RX_DROP_UNUSABLE;
+}
+
+static inline bool lowpan_is_esc(u8 dispatch)
+{
+ return dispatch == LOWPAN_DISPATCH_ESC;
+}
+
+static lowpan_rx_result lowpan_rx_h_esc(struct sk_buff *skb)
+{
+ if (!lowpan_is_esc(*skb_network_header(skb)))
+ return RX_CONTINUE;
+
+ net_warn_ratelimited("%s: %s\n", skb->dev->name,
+ "6LoWPAN ESC not supported\n");
+
+ return RX_DROP_UNUSABLE;
+}
+
+static inline bool lowpan_is_mesh(u8 dispatch)
+{
+ return (dispatch & LOWPAN_DISPATCH_FIRST) == LOWPAN_DISPATCH_MESH;
+}
+
+static lowpan_rx_result lowpan_rx_h_mesh(struct sk_buff *skb)
+{
+ if (!lowpan_is_mesh(*skb_network_header(skb)))
+ return RX_CONTINUE;
+
+ net_warn_ratelimited("%s: %s\n", skb->dev->name,
+ "6LoWPAN MESH not supported\n");
+
+ return RX_DROP_UNUSABLE;
+}
+
int lowpan_invoke_rx_handlers(struct sk_buff *skb)
{
lowpan_rx_result res;
@@ -166,6 +233,10 @@ int lowpan_invoke_rx_handlers(struct sk_buff *skb)
/* likely at first */
CALL_RXH(lowpan_rx_h_iphc);
CALL_RXH(lowpan_rx_h_ipv6);
+ CALL_RXH(lowpan_rx_h_hc1);
+ CALL_RXH(lowpan_rx_h_bc0);
+ CALL_RXH(lowpan_rx_h_esc);
+ CALL_RXH(lowpan_rx_h_mesh);
rxh_next:
return lowpan_rx_handlers_result(skb, res);
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 13/16] ieee802154: 6lowpan: add handler for all dispatch values
2015-08-03 6:23 ` [RFC 13/16] ieee802154: 6lowpan: add handler for all dispatch values Alexander Aring
@ 2015-08-12 13:37 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 13:37 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This patch adds dummy handlers for all known IEEE 802.15.4 dispatch
> values which prints a warning that we don't support these dispatches
> right now. Also we add a warning to the RX_CONTINUE case inside of
> lowpan_rx_handlers_result which should now never happend.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 71 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 71 insertions(+)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 62d181a..146aa14 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -37,6 +37,9 @@ lowpan_rx_handlers_result(struct sk_buff *skb, lowpan_rx_result res)
> switch (res) {
> /* nobody cared about this packet */
> case RX_CONTINUE:
> + net_warn_ratelimited("%s: %s 0x%02x\n", skb->dev->name,
> + "received unknown dispatch",
> + *skb_network_header(skb));
> case RX_DROP_UNUSABLE:
> kfree_skb(skb);
> case RX_DROP:
> @@ -149,6 +152,70 @@ static lowpan_rx_result lowpan_rx_h_iphc(struct sk_buff *skb)
> return lowpan_give_skb_to_device(skb);
> }
>
> +static inline bool lowpan_is_hc1(u8 dispatch)
> +{
> + return dispatch == LOWPAN_DISPATCH_HC1;
> +}
> +
> +static lowpan_rx_result lowpan_rx_h_hc1(struct sk_buff *skb)
> +{
> + if (!lowpan_is_hc1(*skb_network_header(skb)))
> + return RX_CONTINUE;
> +
> + net_warn_ratelimited("%s: %s\n", skb->dev->name,
> + "6LoWPAN HC1 not supported\n");
> +
> + return RX_DROP_UNUSABLE;
> +}
> +
> +static inline bool lowpan_is_bc0(u8 dispatch)
> +{
> + return dispatch == LOWPAN_DISPATCH_BC0;
> +}
> +
> +static lowpan_rx_result lowpan_rx_h_bc0(struct sk_buff *skb)
> +{
> + if (!lowpan_is_bc0(*skb_network_header(skb)))
> + return RX_CONTINUE;
> +
> + net_warn_ratelimited("%s: %s\n", skb->dev->name,
> + "6LoWPAN BC0 not supported\n");
> +
> + return RX_DROP_UNUSABLE;
> +}
> +
> +static inline bool lowpan_is_esc(u8 dispatch)
> +{
> + return dispatch == LOWPAN_DISPATCH_ESC;
> +}
> +
> +static lowpan_rx_result lowpan_rx_h_esc(struct sk_buff *skb)
> +{
> + if (!lowpan_is_esc(*skb_network_header(skb)))
> + return RX_CONTINUE;
> +
> + net_warn_ratelimited("%s: %s\n", skb->dev->name,
> + "6LoWPAN ESC not supported\n");
> +
> + return RX_DROP_UNUSABLE;
> +}
> +
> +static inline bool lowpan_is_mesh(u8 dispatch)
> +{
> + return (dispatch & LOWPAN_DISPATCH_FIRST) == LOWPAN_DISPATCH_MESH;
> +}
> +
> +static lowpan_rx_result lowpan_rx_h_mesh(struct sk_buff *skb)
> +{
> + if (!lowpan_is_mesh(*skb_network_header(skb)))
> + return RX_CONTINUE;
> +
> + net_warn_ratelimited("%s: %s\n", skb->dev->name,
> + "6LoWPAN MESH not supported\n");
> +
> + return RX_DROP_UNUSABLE;
> +}
> +
> int lowpan_invoke_rx_handlers(struct sk_buff *skb)
> {
> lowpan_rx_result res;
> @@ -166,6 +233,10 @@ int lowpan_invoke_rx_handlers(struct sk_buff *skb)
> /* likely at first */
> CALL_RXH(lowpan_rx_h_iphc);
> CALL_RXH(lowpan_rx_h_ipv6);
> + CALL_RXH(lowpan_rx_h_hc1);
> + CALL_RXH(lowpan_rx_h_bc0);
> + CALL_RXH(lowpan_rx_h_esc);
> + CALL_RXH(lowpan_rx_h_mesh);
>
> rxh_next:
> return lowpan_rx_handlers_result(skb, res);
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 14/16] ieee802154: 6lowpan: add check for reserved dispatch
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (12 preceding siblings ...)
2015-08-03 6:23 ` [RFC 13/16] ieee802154: 6lowpan: add handler for all dispatch values Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 13:37 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 15/16] ieee802154: 6lowpan: check on valid 802.15.4 frame Alexander Aring
` (2 subsequent siblings)
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch adds checks for reserved dispatch value by check on all known
dispatch values.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index 146aa14..48869ac 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -248,6 +248,15 @@ static inline bool lowpan_is_nalp(u8 dispatch)
return (dispatch & LOWPAN_DISPATCH_FIRST) == LOWPAN_DISPATCH_NALP;
}
+static inline bool lowpan_is_reserved(u8 dispatch)
+{
+ return !(lowpan_is_nalp(dispatch) || lowpan_is_iphc(dispatch) ||
+ lowpan_is_ipv6(dispatch) || lowpan_is_hc1(dispatch) ||
+ lowpan_is_bc0(dispatch) || lowpan_is_mesh(dispatch) ||
+ lowpan_is_esc(dispatch) || lowpan_is_frag1(dispatch) ||
+ lowpan_is_fragn(dispatch));
+}
+
/* lowpan_rx_h_check checks on generic 6LoWPAN requirements
* in MAC and 6LoWPAN header.
*
@@ -259,7 +268,8 @@ static bool lowpan_rx_h_check(struct sk_buff *skb)
if (unlikely(!skb->len))
return false;
- if (lowpan_is_nalp(*skb_network_header(skb)))
+ if (lowpan_is_nalp(*skb_network_header(skb)) ||
+ lowpan_is_reserved(*skb_network_header(skb)))
return false;
return true;
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 14/16] ieee802154: 6lowpan: add check for reserved dispatch
2015-08-03 6:23 ` [RFC 14/16] ieee802154: 6lowpan: add check for reserved dispatch Alexander Aring
@ 2015-08-12 13:37 ` Stefan Schmidt
2015-08-13 20:17 ` Alexander Aring
0 siblings, 1 reply; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 13:37 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This patch adds checks for reserved dispatch value by check on all known
> dispatch values.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 146aa14..48869ac 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -248,6 +248,15 @@ static inline bool lowpan_is_nalp(u8 dispatch)
> return (dispatch & LOWPAN_DISPATCH_FIRST) == LOWPAN_DISPATCH_NALP;
> }
>
> +static inline bool lowpan_is_reserved(u8 dispatch)
> +{
> + return !(lowpan_is_nalp(dispatch) || lowpan_is_iphc(dispatch) ||
OK, this is fishy. First of all you check lowpan_is_nalp here and negate
it, but below you are checking without negation.
One must be wrong. :)
> + lowpan_is_ipv6(dispatch) || lowpan_is_hc1(dispatch) ||
> + lowpan_is_bc0(dispatch) || lowpan_is_mesh(dispatch) ||
> + lowpan_is_esc(dispatch) || lowpan_is_frag1(dispatch) ||
> + lowpan_is_fragn(dispatch));
> +}
> +
> /* lowpan_rx_h_check checks on generic 6LoWPAN requirements
> * in MAC and 6LoWPAN header.
> *
> @@ -259,7 +268,8 @@ static bool lowpan_rx_h_check(struct sk_buff *skb)
> if (unlikely(!skb->len))
> return false;
>
> - if (lowpan_is_nalp(*skb_network_header(skb)))
> + if (lowpan_is_nalp(*skb_network_header(skb)) ||
Here are you checking it as well. but without negating it.
> + lowpan_is_reserved(*skb_network_header(skb)))
> return false;
>
> return true;
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread* Re: [RFC 14/16] ieee802154: 6lowpan: add check for reserved dispatch
2015-08-12 13:37 ` Stefan Schmidt
@ 2015-08-13 20:17 ` Alexander Aring
0 siblings, 0 replies; 44+ messages in thread
From: Alexander Aring @ 2015-08-13 20:17 UTC (permalink / raw)
To: Stefan Schmidt; +Cc: linux-wpan, kernel
On Wed, Aug 12, 2015 at 03:37:33PM +0200, Stefan Schmidt wrote:
> Hello.
>
> On 03/08/15 08:23, Alexander Aring wrote:
> >This patch adds checks for reserved dispatch value by check on all known
> >dispatch values.
> >
> >Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> >---
> > net/ieee802154/6lowpan/rx.c | 12 +++++++++++-
> > 1 file changed, 11 insertions(+), 1 deletion(-)
> >
> >diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> >index 146aa14..48869ac 100644
> >--- a/net/ieee802154/6lowpan/rx.c
> >+++ b/net/ieee802154/6lowpan/rx.c
> >@@ -248,6 +248,15 @@ static inline bool lowpan_is_nalp(u8 dispatch)
> > return (dispatch & LOWPAN_DISPATCH_FIRST) == LOWPAN_DISPATCH_NALP;
> > }
> >+static inline bool lowpan_is_reserved(u8 dispatch)
> >+{
> >+ return !(lowpan_is_nalp(dispatch) || lowpan_is_iphc(dispatch) ||
>
> OK, this is fishy. First of all you check lowpan_is_nalp here and negate it,
> but below you are checking without negation.
> One must be wrong. :)
>
>
> >+ lowpan_is_ipv6(dispatch) || lowpan_is_hc1(dispatch) ||
> >+ lowpan_is_bc0(dispatch) || lowpan_is_mesh(dispatch) ||
> >+ lowpan_is_esc(dispatch) || lowpan_is_frag1(dispatch) ||
> >+ lowpan_is_fragn(dispatch));
> >+}
> >+
> > /* lowpan_rx_h_check checks on generic 6LoWPAN requirements
> > * in MAC and 6LoWPAN header.
> > *
> >@@ -259,7 +268,8 @@ static bool lowpan_rx_h_check(struct sk_buff *skb)
> > if (unlikely(!skb->len))
> > return false;
> >- if (lowpan_is_nalp(*skb_network_header(skb)))
> >+ if (lowpan_is_nalp(*skb_network_header(skb)) ||
>
> Here are you checking it as well. but without negating it.
>
yes, I think we should work here with ranges. Not checking all known
values. (Maybe we can also do some bit magic there then).
Also I should lookup more iana registrations for dispatches. I forget
LOWPAN_DFF
See [0]. But then somebody else should send a patch to introduce some
"netdev warning message".
btw: we should add some of these warning messages for lowpan_nhc as well.
[1]. I am fine for introduce just a name and known nhc id for printing
some warning that we don't support $NAME right now, instead of
"unknown".
(Also wondering why "11111111 - Unassigned, reserved for extensions" -
does this mean now that when we have "11111111" an additional nhc id
byte is there? I don't see anything in rfc6282 which mention that. For
this reason I had implement the such complicated rbtree lookup mechanism
because I was not sure about this -> "When we know an additional nhc id
byte is there". Anyway it's some variable length bitstring and rbtree
structure should be fit there (I hope).
- Alex
[0] https://www.iana.org/assignments/_6lowpan-parameters/_6lowpan-parameters.xhtml#_6lowpan-parameters-1
[1] https://www.iana.org/assignments/_6lowpan-parameters/_6lowpan-parameters.xhtml#lowpan_nhc
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 15/16] ieee802154: 6lowpan: check on valid 802.15.4 frame
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (13 preceding siblings ...)
2015-08-03 6:23 ` [RFC 14/16] ieee802154: 6lowpan: add check for reserved dispatch Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 13:37 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 16/16] ieee802154: 6lowpan: remove packet type to host Alexander Aring
2015-08-12 8:15 ` [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Stefan Schmidt
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch adds frame control checks to check if the received frame is
something which could contain a 6LoWPAN packet.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
include/linux/ieee802154.h | 48 ++++++++++++++++++++++++++++++++++++++++++++-
net/ieee802154/6lowpan/rx.c | 9 +++++++++
2 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index 4f26c01..5a64fc0 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -208,7 +208,24 @@ enum {
};
/* frame control handling */
-#define IEEE802154_FCTL_ACKREQ 0x0020
+#define IEEE802154_FCTL_FTYPE 0x0003
+#define IEEE802154_FTYPE_DATA 0x0001
+#define IEEE802154_FCTL_ACKREQ 0x0020
+#define IEEE802154_FCTL_INTRA_PAN 0x0040
+#define IEEE802154_FCTL_DADDR 0x0c00
+#define IEEE802154_FCTL_DADDR_NONE 0x0000
+#define IEEE802154_FCTL_SADDR 0xc000
+#define IEEE802154_FCTL_SADDR_NONE 0x0000
+
+/*
+ * ieee802154_is_data - check if type is IEEE802154_FTYPE_DATA
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline int ieee802154_is_data(__le16 fc)
+{
+ return (fc & cpu_to_le16(IEEE802154_FCTL_FTYPE)) ==
+ cpu_to_le16(IEEE802154_FTYPE_DATA);
+}
/**
* ieee802154_is_ackreq - check if acknowledgment request bit is set
@@ -220,6 +237,35 @@ static inline bool ieee802154_is_ackreq(__le16 fc)
}
/**
+ * ieee802154_is_intra_pan - check if intra pan id communication
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee802154_is_intra_pan(__le16 fc)
+{
+ return fc & cpu_to_le16(IEEE802154_FCTL_INTRA_PAN);
+}
+
+/**
+ * ieee802154_is_daddr_none - check if daddr mode is none
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee802154_is_daddr_none(__le16 fc)
+{
+ return (fc & cpu_to_le16(IEEE802154_FCTL_DADDR)) ==
+ cpu_to_le16(IEEE802154_FCTL_DADDR_NONE);
+}
+
+/**
+ * ieee802154_is_saddr_none - check if saddr mode is none
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee802154_is_saddr_none(__le16 fc)
+{
+ return (fc & cpu_to_le16(IEEE802154_FCTL_SADDR)) ==
+ cpu_to_le16(IEEE802154_FCTL_SADDR_NONE);
+}
+
+/**
* ieee802154_get_fc_from_skb - get the frame control field from an skb
* @skb: skb where the frame control field will be get from
*/
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index 48869ac..b1a9d14 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -264,6 +264,15 @@ static inline bool lowpan_is_reserved(u8 dispatch)
*/
static bool lowpan_rx_h_check(struct sk_buff *skb)
{
+ __le16 fc = ieee802154_get_fc_from_skb(skb);
+
+ /* check on ieee802154 conform 6LoWPAN header */
+ if (!ieee802154_is_data(fc) ||
+ ieee802154_is_daddr_none(fc) ||
+ ieee802154_is_saddr_none(fc) ||
+ !ieee802154_is_intra_pan(fc))
+ return false;
+
/* check for if we can evaluate the dispatch */
if (unlikely(!skb->len))
return false;
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 15/16] ieee802154: 6lowpan: check on valid 802.15.4 frame
2015-08-03 6:23 ` [RFC 15/16] ieee802154: 6lowpan: check on valid 802.15.4 frame Alexander Aring
@ 2015-08-12 13:37 ` Stefan Schmidt
2015-08-12 13:54 ` Alexander Aring
0 siblings, 1 reply; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 13:37 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This patch adds frame control checks to check if the received frame is
> something which could contain a 6LoWPAN packet.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> include/linux/ieee802154.h | 48 ++++++++++++++++++++++++++++++++++++++++++++-
> net/ieee802154/6lowpan/rx.c | 9 +++++++++
> 2 files changed, 56 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
> index 4f26c01..5a64fc0 100644
> --- a/include/linux/ieee802154.h
> +++ b/include/linux/ieee802154.h
> @@ -208,7 +208,24 @@ enum {
> };
>
> /* frame control handling */
> -#define IEEE802154_FCTL_ACKREQ 0x0020
> +#define IEEE802154_FCTL_FTYPE 0x0003
> +#define IEEE802154_FTYPE_DATA 0x0001
> +#define IEEE802154_FCTL_ACKREQ 0x0020
> +#define IEEE802154_FCTL_INTRA_PAN 0x0040
> +#define IEEE802154_FCTL_DADDR 0x0c00
> +#define IEEE802154_FCTL_DADDR_NONE 0x0000
> +#define IEEE802154_FCTL_SADDR 0xc000
> +#define IEEE802154_FCTL_SADDR_NONE 0x0000
> +
> +/*
> + * ieee802154_is_data - check if type is IEEE802154_FTYPE_DATA
> + * @fc: frame control bytes in little-endian byteorder
> + */
> +static inline int ieee802154_is_data(__le16 fc)
> +{
> + return (fc & cpu_to_le16(IEEE802154_FCTL_FTYPE)) ==
> + cpu_to_le16(IEEE802154_FTYPE_DATA);
> +}
>
> /**
> * ieee802154_is_ackreq - check if acknowledgment request bit is set
> @@ -220,6 +237,35 @@ static inline bool ieee802154_is_ackreq(__le16 fc)
> }
>
> /**
> + * ieee802154_is_intra_pan - check if intra pan id communication
> + * @fc: frame control bytes in little-endian byteorder
> + */
> +static inline bool ieee802154_is_intra_pan(__le16 fc)
> +{
> + return fc & cpu_to_le16(IEEE802154_FCTL_INTRA_PAN);
> +}
> +
> +/**
> + * ieee802154_is_daddr_none - check if daddr mode is none
> + * @fc: frame control bytes in little-endian byteorder
> + */
> +static inline bool ieee802154_is_daddr_none(__le16 fc)
> +{
> + return (fc & cpu_to_le16(IEEE802154_FCTL_DADDR)) ==
> + cpu_to_le16(IEEE802154_FCTL_DADDR_NONE);
> +}
> +
> +/**
> + * ieee802154_is_saddr_none - check if saddr mode is none
> + * @fc: frame control bytes in little-endian byteorder
> + */
> +static inline bool ieee802154_is_saddr_none(__le16 fc)
> +{
> + return (fc & cpu_to_le16(IEEE802154_FCTL_SADDR)) ==
> + cpu_to_le16(IEEE802154_FCTL_SADDR_NONE);
> +}
> +
> +/**
> * ieee802154_get_fc_from_skb - get the frame control field from an skb
> * @skb: skb where the frame control field will be get from
> */
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 48869ac..b1a9d14 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -264,6 +264,15 @@ static inline bool lowpan_is_reserved(u8 dispatch)
> */
> static bool lowpan_rx_h_check(struct sk_buff *skb)
> {
> + __le16 fc = ieee802154_get_fc_from_skb(skb);
> +
> + /* check on ieee802154 conform 6LoWPAN header */
> + if (!ieee802154_is_data(fc) ||
> + ieee802154_is_daddr_none(fc) ||
> + ieee802154_is_saddr_none(fc) ||
> + !ieee802154_is_intra_pan(fc))
Interesting, 6LoWPAN frames always have to have the intra PAN flag set?
Did not know this until now.
> + return false;
> +
> /* check for if we can evaluate the dispatch */
> if (unlikely(!skb->len))
> return false;
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread* Re: [RFC 15/16] ieee802154: 6lowpan: check on valid 802.15.4 frame
2015-08-12 13:37 ` Stefan Schmidt
@ 2015-08-12 13:54 ` Alexander Aring
0 siblings, 0 replies; 44+ messages in thread
From: Alexander Aring @ 2015-08-12 13:54 UTC (permalink / raw)
To: Stefan Schmidt; +Cc: linux-wpan, kernel
On Wed, Aug 12, 2015 at 03:37:40PM +0200, Stefan Schmidt wrote:
> Hello.
>
> On 03/08/15 08:23, Alexander Aring wrote:
> >This patch adds frame control checks to check if the received frame is
> >something which could contain a 6LoWPAN packet.
> >
> >Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> >---
> > include/linux/ieee802154.h | 48 ++++++++++++++++++++++++++++++++++++++++++++-
> > net/ieee802154/6lowpan/rx.c | 9 +++++++++
> > 2 files changed, 56 insertions(+), 1 deletion(-)
> >
> >diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
> >index 4f26c01..5a64fc0 100644
> >--- a/include/linux/ieee802154.h
> >+++ b/include/linux/ieee802154.h
> >@@ -208,7 +208,24 @@ enum {
> > };
> > /* frame control handling */
> >-#define IEEE802154_FCTL_ACKREQ 0x0020
> >+#define IEEE802154_FCTL_FTYPE 0x0003
> >+#define IEEE802154_FTYPE_DATA 0x0001
> >+#define IEEE802154_FCTL_ACKREQ 0x0020
> >+#define IEEE802154_FCTL_INTRA_PAN 0x0040
> >+#define IEEE802154_FCTL_DADDR 0x0c00
> >+#define IEEE802154_FCTL_DADDR_NONE 0x0000
> >+#define IEEE802154_FCTL_SADDR 0xc000
> >+#define IEEE802154_FCTL_SADDR_NONE 0x0000
> >+
> >+/*
> >+ * ieee802154_is_data - check if type is IEEE802154_FTYPE_DATA
> >+ * @fc: frame control bytes in little-endian byteorder
> >+ */
> >+static inline int ieee802154_is_data(__le16 fc)
> >+{
> >+ return (fc & cpu_to_le16(IEEE802154_FCTL_FTYPE)) ==
> >+ cpu_to_le16(IEEE802154_FTYPE_DATA);
> >+}
> > /**
> > * ieee802154_is_ackreq - check if acknowledgment request bit is set
> >@@ -220,6 +237,35 @@ static inline bool ieee802154_is_ackreq(__le16 fc)
> > }
> > /**
> >+ * ieee802154_is_intra_pan - check if intra pan id communication
> >+ * @fc: frame control bytes in little-endian byteorder
> >+ */
> >+static inline bool ieee802154_is_intra_pan(__le16 fc)
> >+{
> >+ return fc & cpu_to_le16(IEEE802154_FCTL_INTRA_PAN);
> >+}
> >+
> >+/**
> >+ * ieee802154_is_daddr_none - check if daddr mode is none
> >+ * @fc: frame control bytes in little-endian byteorder
> >+ */
> >+static inline bool ieee802154_is_daddr_none(__le16 fc)
> >+{
> >+ return (fc & cpu_to_le16(IEEE802154_FCTL_DADDR)) ==
> >+ cpu_to_le16(IEEE802154_FCTL_DADDR_NONE);
> >+}
> >+
> >+/**
> >+ * ieee802154_is_saddr_none - check if saddr mode is none
> >+ * @fc: frame control bytes in little-endian byteorder
> >+ */
> >+static inline bool ieee802154_is_saddr_none(__le16 fc)
> >+{
> >+ return (fc & cpu_to_le16(IEEE802154_FCTL_SADDR)) ==
> >+ cpu_to_le16(IEEE802154_FCTL_SADDR_NONE);
> >+}
> >+
> >+/**
> > * ieee802154_get_fc_from_skb - get the frame control field from an skb
> > * @skb: skb where the frame control field will be get from
> > */
> >diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> >index 48869ac..b1a9d14 100644
> >--- a/net/ieee802154/6lowpan/rx.c
> >+++ b/net/ieee802154/6lowpan/rx.c
> >@@ -264,6 +264,15 @@ static inline bool lowpan_is_reserved(u8 dispatch)
> > */
> > static bool lowpan_rx_h_check(struct sk_buff *skb)
> > {
> >+ __le16 fc = ieee802154_get_fc_from_skb(skb);
> >+
> >+ /* check on ieee802154 conform 6LoWPAN header */
> >+ if (!ieee802154_is_data(fc) ||
> >+ ieee802154_is_daddr_none(fc) ||
> >+ ieee802154_is_saddr_none(fc) ||
> >+ !ieee802154_is_intra_pan(fc))
>
> Interesting, 6LoWPAN frames always have to have the intra PAN flag set? Did
> not know this until now.
I think intra-pan communication makes only sense, also I talked with
Phoebe about ~ 1 year ago where I asked myself how 802.15.4 6LoWPAN
handles non intra pan connection and I need to lookup again this in some
RFC. I think it was at [0].
"A destination PAN identifier is included in the frame, and it
MUST match the PAN ID of the link in question."
which means "the destination pan id" must be the same of the current "link".
The "link" means -> what we currently set to the 802.15.4 MIB.
I think this answers the question "802.15.4 6LoWPAN is intra-pan only".
Another question is:
How to deal with 802.15.4 which have the same destination and source
PANID. The 802.15.4 says here it should set the intra panid bit.
NOW we could parse "source" and "destination" panid is the same and
intra panid is NOT set. But for me it's an invalid 802.15.4 frame and we
should drop it.
We currently don't drop this frames but we should do it in the lower
layer parsing which I will think about it how to deal frame parsing when
we have crypto working. :-/
Anyway I think everbody is welcome to send patches for this, but I maybe
want to change it later in some complete different parsing mechanism.
- Alex
[0] https://tools.ietf.org/html/rfc4944#section-3
^ permalink raw reply [flat|nested] 44+ messages in thread
* [RFC 16/16] ieee802154: 6lowpan: remove packet type to host
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (14 preceding siblings ...)
2015-08-03 6:23 ` [RFC 15/16] ieee802154: 6lowpan: check on valid 802.15.4 frame Alexander Aring
@ 2015-08-03 6:23 ` Alexander Aring
2015-08-12 13:37 ` Stefan Schmidt
2015-08-12 8:15 ` [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Stefan Schmidt
16 siblings, 1 reply; 44+ messages in thread
From: Alexander Aring @ 2015-08-03 6:23 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch remove the packet_type to host and leave the mac pkt_type.
By running 'grep -r "pkt_type" net/ipv6', the IPv6 stack will evaluate
this value for PACKET_BROADCAST. Instead of overwriting this value we
will leave the mac value there which is broadcasts if the mac frame was
a broadcast frame.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/rx.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index b1a9d14..1d9866a 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -56,7 +56,6 @@ static int lowpan_give_skb_to_device(struct sk_buff *skb)
int ret;
skb->protocol = htons(ETH_P_IPV6);
- skb->pkt_type = PACKET_HOST;
ret = netif_rx(skb);
/* kfree_skb handled by netif_rx, so RX_DROP on failure */
--
2.5.0
^ permalink raw reply related [flat|nested] 44+ messages in thread* Re: [RFC 16/16] ieee802154: 6lowpan: remove packet type to host
2015-08-03 6:23 ` [RFC 16/16] ieee802154: 6lowpan: remove packet type to host Alexander Aring
@ 2015-08-12 13:37 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 13:37 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This patch remove the packet_type to host and leave the mac pkt_type.
> By running 'grep -r "pkt_type" net/ipv6', the IPv6 stack will evaluate
> this value for PACKET_BROADCAST. Instead of overwriting this value we
> will leave the mac value there which is broadcasts if the mac frame was
> a broadcast frame.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/rx.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index b1a9d14..1d9866a 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -56,7 +56,6 @@ static int lowpan_give_skb_to_device(struct sk_buff *skb)
> int ret;
>
> skb->protocol = htons(ETH_P_IPV6);
> - skb->pkt_type = PACKET_HOST;
>
> ret = netif_rx(skb);
> /* kfree_skb handled by netif_rx, so RX_DROP on failure */
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
` (15 preceding siblings ...)
2015-08-03 6:23 ` [RFC 16/16] ieee802154: 6lowpan: remove packet type to host Alexander Aring
@ 2015-08-12 8:15 ` Stefan Schmidt
2015-08-13 9:10 ` Stefan Schmidt
16 siblings, 1 reply; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-12 8:15 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> Hi,
>
> this patch series contains a rework of 802.15.4 6LoWPAN receive handling.
> We need to check on some things before which never checked before, like
> is 802.15.4 dataframe, if we can access skb->data[0] (could be that skb->len
> is 0 then), etc.
>
> Also various bug fixes like the masking for fragmentation dispatch value which
> is currently wrong. Also we should again check the dispatch value after successful
> reassembly a fragment, we currently assume always a iphc header there. This is wrong
> it could also be a non-compressed header. This can occur if the compressed header is
> larger than lower interface MTU size, we doesn't react on this while transmit which
> is another issue. Nevertheless we also don't reach this case at worst-case compression
> currently.
>
> I introduced a complete new handling for the dispatch values based on mac80211
> datatype receive handling mechanism.
I'm going to review this set over the next days. Just as a heads up.
> This patch series based on bluetooth-next with various pending patches, I uploaded
> the branch at:
>
> https://github.com/linux-wpan/linux-wpan-next/commits/802154_6lowpan_cleanup2
>
> so everybody can test it.
I tried to apply the patches directly on bluetooth-next but they did not
apply. Guess you want to rebase them when sending out a new round. For
now I will review the patches here and use the branch you uploaded for
testing. Will report back later.
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread* Re: [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation
2015-08-12 8:15 ` [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Stefan Schmidt
@ 2015-08-13 9:10 ` Stefan Schmidt
0 siblings, 0 replies; 44+ messages in thread
From: Stefan Schmidt @ 2015-08-13 9:10 UTC (permalink / raw)
To: Alexander Aring, linux-wpan; +Cc: kernel
Hello.
On 12/08/15 10:15, Stefan Schmidt wrote:
> Hello.
>
> On 03/08/15 08:23, Alexander Aring wrote:
>> Hi,
>>
>> this patch series contains a rework of 802.15.4 6LoWPAN receive
>> handling.
>> We need to check on some things before which never checked before, like
>> is 802.15.4 dataframe, if we can access skb->data[0] (could be that
>> skb->len
>> is 0 then), etc.
>>
>> Also various bug fixes like the masking for fragmentation dispatch
>> value which
>> is currently wrong. Also we should again check the dispatch value
>> after successful
>> reassembly a fragment, we currently assume always a iphc header
>> there. This is wrong
>> it could also be a non-compressed header. This can occur if the
>> compressed header is
>> larger than lower interface MTU size, we doesn't react on this while
>> transmit which
>> is another issue. Nevertheless we also don't reach this case at
>> worst-case compression
>> currently.
>>
>> I introduced a complete new handling for the dispatch values based on
>> mac80211
>> datatype receive handling mechanism.
>
> I'm going to review this set over the next days. Just as a heads up.
>
>> This patch series based on bluetooth-next with various pending
>> patches, I uploaded
>> the branch at:
>>
>> https://github.com/linux-wpan/linux-wpan-next/commits/802154_6lowpan_cleanup2
>>
>>
>> so everybody can test it.
>
> I tried to apply the patches directly on bluetooth-next but they did
> not apply. Guess you want to rebase them when sending out a new round.
> For now I will review the patches here and use the branch you uploaded
> for testing. Will report back later.
My testing showed no problems with this. You can add a
Tested-by: Stefan Schmidt <stefan@osg.samsung.com>
to the whole series.
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 44+ messages in thread