From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: kernel@pengutronix.de, Alexander Aring <alex.aring@gmail.com>
Subject: [PATCH bluetooth-next 1/2] ieee802154: 6lowpan: fix packet layer registration
Date: Sat, 15 Aug 2015 11:00:32 +0200 [thread overview]
Message-ID: <1439629233-4328-2-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1439629233-4328-1-git-send-email-alex.aring@gmail.com>
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.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan/core.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
index 180e9f5..27c25ad 100644
--- a/net/ieee802154/6lowpan/core.c
+++ b/net/ieee802154/6lowpan/core.c
@@ -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);
--
2.5.0
next prev parent reply other threads:[~2015-08-15 9:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-15 9:00 [PATCH bluetooth-next 0/2] ieee802154: 6lowpan: fixes for multiple interfaces Alexander Aring
2015-08-15 9:00 ` Alexander Aring [this message]
2015-08-15 9:00 ` [PATCH bluetooth-next 2/2] ieee802154: 6lowpan: fix non-lowpan wpan interfaces Alexander Aring
2015-08-15 21:29 ` [PATCH bluetooth-next 0/2] ieee802154: 6lowpan: fixes for multiple interfaces Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439629233-4328-2-git-send-email-alex.aring@gmail.com \
--to=alex.aring@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-wpan@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox