Skip to content

Commit 348baf0

Browse files
committed
nl80211: send event when AP operation is stopped
There are a few cases, e.g. suspend, where an AP interface is stopped by the kernel rather than by userspace request, most commonly when suspending. To let userspace know about this, send the NL80211_CMD_STOP_AP command as an event every time an AP interface is stopped. This also happens when userspace did in fact request the AP stop, but that's not a problem. For full-MAC drivers this may need to be extended to also cover cases where the device stopped the AP operation for some reason, this a bit more complicated because then all cfg80211 state also needs to be reset; such API is not part of this patch. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent d8ca16d commit 348baf0

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎net/wireless/ap.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
3030
wdev->channel = NULL;
3131
wdev->ssid_len = 0;
3232
rdev_set_qos_map(rdev, dev, NULL);
33+
nl80211_send_ap_stopped(wdev);
3334
}
3435

3536
return err;

‎net/wireless/nl80211.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11677,6 +11677,35 @@ void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp)
1167711677
}
1167811678
EXPORT_SYMBOL(cfg80211_crit_proto_stopped);
1167911679

11680+
void nl80211_send_ap_stopped(struct wireless_dev *wdev)
11681+
{
11682+
struct wiphy *wiphy = wdev->wiphy;
11683+
struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
11684+
struct sk_buff *msg;
11685+
void *hdr;
11686+
11687+
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
11688+
if (!msg)
11689+
return;
11690+
11691+
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_STOP_AP);
11692+
if (!hdr)
11693+
goto out;
11694+
11695+
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
11696+
nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex) ||
11697+
nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
11698+
goto out;
11699+
11700+
genlmsg_end(msg, hdr);
11701+
11702+
genlmsg_multicast_netns(&nl80211_fam, wiphy_net(wiphy), msg, 0,
11703+
NL80211_MCGRP_MLME, GFP_KERNEL);
11704+
return;
11705+
out:
11706+
nlmsg_free(msg);
11707+
}
11708+
1168011709
/* initialisation/exit functions */
1168111710

1168211711
int nl80211_init(void)

‎net/wireless/nl80211.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ nl80211_radar_notify(struct cfg80211_registered_device *rdev,
7474
enum nl80211_radar_event event,
7575
struct net_device *netdev, gfp_t gfp);
7676

77+
void nl80211_send_ap_stopped(struct wireless_dev *wdev);
78+
7779
void cfg80211_rdev_free_coalesce(struct cfg80211_registered_device *rdev);
7880

7981
#endif /* __NET_WIRELESS_NL80211_H */

0 commit comments

Comments
 (0)