[PATCH 62/92] nl80211: Support key operations (new/set/del) on non-netdev interfaces
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Wed Apr 22 05:23:53 PDT 2026
From: Avraham Stern <avraham.stern at intel.com>
The kernel added support for setting a key on non-netdev interfaces
(like the NAN device interface). Non-netdev interfaces are identified.
Use nl80211_cmd_msg() for building the command for non-netdev devices.
Signed-off-by: Avraham Stern <avraham.stern at intel.com>
---
src/drivers/driver_nl80211.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 62fa9fe6f4..5ca18ee71e 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -3983,7 +3983,11 @@ static int wpa_driver_nl80211_set_key(struct i802_bss *bss,
goto fail2;
} else if (alg == WPA_ALG_NONE) {
wpa_printf(MSG_DEBUG, "nl80211: DEL_KEY");
- msg = nl80211_ifindex_msg(drv, ifindex, 0, NL80211_CMD_DEL_KEY);
+ if (!nl80211_is_netdev_iftype(drv->nlmode))
+ msg = nl80211_cmd_msg(bss, 0, NL80211_CMD_DEL_KEY);
+ else
+ msg = nl80211_ifindex_msg(drv, ifindex, 0,
+ NL80211_CMD_DEL_KEY);
if (!msg)
goto fail2;
} else {
@@ -3995,7 +3999,13 @@ static int wpa_driver_nl80211_set_key(struct i802_bss *bss,
goto fail2;
}
wpa_printf(MSG_DEBUG, "nl80211: NEW_KEY");
- msg = nl80211_ifindex_msg(drv, ifindex, 0, NL80211_CMD_NEW_KEY);
+
+ if (!nl80211_is_netdev_iftype(drv->nlmode))
+ msg = nl80211_cmd_msg(bss, 0, NL80211_CMD_NEW_KEY);
+ else
+ msg = nl80211_ifindex_msg(drv, ifindex, 0,
+ NL80211_CMD_NEW_KEY);
+
if (!msg)
goto fail2;
if (nla_put(key_msg, NL80211_KEY_DATA, key_len, key) ||
@@ -4092,7 +4102,10 @@ static int wpa_driver_nl80211_set_key(struct i802_bss *bss,
if (!key_msg)
return ret;
- msg = nl80211_ifindex_msg(drv, ifindex, 0, NL80211_CMD_SET_KEY);
+ if (!nl80211_is_netdev_iftype(drv->nlmode))
+ msg = nl80211_cmd_msg(bss, 0, NL80211_CMD_SET_KEY);
+ else
+ msg = nl80211_ifindex_msg(drv, ifindex, 0, NL80211_CMD_SET_KEY);
if (!msg)
goto fail2;
if (!key_msg ||
@@ -8346,8 +8359,12 @@ static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
struct nl_msg *msg;
int res;
- msg = nl80211_ifindex_msg(drv, if_nametoindex(iface), 0,
- NL80211_CMD_GET_KEY);
+ if (!nl80211_is_netdev_iftype(drv->nlmode))
+ msg = nl80211_cmd_msg(bss, 0, NL80211_CMD_GET_KEY);
+ else
+ msg = nl80211_ifindex_msg(drv, if_nametoindex(iface), 0,
+ NL80211_CMD_GET_KEY);
+
if (!msg ||
(addr && nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) ||
(link_id != NL80211_DRV_LINK_ID_NA &&
--
2.53.0
More information about the Hostap
mailing list