* [PATCH v2 0/2] 6lowpan fixes
@ 2012-08-30 2:38 Alan Ott
2012-08-30 2:39 ` [PATCH v2 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan Alan Ott
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Alan Ott @ 2012-08-30 2:38 UTC (permalink / raw)
To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller,
Tony Cheneau
Cc: linux-zigbee-devel, netdev, linux-kernel, Alan Ott
Fixes for 6lowpan.
I'm sorry about the other two emails that just went out with the same
subject. One day I'm going to start getting these right on the first try.
Alan Ott (2):
6lowpan: Make a copy of skb's delivered to 6lowpan
6lowpan: handle NETDEV_UNREGISTER event
net/ieee802154/6lowpan.c | 53 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 45 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan
2012-08-30 2:38 [PATCH v2 0/2] 6lowpan fixes Alan Ott
@ 2012-08-30 2:39 ` Alan Ott
2012-08-31 7:01 ` Eric Dumazet
2012-08-30 2:39 ` [PATCH v2 2/2] 6lowpan: handle NETDEV_UNREGISTER event Alan Ott
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Alan Ott @ 2012-08-30 2:39 UTC (permalink / raw)
To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller,
Tony Cheneau
Cc: linux-zigbee-devel, netdev, linux-kernel, Alan Ott
Since lowpan_process_data() modifies the skb (by calling skb_pull()), we
need our own copy so that it doesn't affect the data received by other
protcols (in this case, af_ieee802154).
Signed-off-by: Alan Ott <alan@signal11.us>
---
net/ieee802154/6lowpan.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 6a09522..ce33b02 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1133,6 +1133,8 @@ static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
+ struct sk_buff *local_skb;
+
if (!netif_running(dev))
goto drop;
@@ -1144,7 +1146,12 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */
case LOWPAN_DISPATCH_FRAG1: /* first fragment header */
case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */
- lowpan_process_data(skb);
+ local_skb = skb_copy(skb, GFP_ATOMIC);
+ if (!local_skb)
+ goto drop;
+ lowpan_process_data(local_skb);
+
+ kfree_skb(skb);
break;
default:
break;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] 6lowpan: handle NETDEV_UNREGISTER event
2012-08-30 2:38 [PATCH v2 0/2] 6lowpan fixes Alan Ott
2012-08-30 2:39 ` [PATCH v2 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan Alan Ott
@ 2012-08-30 2:39 ` Alan Ott
2012-09-01 15:57 ` [PATCH v3 0/2] 6lowpan fixes Alan Ott
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Alan Ott @ 2012-08-30 2:39 UTC (permalink / raw)
To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller,
Tony Cheneau
Cc: linux-zigbee-devel, netdev, linux-kernel, Alan Ott
Before, it was impossible to remove a wpan device which had lowpan
attached to it.
Signed-off-by: Alan Ott <alan@signal11.us>
---
net/ieee802154/6lowpan.c | 44 +++++++++++++++++++++++++++++++++++++-------
1 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index ce33b02..fb41e08 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1063,12 +1063,6 @@ out:
return (err < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK);
}
-static void lowpan_dev_free(struct net_device *dev)
-{
- dev_put(lowpan_dev_info(dev)->real_dev);
- free_netdev(dev);
-}
-
static struct wpan_phy *lowpan_get_phy(const struct net_device *dev)
{
struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
@@ -1118,7 +1112,7 @@ static void lowpan_setup(struct net_device *dev)
dev->netdev_ops = &lowpan_netdev_ops;
dev->header_ops = &lowpan_header_ops;
dev->ml_priv = &lowpan_mlme;
- dev->destructor = lowpan_dev_free;
+ dev->destructor = free_netdev;
}
static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -1244,6 +1238,34 @@ static inline void __init lowpan_netlink_fini(void)
rtnl_link_unregister(&lowpan_link_ops);
}
+static int lowpan_device_event(struct notifier_block *unused,
+ unsigned long event,
+ void *ptr)
+{
+ struct net_device *dev = ptr;
+ LIST_HEAD(del_list);
+ struct lowpan_dev_record *entry, *tmp;
+
+ if (dev->type != ARPHRD_IEEE802154)
+ goto out;
+
+ if (event == NETDEV_UNREGISTER) {
+ list_for_each_entry_safe(entry, tmp, &lowpan_devices, list) {
+ if (lowpan_dev_info(entry->ldev)->real_dev == dev)
+ lowpan_dellink(entry->ldev, &del_list);
+ }
+
+ unregister_netdevice_many(&del_list);
+ };
+
+out:
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block lowpan_dev_notifier = {
+ .notifier_call = lowpan_device_event,
+};
+
static struct packet_type lowpan_packet_type = {
.type = __constant_htons(ETH_P_IEEE802154),
.func = lowpan_rcv,
@@ -1258,6 +1280,12 @@ static int __init lowpan_init_module(void)
goto out;
dev_add_pack(&lowpan_packet_type);
+
+ err = register_netdevice_notifier(&lowpan_dev_notifier);
+ if (err < 0) {
+ dev_remove_pack(&lowpan_packet_type);
+ lowpan_netlink_fini();
+ }
out:
return err;
}
@@ -1270,6 +1298,8 @@ static void __exit lowpan_cleanup_module(void)
dev_remove_pack(&lowpan_packet_type);
+ unregister_netdevice_notifier(&lowpan_dev_notifier);
+
/* Now 6lowpan packet_type is removed, so no new fragments are
* expected on RX, therefore that's the time to clean incomplete
* fragments.
--
1.7.0.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan
2012-08-30 2:39 ` [PATCH v2 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan Alan Ott
@ 2012-08-31 7:01 ` Eric Dumazet
2012-08-31 13:56 ` Alan Ott
0 siblings, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2012-08-31 7:01 UTC (permalink / raw)
To: Alan Ott
Cc: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller,
Tony Cheneau, linux-zigbee-devel, netdev, linux-kernel
On Wed, 2012-08-29 at 22:39 -0400, Alan Ott wrote:
> Since lowpan_process_data() modifies the skb (by calling skb_pull()), we
> need our own copy so that it doesn't affect the data received by other
> protcols (in this case, af_ieee802154).
>
> Signed-off-by: Alan Ott <alan@signal11.us>
> ---
> net/ieee802154/6lowpan.c | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
> index 6a09522..ce33b02 100644
> --- a/net/ieee802154/6lowpan.c
> +++ b/net/ieee802154/6lowpan.c
> @@ -1133,6 +1133,8 @@ static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
> static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
> struct packet_type *pt, struct net_device *orig_dev)
> {
> + struct sk_buff *local_skb;
> +
> if (!netif_running(dev))
> goto drop;
>
> @@ -1144,7 +1146,12 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
> case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */
> case LOWPAN_DISPATCH_FRAG1: /* first fragment header */
> case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */
> - lowpan_process_data(skb);
> + local_skb = skb_copy(skb, GFP_ATOMIC);
> + if (!local_skb)
> + goto drop;
> + lowpan_process_data(local_skb);
> +
> + kfree_skb(skb);
> break;
> default:
> break;
Its not clear to me why skb_copy() is needed here.
>From patch description, I would say skb_clone() would be enough (and
faster) ?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan
2012-08-31 7:01 ` Eric Dumazet
@ 2012-08-31 13:56 ` Alan Ott
0 siblings, 0 replies; 9+ messages in thread
From: Alan Ott @ 2012-08-31 13:56 UTC (permalink / raw)
To: Eric Dumazet
Cc: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller,
Tony Cheneau, linux-zigbee-devel, netdev, linux-kernel
On 08/31/2012 03:01 AM, Eric Dumazet wrote:
> On Wed, 2012-08-29 at 22:39 -0400, Alan Ott wrote:
>> Since lowpan_process_data() modifies the skb (by calling skb_pull()), we
>> need our own copy so that it doesn't affect the data received by other
>> protcols (in this case, af_ieee802154).
>>
>> Signed-off-by: Alan Ott <alan@signal11.us>
>> ---
>> net/ieee802154/6lowpan.c | 9 ++++++++-
>> 1 files changed, 8 insertions(+), 1 deletions(-)
>>
>> diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
>> index 6a09522..ce33b02 100644
>> --- a/net/ieee802154/6lowpan.c
>> +++ b/net/ieee802154/6lowpan.c
>> @@ -1133,6 +1133,8 @@ static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
>> static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
>> struct packet_type *pt, struct net_device *orig_dev)
>> {
>> + struct sk_buff *local_skb;
>> +
>> if (!netif_running(dev))
>> goto drop;
>>
>> @@ -1144,7 +1146,12 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
>> case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */
>> case LOWPAN_DISPATCH_FRAG1: /* first fragment header */
>> case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */
>> - lowpan_process_data(skb);
>> + local_skb = skb_copy(skb, GFP_ATOMIC);
>> + if (!local_skb)
>> + goto drop;
>> + lowpan_process_data(local_skb);
>> +
>> + kfree_skb(skb);
>> break;
>> default:
>> break;
> Its not clear to me why skb_copy() is needed here.
>
> >From patch description, I would say skb_clone() would be enough (and
> faster) ?
You're probably right. I'll check it out. Thanks.
Alan.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 0/2] 6lowpan fixes
2012-08-30 2:38 [PATCH v2 0/2] 6lowpan fixes Alan Ott
2012-08-30 2:39 ` [PATCH v2 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan Alan Ott
2012-08-30 2:39 ` [PATCH v2 2/2] 6lowpan: handle NETDEV_UNREGISTER event Alan Ott
@ 2012-09-01 15:57 ` Alan Ott
2012-09-02 2:48 ` David Miller
2012-09-01 15:57 ` [PATCH v3 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan Alan Ott
2012-09-01 15:57 ` [PATCH v3 2/2] 6lowpan: handle NETDEV_UNREGISTER event Alan Ott
4 siblings, 1 reply; 9+ messages in thread
From: Alan Ott @ 2012-09-01 15:57 UTC (permalink / raw)
To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller,
Tony Cheneau
Cc: linux-zigbee-devel, netdev, linux-kernel, Alan Ott
v3 of this patch changes skb_copy() to skb_clone() in patch #1 at the
recommendation of Eric Dumazet
Alan Ott (2):
6lowpan: Make a copy of skb's delivered to 6lowpan
6lowpan: handle NETDEV_UNREGISTER event
net/ieee802154/6lowpan.c | 53 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 45 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan
2012-08-30 2:38 [PATCH v2 0/2] 6lowpan fixes Alan Ott
` (2 preceding siblings ...)
2012-09-01 15:57 ` [PATCH v3 0/2] 6lowpan fixes Alan Ott
@ 2012-09-01 15:57 ` Alan Ott
2012-09-01 15:57 ` [PATCH v3 2/2] 6lowpan: handle NETDEV_UNREGISTER event Alan Ott
4 siblings, 0 replies; 9+ messages in thread
From: Alan Ott @ 2012-09-01 15:57 UTC (permalink / raw)
To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller,
Tony Cheneau
Cc: linux-zigbee-devel, netdev, linux-kernel, Alan Ott
Since lowpan_process_data() modifies the skb (by calling skb_pull()), we
need our own copy so that it doesn't affect the data received by other
protcols (in this case, af_ieee802154).
Signed-off-by: Alan Ott <alan@signal11.us>
---
net/ieee802154/6lowpan.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 6a09522..b28ec79 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1133,6 +1133,8 @@ static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
+ struct sk_buff *local_skb;
+
if (!netif_running(dev))
goto drop;
@@ -1144,7 +1146,12 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */
case LOWPAN_DISPATCH_FRAG1: /* first fragment header */
case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */
- lowpan_process_data(skb);
+ local_skb = skb_clone(skb, GFP_ATOMIC);
+ if (!local_skb)
+ goto drop;
+ lowpan_process_data(local_skb);
+
+ kfree_skb(skb);
break;
default:
break;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 2/2] 6lowpan: handle NETDEV_UNREGISTER event
2012-08-30 2:38 [PATCH v2 0/2] 6lowpan fixes Alan Ott
` (3 preceding siblings ...)
2012-09-01 15:57 ` [PATCH v3 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan Alan Ott
@ 2012-09-01 15:57 ` Alan Ott
4 siblings, 0 replies; 9+ messages in thread
From: Alan Ott @ 2012-09-01 15:57 UTC (permalink / raw)
To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller,
Tony Cheneau
Cc: linux-zigbee-devel, netdev, linux-kernel, Alan Ott
Before, it was impossible to remove a wpan device which had lowpan
attached to it.
Signed-off-by: Alan Ott <alan@signal11.us>
---
net/ieee802154/6lowpan.c | 44 +++++++++++++++++++++++++++++++++++++-------
1 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index b28ec79..d529111 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1063,12 +1063,6 @@ out:
return (err < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK);
}
-static void lowpan_dev_free(struct net_device *dev)
-{
- dev_put(lowpan_dev_info(dev)->real_dev);
- free_netdev(dev);
-}
-
static struct wpan_phy *lowpan_get_phy(const struct net_device *dev)
{
struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
@@ -1118,7 +1112,7 @@ static void lowpan_setup(struct net_device *dev)
dev->netdev_ops = &lowpan_netdev_ops;
dev->header_ops = &lowpan_header_ops;
dev->ml_priv = &lowpan_mlme;
- dev->destructor = lowpan_dev_free;
+ dev->destructor = free_netdev;
}
static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -1244,6 +1238,34 @@ static inline void __init lowpan_netlink_fini(void)
rtnl_link_unregister(&lowpan_link_ops);
}
+static int lowpan_device_event(struct notifier_block *unused,
+ unsigned long event,
+ void *ptr)
+{
+ struct net_device *dev = ptr;
+ LIST_HEAD(del_list);
+ struct lowpan_dev_record *entry, *tmp;
+
+ if (dev->type != ARPHRD_IEEE802154)
+ goto out;
+
+ if (event == NETDEV_UNREGISTER) {
+ list_for_each_entry_safe(entry, tmp, &lowpan_devices, list) {
+ if (lowpan_dev_info(entry->ldev)->real_dev == dev)
+ lowpan_dellink(entry->ldev, &del_list);
+ }
+
+ unregister_netdevice_many(&del_list);
+ };
+
+out:
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block lowpan_dev_notifier = {
+ .notifier_call = lowpan_device_event,
+};
+
static struct packet_type lowpan_packet_type = {
.type = __constant_htons(ETH_P_IEEE802154),
.func = lowpan_rcv,
@@ -1258,6 +1280,12 @@ static int __init lowpan_init_module(void)
goto out;
dev_add_pack(&lowpan_packet_type);
+
+ err = register_netdevice_notifier(&lowpan_dev_notifier);
+ if (err < 0) {
+ dev_remove_pack(&lowpan_packet_type);
+ lowpan_netlink_fini();
+ }
out:
return err;
}
@@ -1270,6 +1298,8 @@ static void __exit lowpan_cleanup_module(void)
dev_remove_pack(&lowpan_packet_type);
+ unregister_netdevice_notifier(&lowpan_dev_notifier);
+
/* Now 6lowpan packet_type is removed, so no new fragments are
* expected on RX, therefore that's the time to clean incomplete
* fragments.
--
1.7.0.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 0/2] 6lowpan fixes
2012-09-01 15:57 ` [PATCH v3 0/2] 6lowpan fixes Alan Ott
@ 2012-09-02 2:48 ` David Miller
0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2012-09-02 2:48 UTC (permalink / raw)
To: alan
Cc: alex.bluesman.smirnov, dbaryshkov, tony.cheneau,
linux-zigbee-devel, netdev, linux-kernel
From: Alan Ott <alan@signal11.us>
Date: Sat, 1 Sep 2012 11:57:05 -0400
> v3 of this patch changes skb_copy() to skb_clone() in patch #1 at the
> recommendation of Eric Dumazet
>
> Alan Ott (2):
> 6lowpan: Make a copy of skb's delivered to 6lowpan
> 6lowpan: handle NETDEV_UNREGISTER event
All applied to net-next, thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-09-02 2:49 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-30 2:38 [PATCH v2 0/2] 6lowpan fixes Alan Ott
2012-08-30 2:39 ` [PATCH v2 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan Alan Ott
2012-08-31 7:01 ` Eric Dumazet
2012-08-31 13:56 ` Alan Ott
2012-08-30 2:39 ` [PATCH v2 2/2] 6lowpan: handle NETDEV_UNREGISTER event Alan Ott
2012-09-01 15:57 ` [PATCH v3 0/2] 6lowpan fixes Alan Ott
2012-09-02 2:48 ` David Miller
2012-09-01 15:57 ` [PATCH v3 1/2] 6lowpan: Make a copy of skb's delivered to 6lowpan Alan Ott
2012-09-01 15:57 ` [PATCH v3 2/2] 6lowpan: handle NETDEV_UNREGISTER event Alan Ott
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).