]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use sta->vlan_id when needed for VLAN offload
authorSai Pratyusha Magam <quic_smagam@quicinc.com>
Mon, 18 Dec 2023 04:18:23 +0000 (09:48 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 21 Dec 2023 10:24:35 +0000 (12:24 +0200)
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 <quic_smagam@quicinc.com>
src/ap/wpa_auth_glue.c

index 742f6d419af653f511ad0f4d9c800b576d041b65..94b6a724758f887e24bc86dc3fe9e2fc5e3e2dde 100644 (file)
@@ -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;
 }