wifi: mac80211: allow automatic control-port link selection
PATCH 1/1 wifi: mac80211: allow automatic control-port link selection
An MLD AP cannot transmit a control-port frame, such as EAPOL, to a non-MLO peer when the request leaves the link unspecified. Header construction selects the peer's link, then the link-ID check rejects that selection. The Ethernet source also remains the MLD address, which header construction copies into the 802.11 source address instead of the selected link address.
On AP interfaces, take the source address from ieee80211_ap_tx_addr_get(), which header construction also uses for the transmitter address, before storing the ACK copy. A station on an AP_VLAN is handled through its AP interface, since nl80211 rejects a control-port request made on an AP_VLAN. Apply the link-ID check only when the request names a link, so an explicit link other than the non-MLO peer's link is still rejected.
Commit 9dd1953846c7 ("wifi: nl80211/mac80211: clarify link ID in control port TX") added the check, which then rejected such a request only when it asked for a TX status report (an ACK cookie). Commit a64a20fb270f ("wifi: mac80211: store the ack skb before building the header") moved the check out of header construction; since then it rejects the request with or without a cookie.
AI assistance was used.
---
Tested with mac80211_hwsim in QEMU: an MLD AP with two active links and a non-MLO peer on link 1. Omitting the link ID succeeds with or without an ACK cookie, and captured frames use the peer's link address for both source and transmitter. Explicit link 1 still works; another configured link returns -EINVAL without transmitting, and an absent link returns -ENOLINK. No kernel warnings or KASAN reports occurred.
Compile-tested with no new W=1 or sparse warnings.
net/mac80211/tx.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
net/mac80211/tx.c +13 -6
@@ -6720,12 +6720,18 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,skb_set_queue_mapping (skb,ieee80211_select_queue (sdata, sta, skb)); -/* -* for MLO STA, the SA should be the AP MLD address, but -* the link ID has been selected already -*/ -if (sta && sta->sta.mlo) +/* The SA must match the TA that ieee80211_build_hdr() will use. */ +if (sta && sdata->vif.type ==NL80211_IFTYPE_AP ) { + err =ieee80211_ap_tx_addr_get (sdata, sta, ehdr->h_source, +NULL ); +if (err) { +dev_kfree_skb (skb); +rcu_read_unlock (); +return err; + } + }else if (sta && sta->sta.mlo) {memcpy (ehdr->h_source, sdata->vif.addr,ETH_ALEN ); + } info =IEEE80211_SKB_CB (skb);memset (info,0 ,sizeof (*info));
@@ -6742,7 +6748,8 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,return PTR_ERR (skb); } -if (link_id !=u32_get_bits (info->control.flags, +if (link_id !=IEEE80211_LINK_UNSPECIFIED && + link_id !=u32_get_bits (info->control.flags,IEEE80211_TX_CTRL_MLO_LINK )) {ieee80211_free_txskb (&local->hw, skb);rcu_read_unlock ();
base-commit: 6b4b543fa18757297ac756a6fe6e64f506b7844a
Signature · 1 line
2.56.1