Thomas Gleixner | 1802d0b | 2019-05-27 08:55:21 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 2 | /* |
Varka Bhadram | 69bb631 | 2014-11-25 10:04:57 +0530 | [diff] [blame] | 3 | * Netlink interface for IEEE 802.15.4 stack |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 4 | * |
| 5 | * Copyright 2007, 2008 Siemens AG |
| 6 | * |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 7 | * Written by: |
| 8 | * Sergey Lapin <slapin@ossfans.org> |
| 9 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
| 10 | * Maxim Osipov <maxim.osipov@siemens.com> |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 14 | #include <linux/slab.h> |
Dmitry Eremin-Solenikov | 060e417 | 2010-03-18 19:26:23 +0300 | [diff] [blame] | 15 | #include <linux/if_arp.h> |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 16 | #include <net/netlink.h> |
| 17 | #include <net/genetlink.h> |
Alexander Aring | 5ad60d3 | 2014-10-25 09:41:02 +0200 | [diff] [blame] | 18 | #include <net/cfg802154.h> |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 19 | #include <net/af_ieee802154.h> |
| 20 | #include <net/ieee802154_netdev.h> |
| 21 | #include <net/rtnetlink.h> /* for rtnl_{un,}lock */ |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 22 | #include <linux/nl802154.h> |
| 23 | |
| 24 | #include "ieee802154.h" |
Alexander Aring | 4a9a816 | 2014-11-02 04:18:38 +0100 | [diff] [blame] | 25 | #include "rdev-ops.h" |
| 26 | #include "core.h" |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 27 | |
Eric W. Biederman | 15e4730 | 2012-09-07 20:12:54 +0000 | [diff] [blame] | 28 | static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, |
Varka Bhadram | 4710d80 | 2014-07-02 09:01:09 +0530 | [diff] [blame] | 29 | u32 seq, int flags, struct wpan_phy *phy) |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 30 | { |
| 31 | void *hdr; |
| 32 | int i, pages = 0; |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 33 | uint32_t *buf = kcalloc(32, sizeof(uint32_t), GFP_KERNEL); |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 34 | |
| 35 | pr_debug("%s\n", __func__); |
| 36 | |
| 37 | if (!buf) |
Jesper Juhl | b9cabe5 | 2011-06-12 04:28:16 +0000 | [diff] [blame] | 38 | return -EMSGSIZE; |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 39 | |
| 40 | hdr = genlmsg_put(msg, 0, seq, &nl802154_family, flags, |
Varka Bhadram | 4710d80 | 2014-07-02 09:01:09 +0530 | [diff] [blame] | 41 | IEEE802154_LIST_PHY); |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 42 | if (!hdr) |
| 43 | goto out; |
| 44 | |
Alexander Aring | 4a3a8c0 | 2015-05-22 17:43:52 +0200 | [diff] [blame] | 45 | rtnl_lock(); |
David S. Miller | be51da0 | 2012-04-01 20:45:25 -0400 | [diff] [blame] | 46 | if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || |
| 47 | nla_put_u8(msg, IEEE802154_ATTR_PAGE, phy->current_page) || |
| 48 | nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel)) |
| 49 | goto nla_put_failure; |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 50 | for (i = 0; i < 32; i++) { |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 51 | if (phy->supported.channels[i]) |
| 52 | buf[pages++] = phy->supported.channels[i] | (i << 27); |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 53 | } |
David S. Miller | be51da0 | 2012-04-01 20:45:25 -0400 | [diff] [blame] | 54 | if (pages && |
| 55 | nla_put(msg, IEEE802154_ATTR_CHANNEL_PAGE_LIST, |
| 56 | pages * sizeof(uint32_t), buf)) |
| 57 | goto nla_put_failure; |
Alexander Aring | 4a3a8c0 | 2015-05-22 17:43:52 +0200 | [diff] [blame] | 58 | rtnl_unlock(); |
Jesper Juhl | b9cabe5 | 2011-06-12 04:28:16 +0000 | [diff] [blame] | 59 | kfree(buf); |
Johannes Berg | 053c095 | 2015-01-16 22:09:00 +0100 | [diff] [blame] | 60 | genlmsg_end(msg, hdr); |
| 61 | return 0; |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 62 | |
| 63 | nla_put_failure: |
Alexander Aring | 4a3a8c0 | 2015-05-22 17:43:52 +0200 | [diff] [blame] | 64 | rtnl_unlock(); |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 65 | genlmsg_cancel(msg, hdr); |
| 66 | out: |
| 67 | kfree(buf); |
| 68 | return -EMSGSIZE; |
| 69 | } |
| 70 | |
Johannes Berg | 1c582d9 | 2013-11-14 17:14:41 +0100 | [diff] [blame] | 71 | int ieee802154_list_phy(struct sk_buff *skb, struct genl_info *info) |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 72 | { |
| 73 | /* Request for interface name, index, type, IEEE address, |
Varka Bhadram | 4710d80 | 2014-07-02 09:01:09 +0530 | [diff] [blame] | 74 | * PAN Id, short address |
| 75 | */ |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 76 | struct sk_buff *msg; |
| 77 | struct wpan_phy *phy; |
| 78 | const char *name; |
| 79 | int rc = -ENOBUFS; |
| 80 | |
| 81 | pr_debug("%s\n", __func__); |
| 82 | |
| 83 | if (!info->attrs[IEEE802154_ATTR_PHY_NAME]) |
| 84 | return -EINVAL; |
| 85 | |
| 86 | name = nla_data(info->attrs[IEEE802154_ATTR_PHY_NAME]); |
| 87 | if (name[nla_len(info->attrs[IEEE802154_ATTR_PHY_NAME]) - 1] != '\0') |
| 88 | return -EINVAL; /* phy name should be null-terminated */ |
| 89 | |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 90 | phy = wpan_phy_find(name); |
| 91 | if (!phy) |
| 92 | return -ENODEV; |
| 93 | |
Thomas Graf | 58050fc | 2012-06-28 03:57:45 +0000 | [diff] [blame] | 94 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 95 | if (!msg) |
| 96 | goto out_dev; |
| 97 | |
Eric W. Biederman | 15e4730 | 2012-09-07 20:12:54 +0000 | [diff] [blame] | 98 | rc = ieee802154_nl_fill_phy(msg, info->snd_portid, info->snd_seq, |
Varka Bhadram | 4710d80 | 2014-07-02 09:01:09 +0530 | [diff] [blame] | 99 | 0, phy); |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 100 | if (rc < 0) |
| 101 | goto out_free; |
| 102 | |
| 103 | wpan_phy_put(phy); |
| 104 | |
| 105 | return genlmsg_reply(msg, info); |
| 106 | out_free: |
| 107 | nlmsg_free(msg); |
| 108 | out_dev: |
| 109 | wpan_phy_put(phy); |
| 110 | return rc; |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | struct dump_phy_data { |
| 114 | struct sk_buff *skb; |
| 115 | struct netlink_callback *cb; |
| 116 | int idx, s_idx; |
| 117 | }; |
| 118 | |
| 119 | static int ieee802154_dump_phy_iter(struct wpan_phy *phy, void *_data) |
| 120 | { |
| 121 | int rc; |
| 122 | struct dump_phy_data *data = _data; |
| 123 | |
| 124 | pr_debug("%s\n", __func__); |
| 125 | |
| 126 | if (data->idx++ < data->s_idx) |
| 127 | return 0; |
| 128 | |
| 129 | rc = ieee802154_nl_fill_phy(data->skb, |
Varka Bhadram | 4710d80 | 2014-07-02 09:01:09 +0530 | [diff] [blame] | 130 | NETLINK_CB(data->cb->skb).portid, |
| 131 | data->cb->nlh->nlmsg_seq, |
| 132 | NLM_F_MULTI, |
| 133 | phy); |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 134 | |
| 135 | if (rc < 0) { |
| 136 | data->idx--; |
| 137 | return rc; |
| 138 | } |
| 139 | |
| 140 | return 0; |
| 141 | } |
| 142 | |
Johannes Berg | 1c582d9 | 2013-11-14 17:14:41 +0100 | [diff] [blame] | 143 | int ieee802154_dump_phy(struct sk_buff *skb, struct netlink_callback *cb) |
Dmitry Eremin-Solenikov | 1eaa9d0 | 2009-09-15 17:04:44 +0400 | [diff] [blame] | 144 | { |
| 145 | struct dump_phy_data data = { |
| 146 | .cb = cb, |
| 147 | .skb = skb, |
| 148 | .s_idx = cb->args[0], |
| 149 | .idx = 0, |
| 150 | }; |
| 151 | |
| 152 | pr_debug("%s\n", __func__); |
| 153 | |
| 154 | wpan_phy_for_each(ieee802154_dump_phy_iter, &data); |
| 155 | |
| 156 | cb->args[0] = data.idx; |
| 157 | |
| 158 | return skb->len; |
| 159 | } |
| 160 | |
Johannes Berg | 1c582d9 | 2013-11-14 17:14:41 +0100 | [diff] [blame] | 161 | int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 162 | { |
| 163 | struct sk_buff *msg; |
| 164 | struct wpan_phy *phy; |
| 165 | const char *name; |
| 166 | const char *devname; |
| 167 | int rc = -ENOBUFS; |
| 168 | struct net_device *dev; |
alex.bluesman.smirnov@gmail.com | 90c049b | 2012-05-15 20:50:27 +0000 | [diff] [blame] | 169 | int type = __IEEE802154_DEV_INVALID; |
Varka Bhadram | 5b4a1039 | 2015-04-30 17:44:57 +0200 | [diff] [blame] | 170 | unsigned char name_assign_type; |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 171 | |
| 172 | pr_debug("%s\n", __func__); |
| 173 | |
| 174 | if (!info->attrs[IEEE802154_ATTR_PHY_NAME]) |
| 175 | return -EINVAL; |
| 176 | |
| 177 | name = nla_data(info->attrs[IEEE802154_ATTR_PHY_NAME]); |
| 178 | if (name[nla_len(info->attrs[IEEE802154_ATTR_PHY_NAME]) - 1] != '\0') |
| 179 | return -EINVAL; /* phy name should be null-terminated */ |
| 180 | |
| 181 | if (info->attrs[IEEE802154_ATTR_DEV_NAME]) { |
| 182 | devname = nla_data(info->attrs[IEEE802154_ATTR_DEV_NAME]); |
| 183 | if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1] |
| 184 | != '\0') |
| 185 | return -EINVAL; /* phy name should be null-terminated */ |
Varka Bhadram | 5b4a1039 | 2015-04-30 17:44:57 +0200 | [diff] [blame] | 186 | name_assign_type = NET_NAME_USER; |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 187 | } else { |
| 188 | devname = "wpan%d"; |
Varka Bhadram | 5b4a1039 | 2015-04-30 17:44:57 +0200 | [diff] [blame] | 189 | name_assign_type = NET_NAME_ENUM; |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | if (strlen(devname) >= IFNAMSIZ) |
| 193 | return -ENAMETOOLONG; |
| 194 | |
| 195 | phy = wpan_phy_find(name); |
| 196 | if (!phy) |
| 197 | return -ENODEV; |
| 198 | |
| 199 | msg = ieee802154_nl_new_reply(info, 0, IEEE802154_ADD_IFACE); |
| 200 | if (!msg) |
| 201 | goto out_dev; |
| 202 | |
Dmitry Eremin-Solenikov | 060e417 | 2010-03-18 19:26:23 +0300 | [diff] [blame] | 203 | if (info->attrs[IEEE802154_ATTR_HW_ADDR] && |
| 204 | nla_len(info->attrs[IEEE802154_ATTR_HW_ADDR]) != |
| 205 | IEEE802154_ADDR_LEN) { |
| 206 | rc = -EINVAL; |
| 207 | goto nla_put_failure; |
| 208 | } |
| 209 | |
alex.bluesman.smirnov@gmail.com | 90c049b | 2012-05-15 20:50:27 +0000 | [diff] [blame] | 210 | if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) { |
| 211 | type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]); |
Christian Engelmayer | 267d29a | 2014-01-11 22:19:30 +0100 | [diff] [blame] | 212 | if (type >= __IEEE802154_DEV_MAX) { |
| 213 | rc = -EINVAL; |
| 214 | goto nla_put_failure; |
| 215 | } |
alex.bluesman.smirnov@gmail.com | 90c049b | 2012-05-15 20:50:27 +0000 | [diff] [blame] | 216 | } |
| 217 | |
Alexander Aring | 4a9a816 | 2014-11-02 04:18:38 +0100 | [diff] [blame] | 218 | dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname, |
Varka Bhadram | 5b4a1039 | 2015-04-30 17:44:57 +0200 | [diff] [blame] | 219 | name_assign_type, type); |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 220 | if (IS_ERR(dev)) { |
| 221 | rc = PTR_ERR(dev); |
| 222 | goto nla_put_failure; |
| 223 | } |
Alexander Aring | 12cb56c | 2014-11-05 20:51:16 +0100 | [diff] [blame] | 224 | dev_hold(dev); |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 225 | |
Dmitry Eremin-Solenikov | 060e417 | 2010-03-18 19:26:23 +0300 | [diff] [blame] | 226 | if (info->attrs[IEEE802154_ATTR_HW_ADDR]) { |
| 227 | struct sockaddr addr; |
| 228 | |
| 229 | addr.sa_family = ARPHRD_IEEE802154; |
| 230 | nla_memcpy(&addr.sa_data, info->attrs[IEEE802154_ATTR_HW_ADDR], |
Varka Bhadram | 4710d80 | 2014-07-02 09:01:09 +0530 | [diff] [blame] | 231 | IEEE802154_ADDR_LEN); |
Dmitry Eremin-Solenikov | 060e417 | 2010-03-18 19:26:23 +0300 | [diff] [blame] | 232 | |
Varka Bhadram | 4710d80 | 2014-07-02 09:01:09 +0530 | [diff] [blame] | 233 | /* strangely enough, some callbacks (inetdev_event) from |
Dmitry Eremin-Solenikov | 060e417 | 2010-03-18 19:26:23 +0300 | [diff] [blame] | 234 | * dev_set_mac_address require RTNL_LOCK |
| 235 | */ |
| 236 | rtnl_lock(); |
Petr Machata | 3a37a96 | 2018-12-13 11:54:30 +0000 | [diff] [blame] | 237 | rc = dev_set_mac_address(dev, &addr, NULL); |
Dmitry Eremin-Solenikov | 060e417 | 2010-03-18 19:26:23 +0300 | [diff] [blame] | 238 | rtnl_unlock(); |
| 239 | if (rc) |
| 240 | goto dev_unregister; |
| 241 | } |
| 242 | |
David S. Miller | be51da0 | 2012-04-01 20:45:25 -0400 | [diff] [blame] | 243 | if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || |
| 244 | nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name)) |
| 245 | goto nla_put_failure; |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 246 | dev_put(dev); |
| 247 | |
| 248 | wpan_phy_put(phy); |
| 249 | |
| 250 | return ieee802154_nl_reply(msg, info); |
| 251 | |
Dmitry Eremin-Solenikov | 060e417 | 2010-03-18 19:26:23 +0300 | [diff] [blame] | 252 | dev_unregister: |
| 253 | rtnl_lock(); /* del_iface must be called with RTNL lock */ |
Alexander Aring | 4a9a816 | 2014-11-02 04:18:38 +0100 | [diff] [blame] | 254 | rdev_del_virtual_intf_deprecated(wpan_phy_to_rdev(phy), dev); |
Dmitry Eremin-Solenikov | 060e417 | 2010-03-18 19:26:23 +0300 | [diff] [blame] | 255 | dev_put(dev); |
| 256 | rtnl_unlock(); |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 257 | nla_put_failure: |
| 258 | nlmsg_free(msg); |
| 259 | out_dev: |
| 260 | wpan_phy_put(phy); |
| 261 | return rc; |
| 262 | } |
| 263 | |
Johannes Berg | 1c582d9 | 2013-11-14 17:14:41 +0100 | [diff] [blame] | 264 | int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info) |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 265 | { |
| 266 | struct sk_buff *msg; |
| 267 | struct wpan_phy *phy; |
| 268 | const char *name; |
| 269 | int rc; |
| 270 | struct net_device *dev; |
| 271 | |
| 272 | pr_debug("%s\n", __func__); |
| 273 | |
| 274 | if (!info->attrs[IEEE802154_ATTR_DEV_NAME]) |
| 275 | return -EINVAL; |
| 276 | |
| 277 | name = nla_data(info->attrs[IEEE802154_ATTR_DEV_NAME]); |
| 278 | if (name[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1] != '\0') |
| 279 | return -EINVAL; /* name should be null-terminated */ |
| 280 | |
vegard.nossum@oracle.com | 5b3211d | 2016-07-20 10:43:11 +0200 | [diff] [blame] | 281 | rc = -ENODEV; |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 282 | dev = dev_get_by_name(genl_info_net(info), name); |
| 283 | if (!dev) |
vegard.nossum@oracle.com | 5b3211d | 2016-07-20 10:43:11 +0200 | [diff] [blame] | 284 | return rc; |
| 285 | if (dev->type != ARPHRD_IEEE802154) |
| 286 | goto out; |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 287 | |
Alexander Aring | bd28a11 | 2014-11-05 20:51:18 +0100 | [diff] [blame] | 288 | phy = dev->ieee802154_ptr->wpan_phy; |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 289 | BUG_ON(!phy); |
Alexander Aring | bd28a11 | 2014-11-05 20:51:18 +0100 | [diff] [blame] | 290 | get_device(&phy->dev); |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 291 | |
| 292 | rc = -EINVAL; |
| 293 | /* phy name is optional, but should be checked if it's given */ |
| 294 | if (info->attrs[IEEE802154_ATTR_PHY_NAME]) { |
| 295 | struct wpan_phy *phy2; |
| 296 | |
| 297 | const char *pname = |
| 298 | nla_data(info->attrs[IEEE802154_ATTR_PHY_NAME]); |
| 299 | if (pname[nla_len(info->attrs[IEEE802154_ATTR_PHY_NAME]) - 1] |
| 300 | != '\0') |
| 301 | /* name should be null-terminated */ |
| 302 | goto out_dev; |
| 303 | |
| 304 | phy2 = wpan_phy_find(pname); |
| 305 | if (!phy2) |
| 306 | goto out_dev; |
| 307 | |
| 308 | if (phy != phy2) { |
| 309 | wpan_phy_put(phy2); |
| 310 | goto out_dev; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | rc = -ENOBUFS; |
| 315 | |
| 316 | msg = ieee802154_nl_new_reply(info, 0, IEEE802154_DEL_IFACE); |
| 317 | if (!msg) |
| 318 | goto out_dev; |
| 319 | |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 320 | rtnl_lock(); |
Alexander Aring | 4a9a816 | 2014-11-02 04:18:38 +0100 | [diff] [blame] | 321 | rdev_del_virtual_intf_deprecated(wpan_phy_to_rdev(phy), dev); |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 322 | |
| 323 | /* We don't have device anymore */ |
| 324 | dev_put(dev); |
| 325 | dev = NULL; |
| 326 | |
| 327 | rtnl_unlock(); |
| 328 | |
David S. Miller | be51da0 | 2012-04-01 20:45:25 -0400 | [diff] [blame] | 329 | if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || |
| 330 | nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, name)) |
| 331 | goto nla_put_failure; |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 332 | wpan_phy_put(phy); |
| 333 | |
| 334 | return ieee802154_nl_reply(msg, info); |
| 335 | |
| 336 | nla_put_failure: |
| 337 | nlmsg_free(msg); |
| 338 | out_dev: |
| 339 | wpan_phy_put(phy); |
vegard.nossum@oracle.com | 5b3211d | 2016-07-20 10:43:11 +0200 | [diff] [blame] | 340 | out: |
Dmitry Eremin-Solenikov | bb1cafb | 2009-11-05 16:56:23 +0300 | [diff] [blame] | 341 | if (dev) |
| 342 | dev_put(dev); |
| 343 | |
| 344 | return rc; |
| 345 | } |