Commit 3bb20556 authored by Johannes Berg's avatar Johannes Berg

cfg80211: send events when devices are added/removed

We're currently sending NEW_WIPHY events for renames (which
is a bit odd, but now can't be changed), but also send them
for really new devices that register.

Also send DEL_WIPHY events when a device is removed, the
event ID for this was already reserved.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 34171dc0
...@@ -130,7 +130,7 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev, ...@@ -130,7 +130,7 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
newname)) newname))
pr_err("failed to rename debugfs dir to %s!\n", newname); pr_err("failed to rename debugfs dir to %s!\n", newname);
nl80211_notify_dev_rename(rdev); nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
return 0; return 0;
} }
...@@ -660,6 +660,8 @@ int wiphy_register(struct wiphy *wiphy) ...@@ -660,6 +660,8 @@ int wiphy_register(struct wiphy *wiphy)
return res; return res;
} }
nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
return 0; return 0;
} }
EXPORT_SYMBOL(wiphy_register); EXPORT_SYMBOL(wiphy_register);
...@@ -698,6 +700,7 @@ void wiphy_unregister(struct wiphy *wiphy) ...@@ -698,6 +700,7 @@ void wiphy_unregister(struct wiphy *wiphy)
rfkill_unregister(rdev->rfkill); rfkill_unregister(rdev->rfkill);
rtnl_lock(); rtnl_lock();
nl80211_notify_wiphy(rdev, NL80211_CMD_DEL_WIPHY);
rdev->wiphy.registered = false; rdev->wiphy.registered = false;
WARN_ON(!list_empty(&rdev->wdev_list)); WARN_ON(!list_empty(&rdev->wdev_list));
......
...@@ -1226,6 +1226,7 @@ struct nl80211_dump_wiphy_state { ...@@ -1226,6 +1226,7 @@ struct nl80211_dump_wiphy_state {
}; };
static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
enum nl80211_commands cmd,
struct sk_buff *msg, u32 portid, u32 seq, struct sk_buff *msg, u32 portid, u32 seq,
int flags, struct nl80211_dump_wiphy_state *state) int flags, struct nl80211_dump_wiphy_state *state)
{ {
...@@ -1240,7 +1241,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, ...@@ -1240,7 +1241,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
rdev->wiphy.mgmt_stypes; rdev->wiphy.mgmt_stypes;
u32 features; u32 features;
hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_WIPHY); hdr = nl80211hdr_put(msg, portid, seq, flags, cmd);
if (!hdr) if (!hdr)
return -ENOBUFS; return -ENOBUFS;
...@@ -1254,6 +1255,9 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, ...@@ -1254,6 +1255,9 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
cfg80211_rdev_list_generation)) cfg80211_rdev_list_generation))
goto nla_put_failure; goto nla_put_failure;
if (cmd != NL80211_CMD_NEW_WIPHY)
goto finish;
switch (state->split_start) { switch (state->split_start) {
case 0: case 0:
if (nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, if (nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT,
...@@ -1682,6 +1686,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, ...@@ -1682,6 +1686,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
state->split_start = 0; state->split_start = 0;
break; break;
} }
finish:
return genlmsg_end(msg, hdr); return genlmsg_end(msg, hdr);
nla_put_failure: nla_put_failure:
...@@ -1756,7 +1761,8 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -1756,7 +1761,8 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
continue; continue;
/* attempt to fit multiple wiphy data chunks into the skb */ /* attempt to fit multiple wiphy data chunks into the skb */
do { do {
ret = nl80211_send_wiphy(rdev, skb, ret = nl80211_send_wiphy(rdev, NL80211_CMD_NEW_WIPHY,
skb,
NETLINK_CB(cb->skb).portid, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, cb->nlh->nlmsg_seq,
NLM_F_MULTI, state); NLM_F_MULTI, state);
...@@ -1811,7 +1817,8 @@ static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info) ...@@ -1811,7 +1817,8 @@ static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info)
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
if (nl80211_send_wiphy(rdev, msg, info->snd_portid, info->snd_seq, 0, if (nl80211_send_wiphy(rdev, NL80211_CMD_NEW_WIPHY, msg,
info->snd_portid, info->snd_seq, 0,
&state) < 0) { &state) < 0) {
nlmsg_free(msg); nlmsg_free(msg);
return -ENOBUFS; return -ENOBUFS;
...@@ -10101,16 +10108,20 @@ static const struct genl_ops nl80211_ops[] = { ...@@ -10101,16 +10108,20 @@ static const struct genl_ops nl80211_ops[] = {
/* notification functions */ /* notification functions */
void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev) void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev,
enum nl80211_commands cmd)
{ {
struct sk_buff *msg; struct sk_buff *msg;
struct nl80211_dump_wiphy_state state = {}; struct nl80211_dump_wiphy_state state = {};
WARN_ON(cmd != NL80211_CMD_NEW_WIPHY &&
cmd != NL80211_CMD_DEL_WIPHY);
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return; return;
if (nl80211_send_wiphy(rdev, msg, 0, 0, 0, &state) < 0) { if (nl80211_send_wiphy(rdev, cmd, msg, 0, 0, 0, &state) < 0) {
nlmsg_free(msg); nlmsg_free(msg);
return; return;
} }
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
int nl80211_init(void); int nl80211_init(void);
void nl80211_exit(void); void nl80211_exit(void);
void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev); void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev,
enum nl80211_commands cmd);
void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev); struct wireless_dev *wdev);
struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev, struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment