All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5][6lowpan] several fixes for 6lowpan
@ 2012-04-24 10:51 Alexander Smirnov
  2012-04-24 10:51 ` [PATCH 1/5] 6lowpan: fix segmentation fault caused by mlme request Alexander Smirnov
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Alexander Smirnov @ 2012-04-24 10:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-zigbee-devel


Dear David,

the following patch-set contains several fixes/improvements for 6lowpan:
1. fix: segmentation fault caused by mlme request
2. impr: move frame allocation code to a separate function
3. fix: clean up fragments list if module unloaded
4. impr: duplicate definition of IEEE802154_ALEN
5. fix: add missing spin_lock_init()

Could you please review them?

With best regards,
Alex

8<--

The following changes since commit ac807fa8e625aff58060876d70298c93a59c4252:

  tcp: Fix build warning after tcp_{v4,v6}_init_sock consolidation. (2012-04-23 03:21:58 -0400)

are available in the git repository at:
  git://local ..BRANCH.NOT.VERIFIED..

Alexander Smirnov (5):
      6lowpan: fix segmentation fault caused by mlme request
      6lowpan: move frame allocation code to a separate function
      6lowpan: clean up fragments list if module unloaded
      6lowpan: duplicate definition of IEEE802154_ALEN
      6lowpan: add missing spin_lock_init()

 net/ieee802154/6lowpan.c |  125 ++++++++++++++++++++++++++++++++--------------
 net/ieee802154/6lowpan.h |    3 -
 2 files changed, 88 insertions(+), 40 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] 6lowpan: fix segmentation fault caused by mlme request
  2012-04-24 10:51 [PATCH 0/5][6lowpan] several fixes for 6lowpan Alexander Smirnov
@ 2012-04-24 10:51 ` Alexander Smirnov
       [not found] ` <1335264671-27127-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Alexander Smirnov @ 2012-04-24 10:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-zigbee-devel, Alexander Smirnov

Add nescesary mlme callbacks to satisfy "iz list" request from user space.
Due to 6lowpan device doesn't have its own phy, mlme implemented as a pipe
to real phy to which 6lowpan is attached.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 net/ieee802154/6lowpan.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 58c8895..7ce508f 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1044,6 +1044,24 @@ static void lowpan_dev_free(struct net_device *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;
+	return ieee802154_mlme_ops(real_dev)->get_phy(real_dev);
+}
+
+static u16 lowpan_get_pan_id(const struct net_device *dev)
+{
+	struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
+	return ieee802154_mlme_ops(real_dev)->get_pan_id(real_dev);
+}
+
+static u16 lowpan_get_short_addr(const struct net_device *dev)
+{
+	struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
+	return ieee802154_mlme_ops(real_dev)->get_short_addr(real_dev);
+}
+
 static struct header_ops lowpan_header_ops = {
 	.create	= lowpan_header_create,
 };
@@ -1053,6 +1071,12 @@ static const struct net_device_ops lowpan_netdev_ops = {
 	.ndo_set_mac_address	= eth_mac_addr,
 };
 
+static struct ieee802154_mlme_ops lowpan_mlme = {
+	.get_pan_id = lowpan_get_pan_id,
+	.get_phy = lowpan_get_phy,
+	.get_short_addr = lowpan_get_short_addr,
+};
+
 static void lowpan_setup(struct net_device *dev)
 {
 	pr_debug("(%s)\n", __func__);
@@ -1070,6 +1094,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;
 }
 
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] 6lowpan: move frame allocation code to a separate function
       [not found] ` <1335264671-27127-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-04-24 10:51   ` Alexander Smirnov
  2012-04-24 10:51   ` [PATCH 3/5] 6lowpan: clean up fragments list if module unloaded Alexander Smirnov
  1 sibling, 0 replies; 7+ messages in thread
From: Alexander Smirnov @ 2012-04-24 10:51 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Separate frame allocation routine from data processing function.
This makes code more human readable and easier to understand.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 net/ieee802154/6lowpan.c |   81 +++++++++++++++++++++++++++-------------------
 1 files changed, 48 insertions(+), 33 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 7ce508f..d440233 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -650,6 +650,53 @@ static void lowpan_fragment_timer_expired(unsigned long entry_addr)
 	kfree(entry);
 }
 
+static struct lowpan_fragment *
+lowpan_alloc_new_frame(struct sk_buff *skb, u8 iphc0, u8 len, u8 tag)
+{
+	struct lowpan_fragment *frame;
+
+	frame = kzalloc(sizeof(struct lowpan_fragment),
+			GFP_ATOMIC);
+	if (!frame)
+		goto frame_err;
+
+	INIT_LIST_HEAD(&frame->list);
+
+	frame->length = (iphc0 & 7) | (len << 3);
+	frame->tag = tag;
+
+	/* allocate buffer for frame assembling */
+	frame->skb = alloc_skb(frame->length +
+			       sizeof(struct ipv6hdr), GFP_ATOMIC);
+
+	if (!frame->skb)
+		goto skb_err;
+
+	frame->skb->priority = skb->priority;
+	frame->skb->dev = skb->dev;
+
+	/* reserve headroom for uncompressed ipv6 header */
+	skb_reserve(frame->skb, sizeof(struct ipv6hdr));
+	skb_put(frame->skb, frame->length);
+
+	init_timer(&frame->timer);
+	/* time out is the same as for ipv6 - 60 sec */
+	frame->timer.expires = jiffies + LOWPAN_FRAG_TIMEOUT;
+	frame->timer.data = (unsigned long)frame;
+	frame->timer.function = lowpan_fragment_timer_expired;
+
+	add_timer(&frame->timer);
+
+	list_add_tail(&frame->list, &lowpan_fragments);
+
+	return frame;
+
+skb_err:
+	kfree(frame);
+frame_err:
+	return NULL;
+}
+
 static int
 lowpan_process_data(struct sk_buff *skb)
 {
@@ -692,41 +739,9 @@ lowpan_process_data(struct sk_buff *skb)
 
 		/* alloc new frame structure */
 		if (!found) {
-			frame = kzalloc(sizeof(struct lowpan_fragment),
-								GFP_ATOMIC);
+			frame = lowpan_alloc_new_frame(skb, iphc0, len, tag);
 			if (!frame)
 				goto unlock_and_drop;
-
-			INIT_LIST_HEAD(&frame->list);
-
-			frame->length = (iphc0 & 7) | (len << 3);
-			frame->tag = tag;
-
-			/* allocate buffer for frame assembling */
-			frame->skb = alloc_skb(frame->length +
-					sizeof(struct ipv6hdr), GFP_ATOMIC);
-
-			if (!frame->skb) {
-				kfree(frame);
-				goto unlock_and_drop;
-			}
-
-			frame->skb->priority = skb->priority;
-			frame->skb->dev = skb->dev;
-
-			/* reserve headroom for uncompressed ipv6 header */
-			skb_reserve(frame->skb, sizeof(struct ipv6hdr));
-			skb_put(frame->skb, frame->length);
-
-			init_timer(&frame->timer);
-			/* time out is the same as for ipv6 - 60 sec */
-			frame->timer.expires = jiffies + LOWPAN_FRAG_TIMEOUT;
-			frame->timer.data = (unsigned long)frame;
-			frame->timer.function = lowpan_fragment_timer_expired;
-
-			add_timer(&frame->timer);
-
-			list_add_tail(&frame->list, &lowpan_fragments);
 		}
 
 		if ((iphc0 & LOWPAN_DISPATCH_MASK) == LOWPAN_DISPATCH_FRAG1)
-- 
1.7.2.3


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] 6lowpan: clean up fragments list if module unloaded
       [not found] ` <1335264671-27127-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2012-04-24 10:51   ` [PATCH 2/5] 6lowpan: move frame allocation code to a separate function Alexander Smirnov
@ 2012-04-24 10:51   ` Alexander Smirnov
  1 sibling, 0 replies; 7+ messages in thread
From: Alexander Smirnov @ 2012-04-24 10:51 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Clean all the pending fragments and timers if 6lowpan link
is going to be deleted.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 net/ieee802154/6lowpan.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index d440233..a57174e 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1192,11 +1192,20 @@ static void lowpan_dellink(struct net_device *dev, struct list_head *head)
 {
 	struct lowpan_dev_info *lowpan_dev = lowpan_dev_info(dev);
 	struct net_device *real_dev = lowpan_dev->real_dev;
-	struct lowpan_dev_record *entry;
-	struct lowpan_dev_record *tmp;
+	struct lowpan_dev_record *entry, *tmp;
+	struct lowpan_fragment *frame, *tframe;
 
 	ASSERT_RTNL();
 
+	spin_lock(&flist_lock);
+	list_for_each_entry_safe(frame, tframe, &lowpan_fragments, list) {
+		del_timer(&frame->timer);
+		list_del(&frame->list);
+		dev_kfree_skb(frame->skb);
+		kfree(frame);
+	}
+	spin_unlock(&flist_lock);
+
 	mutex_lock(&lowpan_dev_info(dev)->dev_list_mtx);
 	list_for_each_entry_safe(entry, tmp, &lowpan_devices, list) {
 		if (entry->ldev == dev) {
-- 
1.7.2.3


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] 6lowpan: duplicate definition of IEEE802154_ALEN
  2012-04-24 10:51 [PATCH 0/5][6lowpan] several fixes for 6lowpan Alexander Smirnov
  2012-04-24 10:51 ` [PATCH 1/5] 6lowpan: fix segmentation fault caused by mlme request Alexander Smirnov
       [not found] ` <1335264671-27127-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-04-24 10:51 ` Alexander Smirnov
  2012-04-24 10:51 ` [PATCH 5/5] 6lowpan: add missing spin_lock_init() Alexander Smirnov
  2012-04-26  0:35 ` [PATCH 0/5][6lowpan] several fixes for 6lowpan David Miller
  4 siblings, 0 replies; 7+ messages in thread
From: Alexander Smirnov @ 2012-04-24 10:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-zigbee-devel, Alexander Smirnov

The same macros is defined in 'include/net/af_ieee802154.h' and is called
IEEE802154_ADDR_LEN. No need another one, so remove it.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 net/ieee802154/6lowpan.c |    4 ++--
 net/ieee802154/6lowpan.h |    3 ---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index a57174e..8c1d212 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -196,7 +196,7 @@ lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift, const struct in6_addr *ipaddr,
 static void
 lowpan_uip_ds6_set_addr_iid(struct in6_addr *ipaddr, unsigned char *lladdr)
 {
-	memcpy(&ipaddr->s6_addr[8], lladdr, IEEE802154_ALEN);
+	memcpy(&ipaddr->s6_addr[8], lladdr, IEEE802154_ADDR_LEN);
 	/* second bit-flip (Universe/Local) is done according RFC2464 */
 	ipaddr->s6_addr[8] ^= 0x02;
 }
@@ -221,7 +221,7 @@ lowpan_uncompress_addr(struct sk_buff *skb, struct in6_addr *ipaddr,
 
 	if (lladdr)
 		lowpan_raw_dump_inline(__func__, "linklocal address",
-						lladdr,	IEEE802154_ALEN);
+						lladdr,	IEEE802154_ADDR_LEN);
 	if (prefcount > 0)
 		memcpy(ipaddr, prefix, prefcount);
 
diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h
index aeff3f3..8c2251f 100644
--- a/net/ieee802154/6lowpan.h
+++ b/net/ieee802154/6lowpan.h
@@ -53,9 +53,6 @@
 #ifndef __6LOWPAN_H__
 #define __6LOWPAN_H__
 
-/* need to know address length to manipulate with it */
-#define IEEE802154_ALEN		8
-
 #define UIP_802154_SHORTADDR_LEN	2  /* compressed ipv6 address length */
 #define UIP_IPH_LEN			40 /* ipv6 fixed header size */
 #define UIP_PROTO_UDP			17 /* ipv6 next header value for UDP */
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] 6lowpan: add missing spin_lock_init()
  2012-04-24 10:51 [PATCH 0/5][6lowpan] several fixes for 6lowpan Alexander Smirnov
                   ` (2 preceding siblings ...)
  2012-04-24 10:51 ` [PATCH 4/5] 6lowpan: duplicate definition of IEEE802154_ALEN Alexander Smirnov
@ 2012-04-24 10:51 ` Alexander Smirnov
  2012-04-26  0:35 ` [PATCH 0/5][6lowpan] several fixes for 6lowpan David Miller
  4 siblings, 0 replies; 7+ messages in thread
From: Alexander Smirnov @ 2012-04-24 10:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-zigbee-devel, Alexander Smirnov

Add missing spin_lock_init() for frames list lock.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 net/ieee802154/6lowpan.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 8c1d212..32eb417 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1183,6 +1183,8 @@ static int lowpan_newlink(struct net *src_net, struct net_device *dev,
 	list_add_tail(&entry->list, &lowpan_devices);
 	mutex_unlock(&lowpan_dev_info(dev)->dev_list_mtx);
 
+	spin_lock_init(&flist_lock);
+
 	register_netdevice(dev);
 
 	return 0;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5][6lowpan] several fixes for 6lowpan
  2012-04-24 10:51 [PATCH 0/5][6lowpan] several fixes for 6lowpan Alexander Smirnov
                   ` (3 preceding siblings ...)
  2012-04-24 10:51 ` [PATCH 5/5] 6lowpan: add missing spin_lock_init() Alexander Smirnov
@ 2012-04-26  0:35 ` David Miller
  4 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2012-04-26  0:35 UTC (permalink / raw)
  To: alex.bluesman.smirnov; +Cc: netdev, linux-zigbee-devel

From: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
Date: Tue, 24 Apr 2012 14:51:06 +0400

> the following patch-set contains several fixes/improvements for 6lowpan:
> 1. fix: segmentation fault caused by mlme request
> 2. impr: move frame allocation code to a separate function
> 3. fix: clean up fragments list if module unloaded
> 4. impr: duplicate definition of IEEE802154_ALEN
> 5. fix: add missing spin_lock_init()
> 
> Could you please review them?

You need to not mix bug fixe patches with one which perform
cleanups and code refactoring.

Submit the pure bug fixes as one set, against the 'net' tree.

Then submit the rest as another set, against the 'net-next' tree.

Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-04-26  0:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-24 10:51 [PATCH 0/5][6lowpan] several fixes for 6lowpan Alexander Smirnov
2012-04-24 10:51 ` [PATCH 1/5] 6lowpan: fix segmentation fault caused by mlme request Alexander Smirnov
     [not found] ` <1335264671-27127-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-04-24 10:51   ` [PATCH 2/5] 6lowpan: move frame allocation code to a separate function Alexander Smirnov
2012-04-24 10:51   ` [PATCH 3/5] 6lowpan: clean up fragments list if module unloaded Alexander Smirnov
2012-04-24 10:51 ` [PATCH 4/5] 6lowpan: duplicate definition of IEEE802154_ALEN Alexander Smirnov
2012-04-24 10:51 ` [PATCH 5/5] 6lowpan: add missing spin_lock_init() Alexander Smirnov
2012-04-26  0:35 ` [PATCH 0/5][6lowpan] several fixes for 6lowpan David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.