Skip to contentSkip to conversation

netdev: allow SAE reassociation

PATCH Superseded James Prestwood 2 participants 5 messages Aug 5, 2021

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 netdev: allow SAE reassociation

This adds support in netdev_reassociate for SAE. An SAE auth protocol is created rather than the connect command and from here there is virtually no difference to a normal connection attempt. The only differences are 'in_roam' is set as to ignore the inevitable disconnect event and PREV_BSSID is appended to CMD_ASSOCIATE only for this new reassociation case.

---
 src/netdev.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
src/netdev.c +24 -8
index deb780dc..f42e7881 100644
@@ -182,6 +182,7 @@ struct netdev {
 	bool aborting : 1;
 	bool events_ready : 1;
 	bool retry_auth : 1;
+	bool in_reassoc : 1;
 };
 
 struct netdev_preauth_state {
@@ -756,6 +757,7 @@ static void netdev_connect_free(struct netdev *netdev)
 	netdev->result = NETDEV_RESULT_OK;
 	netdev->last_code = 0;
 	netdev->in_ft = false;
+	netdev->in_reassoc = false;
 	netdev->ignore_connect_event = false;
 	netdev->expect_connect_failure = false;
 	netdev->cur_rssi_low = false;
@@ -1098,7 +1100,7 @@ static void netdev_disconnect_event(struct l_genl_msg *msg,
 	l_debug("");
 
 	if (!netdev->connected || netdev->disconnect_cmd_id > 0 ||
-			netdev->in_ft)
+			netdev->in_ft || netdev->in_reassoc)
 		return;
 
 	if (!l_genl_attr_init(&attr, msg)) {
@@ -2535,6 +2537,7 @@ static void netdev_associate_event(struct l_genl_msg *msg,
 								false);
 
 			netdev->in_ft = false;
+			netdev->in_reassoc = false;
 			netdev->associated = true;
 			return;
 		} else if (ret == -EAGAIN) {
@@ -2716,6 +2719,11 @@ static void netdev_sae_tx_associate(void *user_data)
 
 	l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, n_used);
 
+	/* If doing a non-FT Reassociation */
+	if (netdev->in_reassoc && !IE_AKM_IS_FT(netdev->handshake->akm_suite))
+		l_genl_msg_append_attr(msg, NL80211_ATTR_PREV_BSSID, 6,
+					netdev->prev_bssid);
+
 	if (!l_genl_family_send(nl80211, msg, netdev_assoc_cb, netdev, NULL)) {
 		l_genl_msg_unref(msg);
 		netdev_connect_failed(netdev, NETDEV_RESULT_ASSOCIATION_FAILED,
@@ -3584,7 +3592,7 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss,
 			netdev_event_func_t event_filter,
 			netdev_connect_cb_t cb, void *user_data)
 {
-	struct l_genl_msg *cmd_connect;
+	struct l_genl_msg *cmd_connect = NULL;
 	struct netdev_handshake_state;
 	struct handshake_state *old_hs;
 	struct eapol_sm *sm = NULL, *old_sm;
@@ -3594,16 +3602,21 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss,
 	if (netdev_handshake_state_setup_connection_type(hs) < 0)
 		return -ENOTSUP;
 
-	/* TODO: SoftMac SAE/FILS Re-Associations are not suppored yet */
-	if (L_WARN_ON(IE_AKM_IS_SAE(hs->akm_suite) ||
-				IE_AKM_IS_FILS(hs->akm_suite)))
+	/* TODO: SoftMac FILS Re-Associations are not suppored yet */
+	if (L_WARN_ON(IE_AKM_IS_FILS(hs->akm_suite)))
 		return -ENOTSUP;
 
-	cmd_connect = netdev_build_cmd_connect(netdev, target_bss, hs,
+	if (IE_AKM_IS_SAE(hs->akm_suite))
+		netdev->ap = sae_sm_new(hs, netdev_sae_tx_authenticate,
+						netdev_sae_tx_associate,
+						netdev);
+	else {
+		cmd_connect = netdev_build_cmd_connect(netdev, target_bss, hs,
 						orig_bss->addr, NULL, 0);
 
-	if (is_rsn)
-		sm = eapol_sm_new(hs);
+		if (is_rsn)
+			sm = eapol_sm_new(hs);
+	}
 
 	old_sm = netdev->sm;
 	old_hs = netdev->handshake;
@@ -3613,11 +3626,14 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss,
 	if (err < 0)
 		return err;
 
+	l_debug("reassociate to "MAC, MAC_STR(target_bss->addr));
+
 	memcpy(netdev->prev_bssid, orig_bss->addr, ETH_ALEN);
 
 	netdev->associated = false;
 	netdev->operational = false;
 	netdev->connected = false;
+	netdev->in_reassoc = true;
 
 	netdev_rssi_polling_update(netdev);
 
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 2/4 auto-t: add reassociate test to FT-SAE-roam

This refactors to test both FT and reassociation.

---
 autotests/testFT-SAE-roam/TestFT.psk         |  5 +
 autotests/testFT-SAE-roam/connection_test.py | 98 +++++++++++++-------
 2 files changed, 68 insertions(+), 35 deletions(-)
 create mode 100644 autotests/testFT-SAE-roam/TestFT.psk
autotests/testFT-SAE-roam/TestFT.psk new file +5 -0
new file mode 100644
index 00000000..acadaab9
@@ -0,0 +1,5 @@
+[Security]
+Passphrase=EasilyGuessedPassword
+
+[Settings]
+AutoConnect=False
autotests/testFT-SAE-roam/connection_test.py +63 -35

158 lines not on this page · raw message

Signature · 1 line
2.31.1
#2 lore raw

PATCH v2 3/4 auto-t: rename testFT-SAE-roam to testSAE-roam

In reply to James Prestwood

Since reassociation is now tested this name fits better

---
 autotests/{testFT-SAE-roam => testSAE-roam}/TestFT.psk         | 0
 autotests/{testFT-SAE-roam => testSAE-roam}/connection_test.py | 0
 autotests/{testFT-SAE-roam => testSAE-roam}/ft-psk-3.conf      | 0
 autotests/{testFT-SAE-roam => testSAE-roam}/ft-sae-1.conf      | 0
 autotests/{testFT-SAE-roam => testSAE-roam}/ft-sae-2.conf      | 0
 autotests/{testFT-SAE-roam => testSAE-roam}/hw.conf            | 0
 autotests/{testFT-SAE-roam => testSAE-roam}/main.conf          | 0
 7 files changed, 0 insertions(+), 0 deletions(-)
 rename autotests/{testFT-SAE-roam => testSAE-roam}/TestFT.psk (100%)
 rename autotests/{testFT-SAE-roam => testSAE-roam}/connection_test.py (100%)
 rename autotests/{testFT-SAE-roam => testSAE-roam}/ft-psk-3.conf (100%)
 rename autotests/{testFT-SAE-roam => testSAE-roam}/ft-sae-1.conf (100%)
 rename autotests/{testFT-SAE-roam => testSAE-roam}/ft-sae-2.conf (100%)
 rename autotests/{testFT-SAE-roam => testSAE-roam}/hw.conf (100%)
 rename autotests/{testFT-SAE-roam => testSAE-roam}/main.conf (100%)
autotests/testSAE-roam/TestFT.psk renamed from autotests/testFT-SAE-roam/TestFT.psk +0 -0
similarity index 100%
rename from autotests/testFT-SAE-roam/TestFT.psk
rename to autotests/testSAE-roam/TestFT.psk
autotests/testSAE-roam/connection_test.py renamed from autotests/testFT-SAE-roam/connection_test.py +0 -0
similarity index 100%
rename from autotests/testFT-SAE-roam/connection_test.py
rename to autotests/testSAE-roam/connection_test.py
autotests/testSAE-roam/ft-psk-3.conf renamed from autotests/testFT-SAE-roam/ft-psk-3.conf +0 -0
similarity index 100%
rename from autotests/testFT-SAE-roam/ft-psk-3.conf
rename to autotests/testSAE-roam/ft-psk-3.conf
autotests/testSAE-roam/ft-sae-1.conf renamed from autotests/testFT-SAE-roam/ft-sae-1.conf +0 -0
similarity index 100%
rename from autotests/testFT-SAE-roam/ft-sae-1.conf
rename to autotests/testSAE-roam/ft-sae-1.conf
autotests/testSAE-roam/ft-sae-2.conf renamed from autotests/testFT-SAE-roam/ft-sae-2.conf +0 -0
similarity index 100%
rename from autotests/testFT-SAE-roam/ft-sae-2.conf
rename to autotests/testSAE-roam/ft-sae-2.conf
autotests/testSAE-roam/hw.conf renamed from autotests/testFT-SAE-roam/hw.conf +0 -0
similarity index 100%
rename from autotests/testFT-SAE-roam/hw.conf
rename to autotests/testSAE-roam/hw.conf
autotests/testSAE-roam/main.conf renamed from autotests/testFT-SAE-roam/main.conf +0 -0
similarity index 100%
rename from autotests/testFT-SAE-roam/main.conf
rename to autotests/testSAE-roam/main.conf
Signature · 1 line
2.31.1
#3 lore raw

PATCH v2 4/4 netdev: enable FILS reassociation

In reply to James Prestwood

In the same vein of SAE reassociation create a FILS auth proto just as we would for a normal connection. Then append the PREV_BSSID for reassociation.

---
 src/netdev.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
src/netdev.c +9 -4
index f42e7881..3beb767c 100644
@@ -2807,6 +2807,11 @@ static void netdev_fils_tx_associate(struct iovec *iov, size_t iov_len,
 	l_genl_msg_append_attr(msg, NL80211_ATTR_FILS_KEK, kek_len, kek);
 	l_genl_msg_append_attr(msg, NL80211_ATTR_FILS_NONCES, nonces_len, nonces);
 
+	/* If doing a non-FT Reassociation */
+	if (netdev->in_reassoc && !IE_AKM_IS_FT(netdev->handshake->akm_suite))
+		l_genl_msg_append_attr(msg, NL80211_ATTR_PREV_BSSID, 6,
+					netdev->prev_bssid);
+
 	if (!l_genl_family_send(nl80211, msg, netdev_assoc_cb,
 							netdev, NULL)) {
 		l_genl_msg_unref(msg);
@@ -3602,14 +3607,14 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss,
 	if (netdev_handshake_state_setup_connection_type(hs) < 0)
 		return -ENOTSUP;
 
-	/* TODO: SoftMac FILS Re-Associations are not suppored yet */
-	if (L_WARN_ON(IE_AKM_IS_FILS(hs->akm_suite)))
-		return -ENOTSUP;
-
 	if (IE_AKM_IS_SAE(hs->akm_suite))
 		netdev->ap = sae_sm_new(hs, netdev_sae_tx_authenticate,
 						netdev_sae_tx_associate,
 						netdev);
+	else if (IE_AKM_IS_FILS(hs->akm_suite))
+		netdev->ap = fils_sm_new(hs, netdev_fils_tx_authenticate,
+						netdev_fils_tx_associate,
+						netdev);
 	else {
 		cmd_connect = netdev_build_cmd_connect(netdev, target_bss, hs,
 						orig_bss->addr, NULL, 0);
Signature · 1 line
2.31.1
#4 lore raw
In reply to James Prestwood

Hi James,

Quoted 4 lines · James Prestwood

This adds support in netdev_reassociate for SAE. An SAE auth protocol is created rather than the connect command and from here there is virtually no difference to a normal connection attempt. The only differences are 'in_roam' is set as to

Did you mean 'in_reassoc' here?

Quoted 6 lines

ignore the inevitable disconnect event and PREV_BSSID is appended to CMD_ASSOCIATE only for this new reassociation case.

---
  src/netdev.c | 32 ++++++++++++++++++++++++--------
  1 file changed, 24 insertions(+), 8 deletions(-)

Please rebase on top of git HEAD.

src/netdev.c static void netdev_sae_tx_associate(void *user_data) · line 2726

Quoted 9 lines
src/netdev.c +5 -0
@@ -2716,6 +2719,11 @@ static void netdev_sae_tx_associate(void *user_data)
 
  	l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, n_used);
 
+	/* If doing a non-FT Reassociation */
+	if (netdev->in_reassoc && !IE_AKM_IS_FT(netdev->handshake->akm_suite))
+		l_genl_msg_append_attr(msg, NL80211_ATTR_PREV_BSSID, 6,
+					netdev->prev_bssid);
+

Actually I added auth_proto::prev_bssid just recently with exactly this in mind.

Quoted 21 lines
src/netdev.c +3 -4
  	if (!l_genl_family_send(nl80211, msg, netdev_assoc_cb, netdev, NULL)) {
  		l_genl_msg_unref(msg);
  		netdev_connect_failed(netdev, NETDEV_RESULT_ASSOCIATION_FAILED,
@@ -3584,7 +3592,7 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss,
  			netdev_event_func_t event_filter,
  			netdev_connect_cb_t cb, void *user_data)
  {
-	struct l_genl_msg *cmd_connect;
+	struct l_genl_msg *cmd_connect = NULL;
  	struct netdev_handshake_state;
  	struct handshake_state *old_hs;
  	struct eapol_sm *sm = NULL, *old_sm;
@@ -3594,16 +3602,21 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss,
  	if (netdev_handshake_state_setup_connection_type(hs) < 0)
  		return -ENOTSUP;
 
-	/* TODO: SoftMac SAE/FILS Re-Associations are not suppored yet */
-	if (L_WARN_ON(IE_AKM_IS_SAE(hs->akm_suite) ||
-				IE_AKM_IS_FILS(hs->akm_suite)))
+	/* TODO: SoftMac FILS Re-Associations are not suppored yet */
+	if (L_WARN_ON(IE_AKM_IS_FILS(hs->akm_suite)))

src/netdev.c int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss, · line 3615

Quoted 10 lines
src/netdev.c +6 -1
  		return -ENOTSUP;
 
-	cmd_connect = netdev_build_cmd_connect(netdev, target_bss, hs,
+	if (IE_AKM_IS_SAE(hs->akm_suite))
+		netdev->ap = sae_sm_new(hs, netdev_sae_tx_authenticate,
+						netdev_sae_tx_associate,
+						netdev);
+	else {
+		cmd_connect = netdev_build_cmd_connect(netdev, target_bss, hs,
  						orig_bss->addr, NULL, 0);

This should be taking SAE offload into account, similar to netdev_connect path...

src/netdev.c int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss, · line 3622

Quoted 9 lines
src/netdev.c +3 -2
-	if (is_rsn)
-		sm = eapol_sm_new(hs);
+		if (is_rsn)
+			sm = eapol_sm_new(hs);
+	}
 
  	old_sm = netdev->sm;
  	old_hs = netdev->handshake;

Regards,
-Denis