]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Support VLAN offload to the driver
authorGurumoorthi Gnanasambandhan <gguru@codeaurora.org>
Thu, 5 Dec 2019 10:38:47 +0000 (12:38 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 8 Jan 2020 22:48:57 +0000 (00:48 +0200)
If the driver supports VLAN offload mechanism with a single netdev, use
that instead of separate per-VLAN netdevs.

Signed-off-by: Gurumoorthi Gnanasambandhan <gguru@codeaurora.org>
src/ap/sta_info.c
src/ap/wpa_auth_glue.c

index d0198b256081b9787a98fa36045dd1469ff5c94c..c0503f6c579f8055f3c0b357997b09cdf634a542 100644 (file)
@@ -1050,7 +1050,8 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta)
        if (sta->vlan_id == old_vlanid)
                goto skip_counting;
 
-       if (sta->vlan_id > 0 && vlan == NULL) {
+       if (sta->vlan_id > 0 && !vlan &&
+           !(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_VLAN_OFFLOAD)) {
                hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
                               HOSTAPD_LEVEL_DEBUG, "could not find VLAN for "
                               "binding station to (vlan_id=%d)",
index a0131b2b164f9968992226060fa68af0a0492e37..e871cc900a5181e58ab183e8aaf5eec41288218a 100644 (file)
@@ -385,8 +385,12 @@ static int hostapd_wpa_auth_set_key(void *ctx, int vlan_id, enum wpa_alg alg,
 
        if (vlan_id > 0) {
                ifname = hostapd_get_vlan_id_ifname(hapd->conf->vlan, vlan_id);
-               if (ifname == NULL)
-                       return -1;
+               if (!ifname) {
+                       if (!(hapd->iface->drv_flags &
+                             WPA_DRIVER_FLAGS_VLAN_OFFLOAD))
+                               return -1;
+                       ifname = hapd->conf->iface;
+               }
        }
 
 #ifdef CONFIG_TESTING_OPTIONS
@@ -849,26 +853,32 @@ static int hostapd_wpa_auth_update_vlan(void *ctx, const u8 *addr, int vlan_id)
 #ifndef CONFIG_NO_VLAN
        struct hostapd_data *hapd = ctx;
        struct sta_info *sta;
-       struct vlan_description vlan_desc;
 
        sta = ap_get_sta(hapd, addr);
        if (!sta)
                return -1;
 
-       os_memset(&vlan_desc, 0, sizeof(vlan_desc));
-       vlan_desc.notempty = 1;
-       vlan_desc.untagged = vlan_id;
-       if (!hostapd_vlan_valid(hapd->conf->vlan, &vlan_desc)) {
-               wpa_printf(MSG_INFO, "Invalid VLAN ID %d in wpa_psk_file",
-                          vlan_id);
-               return -1;
-       }
+       if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_VLAN_OFFLOAD)) {
+               struct vlan_description vlan_desc;
 
-       if (ap_sta_set_vlan(hapd, sta, &vlan_desc) < 0) {
-               wpa_printf(MSG_INFO,
-                          "Failed to assign VLAN ID %d from wpa_psk_file to "
-                          MACSTR, vlan_id, MAC2STR(sta->addr));
-               return -1;
+               os_memset(&vlan_desc, 0, sizeof(vlan_desc));
+               vlan_desc.notempty = 1;
+               vlan_desc.untagged = vlan_id;
+               if (!hostapd_vlan_valid(hapd->conf->vlan, &vlan_desc)) {
+                       wpa_printf(MSG_INFO,
+                                  "Invalid VLAN ID %d in wpa_psk_file",
+                                  vlan_id);
+                       return -1;
+               }
+
+               if (ap_sta_set_vlan(hapd, sta, &vlan_desc) < 0) {
+                       wpa_printf(MSG_INFO,
+                                  "Failed to assign VLAN ID %d from wpa_psk_file to "
+                                  MACSTR, vlan_id, MAC2STR(sta->addr));
+                       return -1;
+               }
+       } else {
+               sta->vlan_id = vlan_id;
        }
 
        wpa_printf(MSG_INFO,