ieee802154: 6lowpan: fixes for multiple interfaces
Subsystems (2)
Alexander Aring
maintainercover ieee802154: 6lowpan: fixes for multiple interfaces
Hi,
while working on "ieee802154: 6lowpan: cleanup and rework dispatch evaluation", I detected issues which was introduced by removal the multiple interfaces feature _per_ wpan interface. These are:
- multiple registration for the packet handler -> fixed by open_count
- check on if the wpan interface has a lowpan interface.
I also detect the missing dev_put while lowpan netdev_registation and take some patches like moving the ARPHRD check earlier, we need to check on this before evaluating the ieee802154_ptr.
- Alex
Alexander Aring (2):
ieee802154: 6lowpan: fix packet layer registration
ieee802154: 6lowpan: fix non-lowpan wpan interfaces
net/ieee802154/6lowpan/core.c | 22 +++++++++++++++++----- net/ieee802154/6lowpan/rx.c | 7 ++++--- 2 files changed, 21 insertions(+), 8 deletions(-)
Signature · 1 line
2.5.0
Alexander Aring
maintainerPATCH 1/2 ieee802154: 6lowpan: fix packet layer registration
This patch fixes 802.15.4 packet layer registration when mutliple lowpan interfaces will be added. We need to register the packet layer at the first lowpan interface and deregister it at the last interface. This done by open_count variable which is protected by rtnl.
Additional do a quiet fix by adding dev_put(real_dev) when netdev registration fails, which fix the refcount for the wpan dev.
--- net/ieee802154/6lowpan/core.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
net/ieee802154/6lowpan/core.c +17 -5
@@ -52,6 +52,8 @@#include "6lowpan_i.h" +static int open_count; +static struct header_ops lowpan_header_ops = { .create = lowpan_header_create, };
@@ -141,12 +143,18 @@ static int lowpan_newlink(struct net *src_net, struct net_device *dev,lowpan_netdev_setup (dev,LOWPAN_LLTYPE_IEEE802154 ); ret =register_netdevice (dev); -if (ret >=0 ) { - real_dev->ieee802154_ptr->lowpan_dev = dev; -lowpan_rx_init (); +if (ret <0 ) { +dev_put (real_dev); +return ret; } -return ret; + real_dev->ieee802154_ptr->lowpan_dev = dev; +if (!open_count) +lowpan_rx_init (); + + open_count++; + +return 0 ; }static void lowpan_dellink (struct net_device *dev,struct list_head *head)
@@ -156,7 +164,11 @@ static void lowpan_dellink(struct net_device *dev, struct list_head *head)ASSERT_RTNL (); -lowpan_rx_exit (); + open_count--; + +if (!open_count) +lowpan_rx_exit (); + real_dev->ieee802154_ptr->lowpan_dev =NULL ;unregister_netdevice (dev);dev_put (real_dev);
Signature · 1 line
2.5.0
Alexander Aring
maintainerPATCH 2/2 ieee802154: 6lowpan: fix non-lowpan wpan interfaces
In reply to Alexander AringWe receive all 802.15.4 frames on the packet handler "lowpan_rcv" this patch checks if the wpan device belongs to a lowpan interface.
--- net/ieee802154/6lowpan/rx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/ieee802154/6lowpan/rx.c +4 -3
@@ -67,6 +67,10 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,struct ieee802154_hdr hdr;int ret; +if (dev->type !=ARPHRD_IEEE802154 || + !dev->ieee802154_ptr->lowpan_dev) + goto drop; + skb =skb_share_check (skb,GFP_ATOMIC );if (!skb) goto drop;
@@ -77,9 +81,6 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,if (skb->pkt_type ==PACKET_OTHERHOST ) goto drop_skb; -if (dev->type !=ARPHRD_IEEE802154 ) - goto drop_skb; -if (ieee802154_hdr_peek_addrs (skb, &hdr) <0 ) goto drop_skb;
Signature · 1 line
2.5.0
Hi Alex,
Quoted 13 lines
while working on "ieee802154: 6lowpan: cleanup and rework dispatch evaluation", I detected issues which was introduced by removal the multiple interfaces feature _per_ wpan interface. These are:
- multiple registration for the packet handler -> fixed by
open_count
- check on if the wpan interface has a lowpan interface.I also detect the missing
dev_putwhile lowpannetdev_registationand take some patches like moving the ARPHRD check earlier, we need to check on this before evaluating theieee802154_ptr.- Alex
Quoted 7 lines
Alexander Aring (2):
ieee802154: 6lowpan: fix packet layer registration
ieee802154: 6lowpan: fix non-lowpan wpan interfaces
net/ieee802154/6lowpan/core.c| 22 +++++++++++++++++-----net/ieee802154/6lowpan/rx.c| 7 ++++---2 files changed, 21 insertions(+), 8 deletions(-)
both patches have been applied to bluetooth-next tree.
Regards
Marcel