diff options
| author | Alexander Aring <alex.aring@gmail.com> | 2014-11-17 02:20:53 -0500 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2014-11-17 03:49:17 -0500 |
| commit | b821ecd4c8a0b3b1fc1bdd191bb7d555d818cafe (patch) | |
| tree | c8f3ac6ef58c923437e200b7d96b6c7987576dd7 | |
| parent | 0e57547eb7f0aa99aba32b50c49dbd722a80d6fb (diff) | |
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>
| -rw-r--r-- | include/net/cfg802154.h | 2 | ||||
| -rw-r--r-- | net/ieee802154/nl802154.c | 28 | ||||
| -rw-r--r-- | net/ieee802154/rdev-ops.h | 7 | ||||
| -rw-r--r-- | net/mac802154/cfg.c | 9 | ||||
| -rw-r--r-- | net/mac802154/ieee802154_i.h | 6 |
5 files changed, 52 insertions, 0 deletions
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h index 4a9bb0e3db2b..507ac9d3d38a 100644 --- a/include/net/cfg802154.h +++ b/include/net/cfg802154.h | |||
| @@ -43,6 +43,8 @@ struct cfg802154_ops { | |||
| 43 | const char *name, | 43 | const char *name, |
| 44 | enum nl802154_iftype type, | 44 | enum nl802154_iftype type, |
| 45 | __le64 extended_addr); | 45 | __le64 extended_addr); |
| 46 | int (*del_virtual_intf)(struct wpan_phy *wpan_phy, | ||
| 47 | struct wpan_dev *wpan_dev); | ||
| 46 | int (*set_channel)(struct wpan_phy *wpan_phy, u8 page, u8 channel); | 48 | int (*set_channel)(struct wpan_phy *wpan_phy, u8 page, u8 channel); |
| 47 | int (*set_pan_id)(struct wpan_phy *wpan_phy, | 49 | int (*set_pan_id)(struct wpan_phy *wpan_phy, |
| 48 | struct wpan_dev *wpan_dev, u16 pan_id); | 50 | struct wpan_dev *wpan_dev, u16 pan_id); |
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) | |||
| 583 | type, extended_addr); | 583 | type, extended_addr); |
| 584 | } | 584 | } |
| 585 | 585 | ||
| 586 | static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info) | ||
| 587 | { | ||
| 588 | struct cfg802154_registered_device *rdev = info->user_ptr[0]; | ||
| 589 | struct wpan_dev *wpan_dev = info->user_ptr[1]; | ||
| 590 | |||
| 591 | if (!rdev->ops->del_virtual_intf) | ||
| 592 | return -EOPNOTSUPP; | ||
| 593 | |||
| 594 | /* If we remove a wpan device without a netdev then clear | ||
| 595 | * user_ptr[1] so that nl802154_post_doit won't dereference it | ||
| 596 | * to check if it needs to do dev_put(). Otherwise it crashes | ||
| 597 | * since the wpan_dev has been freed, unlike with a netdev where | ||
| 598 | * we need the dev_put() for the netdev to really be freed. | ||
| 599 | */ | ||
| 600 | if (!wpan_dev->netdev) | ||
| 601 | info->user_ptr[1] = NULL; | ||
| 602 | |||
| 603 | return rdev_del_virtual_intf(rdev, wpan_dev); | ||
| 604 | } | ||
| 605 | |||
| 586 | static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info) | 606 | static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info) |
| 587 | { | 607 | { |
| 588 | struct cfg802154_registered_device *rdev = info->user_ptr[0]; | 608 | struct cfg802154_registered_device *rdev = info->user_ptr[0]; |
| @@ -859,6 +879,14 @@ static const struct genl_ops nl802154_ops[] = { | |||
| 859 | NL802154_FLAG_NEED_RTNL, | 879 | NL802154_FLAG_NEED_RTNL, |
| 860 | }, | 880 | }, |
| 861 | { | 881 | { |
| 882 | .cmd = NL802154_CMD_DEL_INTERFACE, | ||
| 883 | .doit = nl802154_del_interface, | ||
| 884 | .policy = nl802154_policy, | ||
| 885 | .flags = GENL_ADMIN_PERM, | ||
| 886 | .internal_flags = NL802154_FLAG_NEED_WPAN_DEV | | ||
| 887 | NL802154_FLAG_NEED_RTNL, | ||
| 888 | }, | ||
| 889 | { | ||
| 862 | .cmd = NL802154_CMD_SET_CHANNEL, | 890 | .cmd = NL802154_CMD_SET_CHANNEL, |
| 863 | .doit = nl802154_set_channel, | 891 | .doit = nl802154_set_channel, |
| 864 | .policy = nl802154_policy, | 892 | .policy = nl802154_policy, |
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h index 06e97542dafb..40ffbc0d8b85 100644 --- a/net/ieee802154/rdev-ops.h +++ b/net/ieee802154/rdev-ops.h | |||
| @@ -29,6 +29,13 @@ rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name, | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | static inline int | 31 | static inline int |
| 32 | rdev_del_virtual_intf(struct cfg802154_registered_device *rdev, | ||
| 33 | struct wpan_dev *wpan_dev) | ||
| 34 | { | ||
| 35 | return rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev); | ||
| 36 | } | ||
| 37 | |||
| 38 | static inline int | ||
| 32 | rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) | 39 | rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) |
| 33 | { | 40 | { |
| 34 | return rdev->ops->set_channel(&rdev->wpan_phy, page, channel); | 41 | return rdev->ops->set_channel(&rdev->wpan_phy, page, channel); |
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c index 568d712bfc8c..7def2625eaca 100644 --- a/net/mac802154/cfg.c +++ b/net/mac802154/cfg.c | |||
| @@ -58,6 +58,14 @@ ieee802154_add_iface(struct wpan_phy *phy, const char *name, | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | static int | 60 | static int |
| 61 | ieee802154_del_iface(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev) | ||
| 62 | { | ||
| 63 | ieee802154_if_remove(IEEE802154_WPAN_DEV_TO_SUB_IF(wpan_dev)); | ||
| 64 | |||
| 65 | return 0; | ||
| 66 | } | ||
| 67 | |||
| 68 | static int | ||
| 61 | ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel) | 69 | ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel) |
| 62 | { | 70 | { |
| 63 | struct ieee802154_local *local = wpan_phy_priv(wpan_phy); | 71 | struct ieee802154_local *local = wpan_phy_priv(wpan_phy); |
| @@ -191,6 +199,7 @@ const struct cfg802154_ops mac802154_config_ops = { | |||
| 191 | .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated, | 199 | .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated, |
| 192 | .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated, | 200 | .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated, |
| 193 | .add_virtual_intf = ieee802154_add_iface, | 201 | .add_virtual_intf = ieee802154_add_iface, |
| 202 | .del_virtual_intf = ieee802154_del_iface, | ||
| 194 | .set_channel = ieee802154_set_channel, | 203 | .set_channel = ieee802154_set_channel, |
| 195 | .set_pan_id = ieee802154_set_pan_id, | 204 | .set_pan_id = ieee802154_set_pan_id, |
| 196 | .set_short_addr = ieee802154_set_short_addr, | 205 | .set_short_addr = ieee802154_set_short_addr, |
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index cc691637d24b..bebd70ffc7a3 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h | |||
| @@ -115,6 +115,12 @@ IEEE802154_DEV_TO_SUB_IF(const struct net_device *dev) | |||
| 115 | return netdev_priv(dev); | 115 | return netdev_priv(dev); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | static inline struct ieee802154_sub_if_data * | ||
| 119 | IEEE802154_WPAN_DEV_TO_SUB_IF(struct wpan_dev *wpan_dev) | ||
| 120 | { | ||
| 121 | return container_of(wpan_dev, struct ieee802154_sub_if_data, wpan_dev); | ||
| 122 | } | ||
| 123 | |||
| 118 | static inline bool | 124 | static inline bool |
| 119 | ieee802154_sdata_running(struct ieee802154_sub_if_data *sdata) | 125 | ieee802154_sdata_running(struct ieee802154_sub_if_data *sdata) |
| 120 | { | 126 | { |
