Linux wireless drivers development
 help / color / mirror / Atom feed
From: Zhao Li <enderaoelyther@gmail.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH wireless] wifi: mac80211: allow automatic control-port link selection
Date: Mon, 16 Nov 2026 12:30:42 +0800	[thread overview]
Message-ID: <20261116043042.14324-1-enderaoelyther@gmail.com> (raw)

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.

Fixes: 9dd1953846c7 ("wifi: nl80211/mac80211: clarify link ID in control port TX")
Fixes: a64a20fb270f ("wifi: mac80211: store the ack skb before building the header")
Cc: stable@vger.kernel.org # needs adjustments for <= 7.3
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
---
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(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index e9b6a0415d6a..459803d345b1 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -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
-- 
2.56.1


                 reply	other threads:[~2026-11-16  4:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116043042.14324-1-enderaoelyther@gmail.com \
    --to=enderaoelyther@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox