aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-05-26 07:52:25 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-05-26 07:52:25 -0400
commit3bb20556726702a27166e49ef513bd8d8432d9c4 (patch)
tree0b67e06ea839378823866d4d35fe46101cdef7f1 /net/wireless
parent34171dc0d623be2c1032416bf7d3819f388ed70d (diff)
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: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/core.c5
-rw-r--r--net/wireless/nl80211.c21
-rw-r--r--net/wireless/nl80211.h3
3 files changed, 22 insertions, 7 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c
index d03d8bdb29ca..a1c40654dd9b 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -130,7 +130,7 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
130 newname)) 130 newname))
131 pr_err("failed to rename debugfs dir to %s!\n", newname); 131 pr_err("failed to rename debugfs dir to %s!\n", newname);
132 132
133 nl80211_notify_dev_rename(rdev); 133 nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
134 134
135 return 0; 135 return 0;
136} 136}
@@ -660,6 +660,8 @@ int wiphy_register(struct wiphy *wiphy)
660 return res; 660 return res;
661 } 661 }
662 662
663 nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
664
663 return 0; 665 return 0;
664} 666}
665EXPORT_SYMBOL(wiphy_register); 667EXPORT_SYMBOL(wiphy_register);
@@ -698,6 +700,7 @@ void wiphy_unregister(struct wiphy *wiphy)
698 rfkill_unregister(rdev->rfkill); 700 rfkill_unregister(rdev->rfkill);
699 701
700 rtnl_lock(); 702 rtnl_lock();
703 nl80211_notify_wiphy(rdev, NL80211_CMD_DEL_WIPHY);
701 rdev->wiphy.registered = false; 704 rdev->wiphy.registered = false;
702 705
703 WARN_ON(!list_empty(&rdev->wdev_list)); 706 WARN_ON(!list_empty(&rdev->wdev_list));
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 62bdb1adaa4d..ba4f1723c83a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1226,6 +1226,7 @@ struct nl80211_dump_wiphy_state {
1226}; 1226};
1227 1227
1228static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, 1228static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
1229 enum nl80211_commands cmd,
1229 struct sk_buff *msg, u32 portid, u32 seq, 1230 struct sk_buff *msg, u32 portid, u32 seq,
1230 int flags, struct nl80211_dump_wiphy_state *state) 1231 int flags, struct nl80211_dump_wiphy_state *state)
1231{ 1232{
@@ -1240,7 +1241,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
1240 rdev->wiphy.mgmt_stypes; 1241 rdev->wiphy.mgmt_stypes;
1241 u32 features; 1242 u32 features;
1242 1243
1243 hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_WIPHY); 1244 hdr = nl80211hdr_put(msg, portid, seq, flags, cmd);
1244 if (!hdr) 1245 if (!hdr)
1245 return -ENOBUFS; 1246 return -ENOBUFS;
1246 1247
@@ -1254,6 +1255,9 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
1254 cfg80211_rdev_list_generation)) 1255 cfg80211_rdev_list_generation))
1255 goto nla_put_failure; 1256 goto nla_put_failure;
1256 1257
1258 if (cmd != NL80211_CMD_NEW_WIPHY)
1259 goto finish;
1260
1257 switch (state->split_start) { 1261 switch (state->split_start) {
1258 case 0: 1262 case 0:
1259 if (nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, 1263 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 state->split_start = 0; 1686 state->split_start = 0;
1683 break; 1687 break;
1684 } 1688 }
1689 finish:
1685 return genlmsg_end(msg, hdr); 1690 return genlmsg_end(msg, hdr);
1686 1691
1687 nla_put_failure: 1692 nla_put_failure:
@@ -1756,7 +1761,8 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
1756 continue; 1761 continue;
1757 /* attempt to fit multiple wiphy data chunks into the skb */ 1762 /* attempt to fit multiple wiphy data chunks into the skb */
1758 do { 1763 do {
1759 ret = nl80211_send_wiphy(rdev, skb, 1764 ret = nl80211_send_wiphy(rdev, NL80211_CMD_NEW_WIPHY,
1765 skb,
1760 NETLINK_CB(cb->skb).portid, 1766 NETLINK_CB(cb->skb).portid,
1761 cb->nlh->nlmsg_seq, 1767 cb->nlh->nlmsg_seq,
1762 NLM_F_MULTI, state); 1768 NLM_F_MULTI, state);
@@ -1811,7 +1817,8 @@ static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info)
1811 if (!msg) 1817 if (!msg)
1812 return -ENOMEM; 1818 return -ENOMEM;
1813 1819
1814 if (nl80211_send_wiphy(rdev, msg, info->snd_portid, info->snd_seq, 0, 1820 if (nl80211_send_wiphy(rdev, NL80211_CMD_NEW_WIPHY, msg,
1821 info->snd_portid, info->snd_seq, 0,
1815 &state) < 0) { 1822 &state) < 0) {
1816 nlmsg_free(msg); 1823 nlmsg_free(msg);
1817 return -ENOBUFS; 1824 return -ENOBUFS;
@@ -10101,16 +10108,20 @@ static const struct genl_ops nl80211_ops[] = {
10101 10108
10102/* notification functions */ 10109/* notification functions */
10103 10110
10104void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev) 10111void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev,
10112 enum nl80211_commands cmd)
10105{ 10113{
10106 struct sk_buff *msg; 10114 struct sk_buff *msg;
10107 struct nl80211_dump_wiphy_state state = {}; 10115 struct nl80211_dump_wiphy_state state = {};
10108 10116
10117 WARN_ON(cmd != NL80211_CMD_NEW_WIPHY &&
10118 cmd != NL80211_CMD_DEL_WIPHY);
10119
10109 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 10120 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
10110 if (!msg) 10121 if (!msg)
10111 return; 10122 return;
10112 10123
10113 if (nl80211_send_wiphy(rdev, msg, 0, 0, 0, &state) < 0) { 10124 if (nl80211_send_wiphy(rdev, cmd, msg, 0, 0, 0, &state) < 0) {
10114 nlmsg_free(msg); 10125 nlmsg_free(msg);
10115 return; 10126 return;
10116 } 10127 }
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
index 1e6df9630f42..49c9a482dd12 100644
--- a/net/wireless/nl80211.h
+++ b/net/wireless/nl80211.h
@@ -5,7 +5,8 @@
5 5
6int nl80211_init(void); 6int nl80211_init(void);
7void nl80211_exit(void); 7void nl80211_exit(void);
8void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev); 8void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev,
9 enum nl80211_commands cmd);
9void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, 10void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
10 struct wireless_dev *wdev); 11 struct wireless_dev *wdev);
11struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev, 12struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,