All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH v2 1/4] netdev: move failure point out of netdev_connect_common
Date: Mon, 09 Aug 2021 10:16:13 -0700	[thread overview]
Message-ID: <20210809171616.535514-1-prestwoj@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2727 bytes --]

The only point of failure in netdev_connect_common was setting
up the handshake type. Moving this outside of netdev_connect_common
makes the code flow much better in netdev_{connect,reassociate} as
nothing needs to be reset upon failure.
---
 src/netdev.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/netdev.c b/src/netdev.c
index 1b72b0a7..479791fd 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -3442,7 +3442,7 @@ offload_1x:
 	return 0;
 }
 
-static int netdev_connect_common(struct netdev *netdev,
+static void netdev_connect_common(struct netdev *netdev,
 					struct scan_bss *bss,
 					struct scan_bss *prev_bss,
 					struct handshake_state *hs,
@@ -3463,9 +3463,6 @@ static int netdev_connect_common(struct netdev *netdev,
 		goto build_cmd_connect;
 	}
 
-	if (netdev_handshake_state_setup_connection_type(hs) < 0)
-		return -ENOTSUP;
-
 	if (nhs->type != CONNECTION_TYPE_SOFTMAC)
 		goto build_cmd_connect;
 
@@ -3534,7 +3531,7 @@ build_cmd_connect:
 	wiphy_radio_work_insert(netdev->wiphy, &netdev->work, 1,
 				&connect_work_ops);
 
-	return 0;
+	return;
 }
 
 int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
@@ -3554,9 +3551,14 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
 	if (netdev->connected || netdev->connect_cmd_id || netdev->work.id)
 		return -EISCONN;
 
-	return netdev_connect_common(netdev, bss, NULL, hs, vendor_ies,
+	if (netdev_handshake_state_setup_connection_type(hs) < 0)
+		return -ENOTSUP;
+
+	netdev_connect_common(netdev, bss, NULL, hs, vendor_ies,
 					num_vendor_ies, event_filter, cb,
 					user_data);
+
+	return 0;
 }
 
 static void disconnect_idle(struct l_idle *idle, void *user_data)
@@ -3646,24 +3648,24 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss,
 {
 	struct handshake_state *old_hs;
 	struct eapol_sm *old_sm;
-	int ret;
 
 	old_sm = netdev->sm;
 	old_hs = netdev->handshake;
 
-	ret = netdev_connect_common(netdev, target_bss, orig_bss, hs, NULL, 0,
-					event_filter, cb, user_data);
-	if (ret < 0)
-		return ret;
-
-	if (netdev->ap)
-		memcpy(netdev->ap->prev_bssid, orig_bss->addr, ETH_ALEN);
+	if (netdev_handshake_state_setup_connection_type(hs) < 0)
+		return -ENOTSUP;
 
 	netdev->associated = false;
 	netdev->operational = false;
 	netdev->connected = false;
 	netdev->in_reassoc = true;
 
+	netdev_connect_common(netdev, target_bss, orig_bss, hs, NULL, 0,
+					event_filter, cb, user_data);
+
+	if (netdev->ap)
+		memcpy(netdev->ap->prev_bssid, orig_bss->addr, ETH_ALEN);
+
 	netdev_rssi_polling_update(netdev);
 
 	if (old_sm)
-- 
2.31.1

             reply	other threads:[~2021-08-09 17:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 17:16 James Prestwood [this message]
2021-08-09 17:16 ` [PATCH v2 2/4] station: add ConnectBssid() developer method James Prestwood
2021-08-09 17:16 ` [PATCH v2 3/4] station: move Roam() under station debug interface James Prestwood
2021-08-09 17:16 ` [PATCH v2 4/4] test: update force-roam to use Debug interface James Prestwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210809171616.535514-1-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.