cfg80211/mac80211: allow management frame TX in AP mode
Subsystems (2)
Johannes Berg
maintainerPATCH 1/1 cfg80211/mac80211: allow management frame TX in AP mode
From: Johannes Berg <[email protected]>
Enable management frame transmission and subscribing to management frames through nl80211 in both cfg80211 and mac80211. Also update a few places that I forgot to update for P2P-client mode previously, and fix a small bug with non-action frames in this API.
--- net/mac80211/cfg.c | 7 +++++- net/wireless/mlme.c | 54 +++++++++++++++++++++++++++++++++++++++---------- net/wireless/nl80211.c | 10 +++++++-- 3 files changed, 57 insertions(+), 14 deletions(-)
net/wireless/mlme.c +43 -11
@@ -876,21 +876,53 @@ int cfg80211_mlme_mgmt_tx(struct cfg8021if (ieee80211_is_action (mgmt->frame_control) && mgmt->u.action.category !=WLAN_CATEGORY_PUBLIC ) { -/* Verify that we are associated with the destination AP */ +int err =0 ; +wdev_lock (wdev); -if (!wdev->current_bss || -memcmp (wdev->current_bss->pub.bssid, mgmt->bssid, -ETH_ALEN ) !=0 || - ((wdev->iftype ==NL80211_IFTYPE_STATION || - wdev->iftype ==NL80211_IFTYPE_P2P_CLIENT ) && -memcmp (wdev->current_bss->pub.bssid, mgmt->da, -ETH_ALEN ) !=0 )) { -wdev_unlock (wdev); -return -ENOTCONN ; - } +switch (wdev->iftype) { +case NL80211_IFTYPE_ADHOC : +case NL80211_IFTYPE_STATION : +case NL80211_IFTYPE_P2P_CLIENT : +if (!wdev->current_bss) { + err = -ENOTCONN ; +break ; + } + +if (memcmp (wdev->current_bss->pub.bssid, + mgmt->bssid,ETH_ALEN )) { + err = -ENOTCONN ; +break ; + } +/* +* check for IBSS DA must be done by driver as +* cfg80211 doesn't track the stations +*/ +if (wdev->iftype ==NL80211_IFTYPE_ADHOC ) +break ; + +/* for station, check that DA is the AP */ +if (memcmp (wdev->current_bss->pub.bssid, + mgmt->da,ETH_ALEN )) { + err = -ENOTCONN ; +break ; + } +break ; +case NL80211_IFTYPE_AP : +case NL80211_IFTYPE_P2P_GO : +case NL80211_IFTYPE_AP_VLAN : +if (memcmp (mgmt->bssid, dev->dev_addr,ETH_ALEN )) + err = -EINVAL ; +break ; +default : + err = -EOPNOTSUPP ; +break ; + }wdev_unlock (wdev); + +if (err) +return err; }if (memcmp (mgmt->sa, dev->dev_addr,ETH_ALEN ) !=0 )
net/wireless/nl80211.c +8 -2
@@ -4899,7 +4899,10 @@ static int nl80211_register_mgmt(structif (dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_STATION && dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_ADHOC && - dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_CLIENT ) { + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_CLIENT && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_AP && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_AP_VLAN && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_GO ) { err = -EOPNOTSUPP ; goto out; }
@@ -4952,7 +4955,10 @@ static int nl80211_tx_mgmt(struct sk_bufif (dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_STATION && dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_ADHOC && - dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_CLIENT ) { + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_CLIENT && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_AP && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_AP_VLAN && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_GO ) { err = -EOPNOTSUPP ; goto out; }
net/mac80211/cfg.c +6 -1
@@ -1535,7 +1535,11 @@ static int ieee80211_mgmt_tx(struct wiphswitch (sdata->vif.type) {case NL80211_IFTYPE_ADHOC : -if (mgmt->u.action.category ==WLAN_CATEGORY_PUBLIC ) +case NL80211_IFTYPE_AP : +case NL80211_IFTYPE_AP_VLAN : +case NL80211_IFTYPE_P2P_GO : +if (!ieee80211_is_action (mgmt->frame_control) || + mgmt->u.action.category ==WLAN_CATEGORY_PUBLIC )break ;rcu_read_lock (); sta =sta_info_get (sdata, mgmt->da);
@@ -1544,6 +1548,7 @@ static int ieee80211_mgmt_tx(struct wiphreturn -ENOLINK ;break ;case NL80211_IFTYPE_STATION : +case NL80211_IFTYPE_P2P_CLIENT :break ;default :return -EOPNOTSUPP ;
Johannes Berg
maintainerPATCH v2 1/1 cfg80211/mac80211: allow management frame TX in AP mode
From: Johannes Berg <[email protected]>
Enable management frame transmission and subscribing to management frames through nl80211 in both cfg80211 and mac80211. Also update a few places that I forgot to update for P2P-client mode previously, and fix a small bug with non-action frames in this API.
---
v2: diff against right tree ...
net/mac80211/cfg.c | 7 +++++- net/wireless/mlme.c | 54 +++++++++++++++++++++++++++++++++++++++---------- net/wireless/nl80211.c | 10 +++++++-- 3 files changed, 57 insertions(+), 14 deletions(-)
net/wireless/mlme.c +43 -11
@@ -876,21 +876,53 @@ int cfg80211_mlme_mgmt_tx(struct cfg8021if (ieee80211_is_action (mgmt->frame_control) && mgmt->u.action.category !=WLAN_CATEGORY_PUBLIC ) { -/* Verify that we are associated with the destination AP */ +int err =0 ; +wdev_lock (wdev); -if (!wdev->current_bss || -memcmp (wdev->current_bss->pub.bssid, mgmt->bssid, -ETH_ALEN ) !=0 || - ((wdev->iftype ==NL80211_IFTYPE_STATION || - wdev->iftype ==NL80211_IFTYPE_P2P_CLIENT ) && -memcmp (wdev->current_bss->pub.bssid, mgmt->da, -ETH_ALEN ) !=0 )) { -wdev_unlock (wdev); -return -ENOTCONN ; - } +switch (wdev->iftype) { +case NL80211_IFTYPE_ADHOC : +case NL80211_IFTYPE_STATION : +case NL80211_IFTYPE_P2P_CLIENT : +if (!wdev->current_bss) { + err = -ENOTCONN ; +break ; + } + +if (memcmp (wdev->current_bss->pub.bssid, + mgmt->bssid,ETH_ALEN )) { + err = -ENOTCONN ; +break ; + } +/* +* check for IBSS DA must be done by driver as +* cfg80211 doesn't track the stations +*/ +if (wdev->iftype ==NL80211_IFTYPE_ADHOC ) +break ; + +/* for station, check that DA is the AP */ +if (memcmp (wdev->current_bss->pub.bssid, + mgmt->da,ETH_ALEN )) { + err = -ENOTCONN ; +break ; + } +break ; +case NL80211_IFTYPE_AP : +case NL80211_IFTYPE_P2P_GO : +case NL80211_IFTYPE_AP_VLAN : +if (memcmp (mgmt->bssid, dev->dev_addr,ETH_ALEN )) + err = -EINVAL ; +break ; +default : + err = -EOPNOTSUPP ; +break ; + }wdev_unlock (wdev); + +if (err) +return err; }if (memcmp (mgmt->sa, dev->dev_addr,ETH_ALEN ) !=0 )
net/wireless/nl80211.c +8 -2
@@ -4826,7 +4826,10 @@ static int nl80211_register_mgmt(structif (dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_STATION && dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_ADHOC && - dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_CLIENT ) { + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_CLIENT && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_AP && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_AP_VLAN && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_GO ) { err = -EOPNOTSUPP ; goto out; }
@@ -4879,7 +4882,10 @@ static int nl80211_tx_mgmt(struct sk_bufif (dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_STATION && dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_ADHOC && - dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_CLIENT ) { + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_CLIENT && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_AP && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_AP_VLAN && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_GO ) { err = -EOPNOTSUPP ; goto out; }
net/mac80211/cfg.c +6 -1
@@ -1521,7 +1521,11 @@ static int ieee80211_mgmt_tx(struct wiphswitch (sdata->vif.type) {case NL80211_IFTYPE_ADHOC : -if (mgmt->u.action.category ==WLAN_CATEGORY_PUBLIC ) +case NL80211_IFTYPE_AP : +case NL80211_IFTYPE_AP_VLAN : +case NL80211_IFTYPE_P2P_GO : +if (!ieee80211_is_action (mgmt->frame_control) || + mgmt->u.action.category ==WLAN_CATEGORY_PUBLIC )break ;rcu_read_lock (); sta =sta_info_get (sdata, mgmt->da);
@@ -1530,6 +1534,7 @@ static int ieee80211_mgmt_tx(struct wiphreturn -ENOLINK ;break ;case NL80211_IFTYPE_STATION : +case NL80211_IFTYPE_P2P_CLIENT :break ;default :return -EOPNOTSUPP ;