]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add vlan_id to driver set_key() operation
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)
This is in preparation for adding support to use a single WLAN netdev
with VLAN operations offloaded to the driver. No functional changes are
included in this commit.

Signed-off-by: Gurumoorthi Gnanasambandhan <gguru@codeaurora.org>
hostapd/ctrl_iface.c
src/ap/ap_drv_ops.c
src/ap/ap_drv_ops.h
src/ap/hostapd.c
src/ap/ieee802_11.c
src/ap/ieee802_1x.c
src/ap/wpa_auth_glue.c
src/drivers/driver.h

index cb4d8fac277b484aada1648fde11794286f95300..af49551848aba4cfe24677c9f9928f2dd4a4765e 100644 (file)
@@ -2154,7 +2154,7 @@ static int hostapd_ctrl_reset_pn(struct hostapd_data *hapd, const char *cmd)
                if (hostapd_drv_set_key(hapd->conf->iface, hapd,
                                        hapd->last_igtk_alg,
                                        broadcast_ether_addr,
-                                       hapd->last_igtk_key_idx, 1, NULL, 0,
+                                       hapd->last_igtk_key_idx, 0, 1, NULL, 0,
                                        zero, hapd->last_igtk_len) < 0)
                        return -1;
 
@@ -2162,8 +2162,8 @@ static int hostapd_ctrl_reset_pn(struct hostapd_data *hapd, const char *cmd)
                return hostapd_drv_set_key(hapd->conf->iface, hapd,
                                           hapd->last_igtk_alg,
                                           broadcast_ether_addr,
-                                          hapd->last_igtk_key_idx, 1, NULL, 0,
-                                          hapd->last_igtk,
+                                          hapd->last_igtk_key_idx, 0, 1, NULL,
+                                          0, hapd->last_igtk,
                                           hapd->last_igtk_len);
        }
 
@@ -2178,7 +2178,7 @@ static int hostapd_ctrl_reset_pn(struct hostapd_data *hapd, const char *cmd)
                if (hostapd_drv_set_key(hapd->conf->iface, hapd,
                                        hapd->last_gtk_alg,
                                        broadcast_ether_addr,
-                                       hapd->last_gtk_key_idx, 1, NULL, 0,
+                                       hapd->last_gtk_key_idx, 0, 1, NULL, 0,
                                        zero, hapd->last_gtk_len) < 0)
                        return -1;
 
@@ -2186,8 +2186,9 @@ static int hostapd_ctrl_reset_pn(struct hostapd_data *hapd, const char *cmd)
                return hostapd_drv_set_key(hapd->conf->iface, hapd,
                                           hapd->last_gtk_alg,
                                           broadcast_ether_addr,
-                                          hapd->last_gtk_key_idx, 1, NULL, 0,
-                                          hapd->last_gtk, hapd->last_gtk_len);
+                                          hapd->last_gtk_key_idx, 0, 1, NULL,
+                                          0, hapd->last_gtk,
+                                          hapd->last_gtk_len);
        }
 
        sta = ap_get_sta(hapd, addr);
@@ -2203,14 +2204,14 @@ static int hostapd_ctrl_reset_pn(struct hostapd_data *hapd, const char *cmd)
        /* First, use a zero key to avoid any possible duplicate key avoidance
         * in the driver. */
        if (hostapd_drv_set_key(hapd->conf->iface, hapd, sta->last_tk_alg,
-                               sta->addr, sta->last_tk_key_idx, 1, NULL, 0,
+                               sta->addr, sta->last_tk_key_idx, 0, 1, NULL, 0,
                                zero, sta->last_tk_len) < 0)
                return -1;
 
        /* Set the previously configured key to reset its TSC/RSC */
        return hostapd_drv_set_key(hapd->conf->iface, hapd, sta->last_tk_alg,
-                                  sta->addr, sta->last_tk_key_idx, 1, NULL, 0,
-                                  sta->last_tk, sta->last_tk_len);
+                                  sta->addr, sta->last_tk_key_idx, 0, 1, NULL,
+                                  0, sta->last_tk, sta->last_tk_len);
 }
 
 
@@ -2257,7 +2258,7 @@ static int hostapd_ctrl_set_key(struct hostapd_data *hapd, const char *cmd)
                return -1;
 
        wpa_printf(MSG_INFO, "TESTING: Set key");
-       return hostapd_drv_set_key(hapd->conf->iface, hapd, alg, addr, idx,
+       return hostapd_drv_set_key(hapd->conf->iface, hapd, alg, addr, idx, 0,
                                   set_tx, seq, 6, key, key_len);
 }
 
@@ -2273,7 +2274,7 @@ static void restore_tk(void *ctx1, void *ctx2)
         * in replay protection issues for now since there is no clean way of
         * preventing encryption of a single EAPOL frame. */
        hostapd_drv_set_key(hapd->conf->iface, hapd, sta->last_tk_alg,
-                           sta->addr, sta->last_tk_key_idx, 1, NULL, 0,
+                           sta->addr, sta->last_tk_key_idx, 0, 1, NULL, 0,
                            sta->last_tk, sta->last_tk_len);
 }
 
@@ -2297,8 +2298,8 @@ static int hostapd_ctrl_resend_m1(struct hostapd_data *hapd, const char *cmd)
                wpa_printf(MSG_INFO, "TESTING: Clear TK for " MACSTR,
                           MAC2STR(sta->addr));
                hostapd_drv_set_key(hapd->conf->iface, hapd, WPA_ALG_NONE,
-                                   sta->addr, sta->last_tk_key_idx, 0, NULL, 0,
-                                   NULL, 0);
+                                   sta->addr, sta->last_tk_key_idx, 0, 0, NULL,
+                                   0, NULL, 0);
        }
 
        wpa_printf(MSG_INFO, "TESTING: Send M1 to " MACSTR, MAC2STR(sta->addr));
@@ -2327,8 +2328,8 @@ static int hostapd_ctrl_resend_m3(struct hostapd_data *hapd, const char *cmd)
                wpa_printf(MSG_INFO, "TESTING: Clear TK for " MACSTR,
                           MAC2STR(sta->addr));
                hostapd_drv_set_key(hapd->conf->iface, hapd, WPA_ALG_NONE,
-                                   sta->addr, sta->last_tk_key_idx, 0, NULL, 0,
-                                   NULL, 0);
+                                   sta->addr, sta->last_tk_key_idx, 0, 0, NULL,
+                                   0, NULL, 0);
        }
 
        wpa_printf(MSG_INFO, "TESTING: Send M3 to " MACSTR, MAC2STR(sta->addr));
@@ -2357,8 +2358,8 @@ static int hostapd_ctrl_resend_group_m1(struct hostapd_data *hapd,
                wpa_printf(MSG_INFO, "TESTING: Clear TK for " MACSTR,
                           MAC2STR(sta->addr));
                hostapd_drv_set_key(hapd->conf->iface, hapd, WPA_ALG_NONE,
-                                   sta->addr, sta->last_tk_key_idx, 0, NULL, 0,
-                                   NULL, 0);
+                                   sta->addr, sta->last_tk_key_idx, 0, 0, NULL,
+                                   0, NULL, 0);
        }
 
        wpa_printf(MSG_INFO,
index bb3a6c5c709e08c483b371cf88d4eed3c5d336d8..74f011806341c6b0a5da3ef6ebb55ed8779dd46e 100644 (file)
@@ -680,7 +680,7 @@ int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
 
 int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd,
                        enum wpa_alg alg, const u8 *addr,
-                       int key_idx, int set_tx,
+                       int key_idx, int vlan_id, int set_tx,
                        const u8 *seq, size_t seq_len,
                        const u8 *key, size_t key_len)
 {
@@ -699,6 +699,7 @@ int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd,
        params.seq_len = seq_len;
        params.key = key;
        params.key_len = key_len;
+       params.vlan_id = vlan_id;
 
        return hapd->driver->set_key(hapd->drv_priv, &params);
 }
index b0170df583d67bfede7aaf9f98cc7fd0f3c41e82..30547b713cf9c420bd925f5967f43753dd566b75 100644 (file)
@@ -89,7 +89,7 @@ int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
 int hostapd_drv_set_key(const char *ifname,
                        struct hostapd_data *hapd,
                        enum wpa_alg alg, const u8 *addr,
-                       int key_idx, int set_tx,
+                       int key_idx, int vlan_id, int set_tx,
                        const u8 *seq, size_t seq_len,
                        const u8 *key, size_t key_len);
 int hostapd_drv_send_mlme(struct hostapd_data *hapd,
index 55dd11e065ff548d97a45fc43744199fe4f8c800..3fb493ae540a2b3acb1d02f108a1da87d8863ab2 100644 (file)
@@ -292,7 +292,7 @@ static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd,
        if (!ifname || !hapd->drv_priv)
                return;
        for (i = 0; i < NUM_WEP_KEYS; i++) {
-               if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i,
+               if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i, 0,
                                        0, NULL, 0, NULL, 0)) {
                        wpa_printf(MSG_DEBUG, "Failed to clear default "
                                   "encryption keys (ifname=%s keyidx=%d)",
@@ -302,7 +302,7 @@ static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd,
        if (hapd->conf->ieee80211w) {
                for (i = NUM_WEP_KEYS; i < NUM_WEP_KEYS + 2; i++) {
                        if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE,
-                                               NULL, i, 0, NULL,
+                                               NULL, i, 0, 0, NULL,
                                                0, NULL, 0)) {
                                wpa_printf(MSG_DEBUG, "Failed to clear "
                                           "default mgmt encryption keys "
@@ -328,7 +328,7 @@ static int hostapd_broadcast_wep_set(struct hostapd_data *hapd)
        idx = ssid->wep.idx;
        if (ssid->wep.default_len &&
            hostapd_drv_set_key(hapd->conf->iface,
-                               hapd, WPA_ALG_WEP, broadcast_ether_addr, idx,
+                               hapd, WPA_ALG_WEP, broadcast_ether_addr, idx, 0,
                                1, NULL, 0, ssid->wep.key[idx],
                                ssid->wep.len[idx])) {
                wpa_printf(MSG_WARNING, "Could not set WEP encryption.");
@@ -553,7 +553,7 @@ static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd)
 
        for (i = 0; i < 4; i++) {
                if (hapd->conf->ssid.wep.key[i] &&
-                   hostapd_drv_set_key(iface, hapd, WPA_ALG_WEP, NULL, i,
+                   hostapd_drv_set_key(iface, hapd, WPA_ALG_WEP, NULL, i, 0,
                                        i == hapd->conf->ssid.wep.idx, NULL, 0,
                                        hapd->conf->ssid.wep.key[i],
                                        hapd->conf->ssid.wep.len[i])) {
index 08ceb2e6ceb618414c8a85308ec572ba663b6b1f..aa8b828bec75e7940be455c61887bcbf5e3ecd93 100644 (file)
@@ -4911,7 +4911,7 @@ static void hostapd_set_wds_encryption(struct hostapd_data *hapd,
        for (i = 0; i < 4; i++) {
                if (ssid->wep.key[i] &&
                    hostapd_drv_set_key(ifname_wds, hapd, WPA_ALG_WEP, NULL, i,
-                                       i == ssid->wep.idx, NULL, 0,
+                                       0, i == ssid->wep.idx, NULL, 0,
                                        ssid->wep.key[i], ssid->wep.len[i])) {
                        wpa_printf(MSG_WARNING,
                                   "Could not set WEP keys for WDS interface; %s",
index d0810310cec045249f4be370c6b35a26b13f715a..4bcaec9dab7d6615a40333d70198b35698e9415e 100644 (file)
@@ -284,7 +284,7 @@ static void ieee802_1x_tx_key(struct hostapd_data *hapd, struct sta_info *sta)
                /* TODO: set encryption in TX callback, i.e., only after STA
                 * has ACKed EAPOL-Key frame */
                if (hostapd_drv_set_key(hapd->conf->iface, hapd, WPA_ALG_WEP,
-                                       sta->addr, 0, 1, NULL, 0, ikey,
+                                       sta->addr, 0, 0, 1, NULL, 0, ikey,
                                        hapd->conf->individual_wep_key_len)) {
                        wpa_printf(MSG_ERROR,
                                   "Could not set individual WEP encryption");
@@ -2177,7 +2177,7 @@ static void ieee802_1x_rekey(void *eloop_ctx, void *timeout_ctx)
         * after new broadcast key has been sent to all stations. */
        if (hostapd_drv_set_key(hapd->conf->iface, hapd, WPA_ALG_WEP,
                                broadcast_ether_addr,
-                               eapol->default_wep_key_idx, 1, NULL, 0,
+                               eapol->default_wep_key_idx, 0, 1, NULL, 0,
                                eapol->default_wep_key,
                                hapd->conf->default_wep_key_len)) {
                hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE8021X,
@@ -2470,8 +2470,8 @@ int ieee802_1x_init(struct hostapd_data *hapd)
        if (hapd->conf->default_wep_key_len) {
                for (i = 0; i < 4; i++)
                        hostapd_drv_set_key(hapd->conf->iface, hapd,
-                                           WPA_ALG_NONE, NULL, i, 0, NULL, 0,
-                                           NULL, 0);
+                                           WPA_ALG_NONE, NULL, i, 0, 0, NULL,
+                                           0, NULL, 0);
 
                ieee802_1x_rekey(hapd, NULL);
 
index c523f20f314d6001eb374143c7669f7a38dd705f..a0131b2b164f9968992226060fa68af0a0492e37 100644 (file)
@@ -418,8 +418,8 @@ static int hostapd_wpa_auth_set_key(void *ctx, int vlan_id, enum wpa_alg alg,
                hapd->last_gtk_len = key_len;
        }
 #endif /* CONFIG_TESTING_OPTIONS */
-       return hostapd_drv_set_key(ifname, hapd, alg, addr, idx, 1, NULL, 0,
-                                  key, key_len);
+       return hostapd_drv_set_key(ifname, hapd, alg, addr, idx, vlan_id, 1,
+                                  NULL, 0, key, key_len);
 }
 
 
index 1d18dac312dff40937c39ec5e4be57273329538f..e96a768162ff818656badde93a1665f90875d9bd 100644 (file)
@@ -1588,6 +1588,10 @@ struct wpa_driver_set_key_params {
         *
         * WEP: 5 or 13, TKIP: 32, CCMP/GCMP: 16, IGTK: 16 */
        size_t key_len;
+
+       /**
+        * vlan_id - VLAN index (0..4095) for VLAN offload cases */
+       int vlan_id;
 };
 
 /**