AP: Provide the link ID for an MLD setting when setting VLAN

This is a required modification to the driver interface and driver
nl80211.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
This commit is contained in:
Ilan Peer 2023-05-22 22:33:55 +03:00 committed by Jouni Malinen
parent 172b0a9a2b
commit fbbca2bf16
4 changed files with 23 additions and 9 deletions

View file

@ -173,12 +173,13 @@ static inline int hostapd_drv_set_countermeasures(struct hostapd_data *hapd,
static inline int hostapd_drv_set_sta_vlan(const char *ifname,
struct hostapd_data *hapd,
const u8 *addr, int vlan_id)
const u8 *addr, int vlan_id,
int link_id)
{
if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
return 0;
return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname,
vlan_id);
vlan_id, link_id);
}
static inline int hostapd_drv_get_inact_sec(struct hostapd_data *hapd,

View file

@ -1086,6 +1086,12 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta)
struct hostapd_vlan *vlan = NULL;
int ret;
int old_vlanid = sta->vlan_id_bound;
int mld_link_id = -1;
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap)
mld_link_id = hapd->mld_link_id;
#endif /* CONFIG_IEEE80211BE */
if ((sta->flags & WLAN_STA_WDS) && sta->vlan_id == 0) {
wpa_printf(MSG_DEBUG,
@ -1143,7 +1149,8 @@ skip_counting:
if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0)
wpa_printf(MSG_INFO, "Failed to update VLAN-ID for WPA");
ret = hostapd_drv_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
ret = hostapd_drv_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id,
mld_link_id);
if (ret < 0) {
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG, "could not bind the STA "

View file

@ -3785,6 +3785,7 @@ struct wpa_driver_ops {
* @ifname: Interface (main or virtual BSS or VLAN)
* @addr: MAC address of the associated station
* @vlan_id: VLAN ID
* @link_id: The link ID or -1 for non-MLO
* Returns: 0 on success, -1 on failure
*
* This function is used to bind a station to a specific virtual
@ -3794,7 +3795,7 @@ struct wpa_driver_ops {
* domains to be used with a single BSS.
*/
int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
int vlan_id);
int vlan_id, int link_id);
/**
* commit - Optional commit changes handler (AP only)

View file

@ -8025,7 +8025,7 @@ fail:
static int i802_set_sta_vlan(struct i802_bss *bss, const u8 *addr,
const char *ifname, int vlan_id)
const char *ifname, int vlan_id, int link_id)
{
struct wpa_driver_nl80211_data *drv = bss->drv;
struct nl_msg *msg;
@ -8039,6 +8039,8 @@ static int i802_set_sta_vlan(struct i802_bss *bss, const u8 *addr,
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) ||
(vlan_id && (drv->capa.flags & WPA_DRIVER_FLAGS_VLAN_OFFLOAD) &&
nla_put_u16(msg, NL80211_ATTR_VLAN_ID, vlan_id)) ||
(link_id != NL80211_DRV_LINK_ID_NA &&
nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, link_id)) ||
nla_put_u32(msg, NL80211_ATTR_STA_VLAN, if_nametoindex(ifname))) {
nlmsg_free(msg);
return -ENOBUFS;
@ -8297,7 +8299,8 @@ static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val,
wpa_printf(MSG_ERROR, "nl80211: Failed to set WDS STA "
"interface %s up", name);
}
return i802_set_sta_vlan(priv, addr, name, 0);
return i802_set_sta_vlan(priv, addr, name, 0,
NL80211_DRV_LINK_ID_NA);
} else {
if (bridge_ifname &&
linux_br_del_if(drv->global->ioctl_sock, bridge_ifname,
@ -8306,7 +8309,8 @@ static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val,
"nl80211: Failed to remove interface %s from bridge %s: %s",
name, bridge_ifname, strerror(errno));
i802_set_sta_vlan(priv, addr, bss->ifname, 0);
i802_set_sta_vlan(priv, addr, bss->ifname, 0,
NL80211_DRV_LINK_ID_NA);
nl80211_remove_iface(drv, if_nametoindex(name));
os_memset(&event, 0, sizeof(event));
event.wds_sta_interface.sta_addr = addr;
@ -10477,10 +10481,11 @@ static int driver_nl80211_sta_remove(void *priv, const u8 *addr)
static int driver_nl80211_set_sta_vlan(void *priv, const u8 *addr,
const char *ifname, int vlan_id)
const char *ifname, int vlan_id,
int link_id)
{
struct i802_bss *bss = priv;
return i802_set_sta_vlan(bss, addr, ifname, vlan_id);
return i802_set_sta_vlan(bss, addr, ifname, vlan_id, link_id);
}