[PATCH 1/2] AP MLD: Build the Non-Inheritance element generically

Andrei Otcheretianski andrei.otcheretianski at intel.com
Wed Nov 25 04:32:23 PST 2026


A reported link inherits from the reporting link every element that the
reporting link carries and the reported link does not, unless that
element is listed in the Non-Inheritance element. hostapd only ever
listed the RSNXE there, so for an AP MLD with links on different bands
the reported link also inherited the band specific elements of the
reporting link. For example, a 2.4 GHz link reported by a 5 GHz link
inherited the VHT Capabilities and VHT Operation elements.

Build the set of elements that may be inherited for both the reporting
and the reported link and compare them:

 - present only in the reporting link: list it as non-inherited;
 - present in both with identical content: omit it from the profile,
   which is what the inheritance mechanism is for;
 - anything else: include it in the profile.

The RSNXE is derived the same way now, so there is a single place that
decides and a single Non-Inheritance element in the profile. Emit it as
the last element of the STA Profile field as required by
IEEE P802.11-REVmf/D3.0 35.3.3.3.

Inheritance is only defined against the elements that the frame carries
outside the Basic Multi-Link element, so Link Reconfiguration Response
needs to include a complete profile.

Dropping the elements that are identical on both links also shrinks the
profiles considerably.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
 src/ap/ieee802_11.c     | 188 ++++++++++++++++++++++++++++++++--------
 src/ap/ieee802_11.h     |   2 +-
 src/ap/ieee802_11_eht.c |   8 +-
 3 files changed, 161 insertions(+), 37 deletions(-)

diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index 736b1bda34..c458f7752e 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -7674,9 +7674,99 @@ static int check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta,
 
 #ifdef CONFIG_IEEE80211BE
 
+/* Enough room for the elements built by ieee80211_ml_build_inheritable() */
+#define ML_INHERITABLE_LEN 384
+
+struct ml_inheritance {
+	u8 own[ML_INHERITABLE_LEN];
+	u8 ref[ML_INHERITABLE_LEN];
+	size_t own_len;
+	size_t ref_len;
+};
+
+
+/*
+ * Elements a reported link is allowed to inherit from the reporting link.
+ * Built in increasing Element ID order, as the Non-Inheritance lists are
+ * required to be sorted.
+ */
+static size_t ieee80211_ml_build_inheritable(struct hostapd_data *hapd,
+					    u8 *buf, bool omit_rsnxe)
+{
+	const u8 *rsnxe;
+	u8 *p = buf;
+
+	p = hostapd_eid_ht_capabilities(hapd, p);
+	p = hostapd_eid_ht_operation(hapd, p);
+
+	/* hostapd_eid_vht_capabilities() does not check this by itself */
+	if (hostapd_is_vht_enabled(hapd)) {
+		p = hostapd_eid_vht_capabilities(hapd, p, 0);
+		p = hostapd_eid_vht_operation(hapd, p);
+	}
+
+	if (hostapd_is_he_enabled(hapd))
+		p = hostapd_eid_he_6ghz_band_cap(hapd, p);
+
+	rsnxe = omit_rsnxe ? NULL : hostapd_wpa_ie(hapd, WLAN_EID_RSNX);
+	if (rsnxe && (size_t) (buf + ML_INHERITABLE_LEN - p) >= 2 + rsnxe[1]) {
+		os_memcpy(p, rsnxe, 2 + rsnxe[1]);
+		p += 2 + rsnxe[1];
+	}
+
+	return p - buf;
+}
+
+
+/* An element is inherited only when both links have it with the same content */
+static bool ieee80211_ml_inherited(const struct ml_inheritance *inh,
+				   u8 eid, u8 ext_eid)
+{
+	const u8 *own, *ref;
+
+	if (eid == WLAN_EID_EXTENSION) {
+		own = get_ie_ext(inh->own, inh->own_len, ext_eid);
+		ref = get_ie_ext(inh->ref, inh->ref_len, ext_eid);
+	} else {
+		own = get_ie(inh->own, inh->own_len, eid);
+		ref = get_ie(inh->ref, inh->ref_len, eid);
+	}
+
+	return own && ref && own[1] == ref[1] &&
+		os_memcmp(own, ref, 2 + own[1]) == 0;
+}
+
+
+static u8 * hostapd_eid_non_inheritance(u8 *eid, size_t len,
+					const u8 *ids, u8 num_ids,
+					const u8 *ext_ids, u8 num_ext_ids)
+{
+	if (!num_ids && !num_ext_ids)
+		return eid;
+
+	if (len < 5 + (size_t) num_ids + num_ext_ids)
+		return eid;
+
+	*eid++ = WLAN_EID_EXTENSION;
+	/* Element ID Extension + the length octet of each of the two lists */
+	*eid++ = 3 + num_ids + num_ext_ids;
+	*eid++ = WLAN_EID_EXT_NON_INHERITANCE;
+
+	*eid++ = num_ids;
+	os_memcpy(eid, ids, num_ids);
+	eid += num_ids;
+
+	*eid++ = num_ext_ids;
+	os_memcpy(eid, ext_ids, num_ext_ids);
+	eid += num_ext_ids;
+
+	return eid;
+}
+
+
 void ieee80211_ml_build_assoc_resp(struct hostapd_data *hapd,
 				   struct mld_link_info *link,
-				   struct sta_info *sta)
+				   struct sta_info *sta, bool allow_inherit)
 {
 	struct hostapd_data *assoc_hapd;
 	struct sta_info *assoc_sta;
@@ -7684,6 +7774,10 @@ void ieee80211_ml_build_assoc_resp(struct hostapd_data *hapd,
 	u8 *p = buf;
 	size_t buflen = sizeof(buf);
 	u8 *end = p + buflen;
+	struct ml_inheritance inh = { .own_len = 0, .ref_len = 0 };
+	u8 non_inherit[8], non_inherit_ext[4];
+	u8 non_inherit_len = 0, non_inherit_ext_len = 0;
+	bool omit_rsnxe = false;
 
 	/* Capability Info */
 	WPA_PUT_LE16(p, hostapd_own_capab_info(hapd));
@@ -7696,16 +7790,54 @@ void ieee80211_ml_build_assoc_resp(struct hostapd_data *hapd,
 	if (link->status != WLAN_STATUS_SUCCESS)
 		goto out;
 
+	assoc_sta = hostapd_ml_get_assoc_sta(hapd, sta, &assoc_hapd);
+	if (assoc_sta && hapd != assoc_hapd && allow_inherit) {
+		const struct element *elem;
+
+		omit_rsnxe = assoc_hapd->conf->rsn_override_omit_rsnxe;
+		inh.own_len = ieee80211_ml_build_inheritable(hapd, inh.own,
+							     omit_rsnxe);
+		inh.ref_len = ieee80211_ml_build_inheritable(assoc_hapd,
+							     inh.ref,
+							     omit_rsnxe);
+
+		/*
+		 * An element that the reporting link includes but this link
+		 * does not would otherwise be inherited by the reported link,
+		 * so it has to be listed as non-inherited.
+		 */
+		for_each_element(elem, inh.ref, inh.ref_len) {
+			if (elem->id == WLAN_EID_EXTENSION) {
+				if (!elem->datalen ||
+				    get_ie_ext(inh.own, inh.own_len,
+					       elem->data[0]) ||
+				    non_inherit_ext_len >=
+				    sizeof(non_inherit_ext))
+					continue;
+				non_inherit_ext[non_inherit_ext_len++] =
+					elem->data[0];
+			} else if (!get_ie(inh.own, inh.own_len, elem->id) &&
+				   non_inherit_len < sizeof(non_inherit)) {
+				non_inherit[non_inherit_len++] = elem->id;
+			}
+		}
+	}
+
 	/* AID is not included */
 	p = hostapd_eid_supp_rates(hapd, p);
 	p = hostapd_eid_ext_supp_rates(hapd, p);
 	p = hostapd_eid_rm_enabled_capab(hapd, p, buf + buflen - p);
-	p = hostapd_eid_ht_capabilities(hapd, p);
-	p = hostapd_eid_ht_operation(hapd, p);
+
+	if (!ieee80211_ml_inherited(&inh, WLAN_EID_HT_CAP, 0))
+		p = hostapd_eid_ht_capabilities(hapd, p);
+	if (!ieee80211_ml_inherited(&inh, WLAN_EID_HT_OPERATION, 0))
+		p = hostapd_eid_ht_operation(hapd, p);
 
 	if (hostapd_is_vht_enabled(hapd)) {
-		p = hostapd_eid_vht_capabilities(hapd, p, 0);
-		p = hostapd_eid_vht_operation(hapd, p);
+		if (!ieee80211_ml_inherited(&inh, WLAN_EID_VHT_CAP, 0))
+			p = hostapd_eid_vht_capabilities(hapd, p, 0);
+		if (!ieee80211_ml_inherited(&inh, WLAN_EID_VHT_OPERATION, 0))
+			p = hostapd_eid_vht_operation(hapd, p);
 	}
 
 	if (hostapd_is_he_enabled(hapd)) {
@@ -7713,7 +7845,9 @@ void ieee80211_ml_build_assoc_resp(struct hostapd_data *hapd,
 		p = hostapd_eid_he_operation(hapd, p);
 		p = hostapd_eid_spatial_reuse(hapd, p);
 		p = hostapd_eid_he_mu_edca_parameter_set(hapd, p);
-		p = hostapd_eid_he_6ghz_band_cap(hapd, p);
+		if (!ieee80211_ml_inherited(&inh, WLAN_EID_EXTENSION,
+					    WLAN_EID_EXT_HE_6GHZ_BAND_CAP))
+			p = hostapd_eid_he_6ghz_band_cap(hapd, p);
 		if (hostapd_is_eht_enabled(hapd)) {
 			p = hostapd_eid_eht_capab(hapd, p, IEEE80211_MODE_AP);
 			p = hostapd_eid_eht_operation(hapd, p);
@@ -7723,40 +7857,27 @@ void ieee80211_ml_build_assoc_resp(struct hostapd_data *hapd,
 	p = hostapd_eid_ext_capab(hapd, p, end - p, false);
 
 
-	assoc_sta = hostapd_ml_get_assoc_sta(hapd, sta, &assoc_hapd);
 	if (assoc_sta && hapd != assoc_hapd) {
-		const u8 *rsnxe, *assoc_rsnxe;
+		const u8 *rsnxe;
 #ifdef CONFIG_ENC_ASSOC
 		const u8 *rsne, *assoc_rsne;
 #endif /* CONFIG_ENC_ASSOC */
-		u8 ie_count = 0, non_inherit_ie[2];
 
 		rsnxe = hostapd_wpa_ie(hapd, WLAN_EID_RSNX);
-		assoc_rsnxe = hostapd_wpa_ie(assoc_hapd, WLAN_EID_RSNX);
 #ifdef CONFIG_ENC_ASSOC
 		rsne = hostapd_wpa_ie(hapd, WLAN_EID_RSN);
 		assoc_rsne = hostapd_wpa_ie(assoc_hapd, WLAN_EID_RSN);
 #endif /* CONFIG_ENC_ASSOC */
 
-		if (assoc_hapd->conf->rsn_override_omit_rsnxe)
-			goto omit_rsnxe;
-
-		if (assoc_rsnxe && !rsnxe)
-			non_inherit_ie[ie_count++] = WLAN_EID_RSNX;
-
-		if ((!assoc_rsnxe && rsnxe) ||
-		    (rsnxe && assoc_rsnxe &&
-		     (rsnxe[1] != assoc_rsnxe[1] ||
-		      os_memcmp(rsnxe, assoc_rsnxe, 2 + rsnxe[1]) != 0))) {
-			size_t rsnx_ie_len;
+		if (!omit_rsnxe && rsnxe &&
+		    !ieee80211_ml_inherited(&inh, WLAN_EID_RSNX, 0)) {
+			size_t rsnx_ie_len = 2 + rsnxe[1];
 
-			rsnx_ie_len = 2 + rsnxe[1];
 			if ((size_t) (buf + buflen - p) >= rsnx_ie_len) {
 				os_memcpy(p, rsnxe, rsnx_ie_len);
 				p += rsnx_ie_len;
 			}
 		}
-omit_rsnxe:
 #ifdef CONFIG_ENC_ASSOC
 		if (ap_sta_is_epp(sta) &&
 		    wpa_auth_ap_sta_support_assoc_enc(sta->wpa_sm)) {
@@ -7773,15 +7894,6 @@ omit_rsnxe:
 			}
 		}
 #endif /* CONFIG_ENC_ASSOC */
-		if (ie_count) {
-			*p++ = WLAN_EID_EXTENSION;
-			*p++ = 2 + ie_count + 1;
-			*p++ = WLAN_EID_EXT_NON_INHERITANCE;
-			*p++ = ie_count;
-			os_memcpy(p, non_inherit_ie, ie_count);
-			p += ie_count;
-			*p++ = 0; /* No Element ID Extension List */
-		}
 	}
 
 #ifdef CONFIG_IEEE80211BN
@@ -7805,6 +7917,10 @@ omit_rsnxe:
 		p += wpabuf_len(hapd->conf->assocresp_elements);
 	}
 
+	/* The Non-Inheritance element has to be the last one in the profile */
+	p = hostapd_eid_non_inheritance(p, buf + buflen - p,
+					non_inherit, non_inherit_len,
+					non_inherit_ext, non_inherit_ext_len);
 out:
 	os_free(link->resp_sta_profile);
 	link->resp_sta_profile = os_memdup(buf, p - buf);
@@ -7932,7 +8048,7 @@ out:
 	link->status = status;
 
 	if (!offload && type != LINK_PARSE_RECONF)
-		ieee80211_ml_build_assoc_resp(hapd, link, sta);
+		ieee80211_ml_build_assoc_resp(hapd, link, sta, true);
 
 	wpa_printf(MSG_DEBUG, "MLD: link: status=%u", status);
 	if (status != WLAN_STATUS_SUCCESS) {
@@ -8014,12 +8130,14 @@ int hostapd_process_assoc_ml_info(struct hostapd_data *hapd,
 
 			link->status = WLAN_STATUS_UNSPECIFIED_FAILURE;
 			if (!offload)
-				ieee80211_ml_build_assoc_resp(hapd, link, sta);
+				ieee80211_ml_build_assoc_resp(hapd, link, sta,
+							      true);
 		} else if (tx_link_status != WLAN_STATUS_SUCCESS) {
 			/* TX link rejected the connection */
 			link->status = WLAN_STATUS_DENIED_TX_LINK_NOT_ACCEPTED;
 			if (!offload)
-				ieee80211_ml_build_assoc_resp(hapd, link, sta);
+				ieee80211_ml_build_assoc_resp(hapd, link, sta,
+							      true);
 		} else {
 			if (ieee80211_ml_process_link(
 				    bss, sta, link, ies, ies_len,
diff --git a/src/ap/ieee802_11.h b/src/ap/ieee802_11.h
index 4eff89fb72..00a49563c8 100644
--- a/src/ap/ieee802_11.h
+++ b/src/ap/ieee802_11.h
@@ -323,7 +323,7 @@ int ieee80211_ml_process_link(struct hostapd_data *hapd,
 			      bool *set_beacon);
 void ieee80211_ml_build_assoc_resp(struct hostapd_data *hapd,
 				   struct mld_link_info *link,
-				   struct sta_info *sta);
+				   struct sta_info *sta, bool allow_inherit);
 
 void ieee802_11_rx_protected_eht_action(struct hostapd_data *hapd,
 					const struct ieee80211_mgmt *mgmt,
diff --git a/src/ap/ieee802_11_eht.c b/src/ap/ieee802_11_eht.c
index 06e8b8c11d..10dfbd96f8 100644
--- a/src/ap/ieee802_11_eht.c
+++ b/src/ap/ieee802_11_eht.c
@@ -1939,7 +1939,13 @@ hostapd_send_link_reconf_resp(struct hostapd_data *hapd,
 				continue;
 
 			link->valid = true;
-			ieee80211_ml_build_assoc_resp(lhapd, link, assoc_sta);
+			/*
+			 * A Link Reconfiguration Response frame carries no
+			 * elements outside the ML element, so nothing can be
+			 * inherited and the profile has to be complete.
+			 */
+			ieee80211_ml_build_assoc_resp(lhapd, link, assoc_sta,
+						      false);
 		}
 		/* TODO: Basic MLE is not supposed to include BPCC in Link
 		 * Reconfiguration Response, but mac80211 implementation for
-- 
2.56.1




More information about the Hostap mailing list