From 618df655ae91a96d467185e81a12e0dbd9ab0c50 Mon Sep 17 00:00:00 2001 From: Sai Pratyusha Magam Date: Mon, 18 Dec 2023 09:48:23 +0530 Subject: [PATCH] Use sta->vlan_id when needed for VLAN offload Share VLAN info in RRB when the driver advertises support for VLAN offload (WPA_DRIVER_FLAGS_VLAN_OFFLOAD). sta->vlan_desc is unused in this case, only sta->vlan_id is used. Skip the checks that are based on sta->vlan_desc. Signed-off-by: Sai Pratyusha Magam --- src/ap/wpa_auth_glue.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c index 742f6d419..94b6a7247 100644 --- a/src/ap/wpa_auth_glue.c +++ b/src/ap/wpa_auth_glue.c @@ -1155,17 +1155,25 @@ static int hostapd_wpa_auth_set_vlan(void *ctx, const u8 *sta_addr, if (!sta || !sta->wpa_sm) return -1; - if (vlan->notempty && - !hostapd_vlan_valid(hapd->conf->vlan, vlan)) { - hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, - HOSTAPD_LEVEL_INFO, - "Invalid VLAN %d%s received from FT", - vlan->untagged, vlan->tagged[0] ? "+" : ""); - return -1; - } + if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_VLAN_OFFLOAD)) { + if (vlan->notempty && + !hostapd_vlan_valid(hapd->conf->vlan, vlan)) { + hostapd_logger(hapd, sta->addr, + HOSTAPD_MODULE_IEEE80211, + HOSTAPD_LEVEL_INFO, + "Invalid VLAN %d%s received from FT", + vlan->untagged, vlan->tagged[0] ? + "+" : ""); + return -1; + } - if (ap_sta_set_vlan(hapd, sta, vlan) < 0) - return -1; + if (ap_sta_set_vlan(hapd, sta, vlan) < 0) + return -1; + + } else { + if (vlan->notempty) + sta->vlan_id = vlan->untagged; + } /* Configure wpa_group for GTK but ignore error due to driver not * knowing this STA. */ ap_sta_bind_vlan(hapd, sta); @@ -1188,10 +1196,15 @@ static int hostapd_wpa_auth_get_vlan(void *ctx, const u8 *sta_addr, if (!sta) return -1; - if (sta->vlan_desc) + if (sta->vlan_desc) { *vlan = *sta->vlan_desc; - else + } else if ((hapd->iface->drv_flags & WPA_DRIVER_FLAGS_VLAN_OFFLOAD) && + sta->vlan_id) { + vlan->notempty = 1; + vlan->untagged = sta->vlan_id; + } else { os_memset(vlan, 0, sizeof(*vlan)); + } return 0; } -- 2.47.2