summaryrefslogtreecommitdiffstats
path: root/net/ieee802154/nl802154.c
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-11-17 08:20:53 +0100
committerMarcel Holtmann <marcel@holtmann.org>2014-11-17 09:49:17 +0100
commitb821ecd4c8a0b3b1fc1bdd191bb7d555d818cafe (patch)
treec8f3ac6ef58c923437e200b7d96b6c7987576dd7 /net/ieee802154/nl802154.c
parent0e57547eb7f0aa99aba32b50c49dbd722a80d6fb (diff)
downloadlinux-b821ecd4c8a0b3b1fc1bdd191bb7d555d818cafe.tar.gz
linux-b821ecd4c8a0b3b1fc1bdd191bb7d555d818cafe.tar.bz2
linux-b821ecd4c8a0b3b1fc1bdd191bb7d555d818cafe.zip
ieee802154: add del interface command
This patch adds support for deleting a wpan interface via nl802154. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/ieee802154/nl802154.c')
-rw-r--r--net/ieee802154/nl802154.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 49c4d8a5004a..6b9bc93944a6 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -583,6 +583,26 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info)
type, extended_addr);
}
+static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info)
+{
+ struct cfg802154_registered_device *rdev = info->user_ptr[0];
+ struct wpan_dev *wpan_dev = info->user_ptr[1];
+
+ if (!rdev->ops->del_virtual_intf)
+ return -EOPNOTSUPP;
+
+ /* If we remove a wpan device without a netdev then clear
+ * user_ptr[1] so that nl802154_post_doit won't dereference it
+ * to check if it needs to do dev_put(). Otherwise it crashes
+ * since the wpan_dev has been freed, unlike with a netdev where
+ * we need the dev_put() for the netdev to really be freed.
+ */
+ if (!wpan_dev->netdev)
+ info->user_ptr[1] = NULL;
+
+ return rdev_del_virtual_intf(rdev, wpan_dev);
+}
+
static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info)
{
struct cfg802154_registered_device *rdev = info->user_ptr[0];
@@ -859,6 +879,14 @@ static const struct genl_ops nl802154_ops[] = {
NL802154_FLAG_NEED_RTNL,
},
{
+ .cmd = NL802154_CMD_DEL_INTERFACE,
+ .doit = nl802154_del_interface,
+ .policy = nl802154_policy,
+ .flags = GENL_ADMIN_PERM,
+ .internal_flags = NL802154_FLAG_NEED_WPAN_DEV |
+ NL802154_FLAG_NEED_RTNL,
+ },
+ {
.cmd = NL802154_CMD_SET_CHANNEL,
.doit = nl802154_set_channel,
.policy = nl802154_policy,