[RFC PATCH 13/23] nl80211: Route set_key operations to PD wdev based on own_addr

Peddolla Harshavardhan Reddy peddolla.reddy at oss.qualcomm.com
Tue Mar 31 22:27:03 PDT 2026


From: Veerendranath Jakkam <vjakkam at qti.qualcomm.com>

When installing keys for PD-only wdevs, the key operation must be sent
using the PD wdev_id instead of the main interface ifindex. Previously,
set_key calls always used the ifname/ifindex of the main BSS, which
caused keys for PD wdevs to be sent on the wrong interface.

Add an own_addr field to struct wpa_driver_set_key_params to identify
the virtual interface on which the key should be installed. In the
nl80211 driver, look up a matching PD BSS by own_addr and, if found,
route the set_key operation to that PD wdev. Since PD wdevs do not have
an ifindex, force ifindex = 0 so that the existing
"ifindex ? nl80211_ifindex_msg() : nl80211_cmd_msg()" logic will use
the wdev_id associated with the selected BSS.

If own_addr is NULL or does not match a PD wdev, the existing behavior
is preserved and the key is installed on the interface identified by
ifname/ifindex.

Signed-off-by: Veerendranath Jakkam <vjakkam at qti.qualcomm.com>
---
 src/drivers/driver.h         | 11 +++++++++++
 src/drivers/driver_nl80211.c | 18 ++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index c7c4e7571..348634fad 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1973,6 +1973,17 @@ struct wpa_driver_set_key_params {
 	 * ifname - Interface name (for multi-SSID/VLAN support) */
 	const char *ifname;
 
+	/**
+	 * own_addr - Own MAC address for the key operation
+	 *
+	 * When non-NULL, identifies the virtual interface (e.g., PD wdev) on
+	 * which the key should be installed.  The driver matches this address
+	 * against its known virtual interfaces (pd_bss, etc.) and uses the
+	 * corresponding wdev for the netlink command.  NULL means use the
+	 * default interface identified by ifname/ifindex.
+	 */
+	const u8 *own_addr;
+
 	/**
 	 * alg - Encryption algorithm
 	 *
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 8bf2ffebc..c68f343e8 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4049,6 +4049,7 @@ static int wpa_driver_nl80211_set_key(struct i802_bss *bss,
 				      struct wpa_driver_set_key_params *params)
 {
 	struct wpa_driver_nl80211_data *drv = bss->drv;
+	struct i802_bss *pd_bss;
 	int ifindex;
 	struct nl_msg *msg;
 	struct nl_msg *key_msg;
@@ -4072,6 +4073,23 @@ static int wpa_driver_nl80211_set_key(struct i802_bss *bss,
 		return 0;
 
 	ifindex = if_nametoindex(ifname);
+
+	/*
+	 * Route key operations to the PD wdev when own_addr matches the PD
+	 * wdev's MAC address. The PD wdev has no ifindex (wdev-only
+	 * interface), so we override bss to pd_bss and set ifindex = 0 so
+	 * that the existing "ifindex ? nl80211_ifindex_msg() : nl80211_cmd_msg()"
+	 * pattern below picks up the correct wdev_id.
+	 */
+	pd_bss = nl80211_get_pd_bss_by_addr(drv, params->own_addr);
+	if (pd_bss) {
+		bss = pd_bss;
+		wpa_printf(MSG_DEBUG,
+			   "nl80211: set_key: routing to PD wdev " MACSTR,
+			   MAC2STR(bss->addr));
+		ifindex = 0; /* PD wdev has no ifindex */
+	}
+
 	wpa_printf(MSG_DEBUG, "%s: ifindex=%d (%s) alg=%d addr=%p key_idx=%d "
 		   "set_tx=%d seq_len=%lu key_len=%lu key_flag=0x%x link_id=%d",
 		   __func__, ifindex, ifname, alg, addr, key_idx, set_tx,
-- 
2.34.1




More information about the Hostap mailing list