From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v3 08/14] netdev: update FT-over-Air to use ft_authenticate()
Date: Thu, 15 Sep 2022 15:07:35 -0700 [thread overview]
Message-ID: <20220915220741.1128728-8-prestwoj@gmail.com> (raw)
In-Reply-To: <20220915220741.1128728-1-prestwoj@gmail.com>
This removes the FT auth-proto entirely from FT-over-Air, and
instead requires using ft_authenticate/ft_associate along with
the new ft_sm state machine.
The authentication phase is now done off-channel which allows
failures to be non-fatal (eventually). Currently the behavior
isn't changed, and failing to authenticate to a BSS will result
in a disconnect.
---
src/ft.c | 6 +++
src/netdev.c | 113 +++++++++++++++++----------------------------------
2 files changed, 44 insertions(+), 75 deletions(-)
diff --git a/src/ft.c b/src/ft.c
index 559e3984..abb2f380 100644
--- a/src/ft.c
+++ b/src/ft.c
@@ -1114,6 +1114,12 @@ static void ft_prepare_handshake(struct ft_info *info,
if (!hs->supplicant_ie)
return;
+ if (info->authenticator_ie)
+ handshake_state_set_authenticator_ie(hs,
+ info->authenticator_ie);
+
+ memcpy(hs->mde + 2, info->mde, 3);
+
memcpy(hs->snonce, info->snonce, sizeof(hs->snonce));
handshake_state_set_fte(hs, info->fte);
diff --git a/src/netdev.c b/src/netdev.c
index 2519feda..cfb741db 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -1395,8 +1395,7 @@ static void netdev_connect_ok(struct netdev *netdev)
netdev->fw_roam_bss = NULL;
}
- /* TODO: Create only for over-DS. Over-air still uses auth-proto */
- if (netdev->handshake->mde && (netdev->handshake->mde[4] & 1)) {
+ if (netdev->handshake->mde) {
if (netdev->ft_sm)
ft_sm_free(netdev->ft_sm);
@@ -4375,48 +4374,6 @@ static int netdev_tx_ft_action_frame(uint32_t ifindex, const uint8_t *dest,
return 0;
}
-static void netdev_cmd_authenticate_ft_cb(struct l_genl_msg *msg,
- void *user_data)
-{
- struct netdev *netdev = user_data;
-
- netdev->connect_cmd_id = 0;
-
- if (l_genl_msg_get_error(msg) < 0)
- netdev_connect_failed(netdev,
- NETDEV_RESULT_AUTHENTICATION_FAILED,
- MMPDU_STATUS_CODE_UNSPECIFIED);
-}
-
-static void netdev_ft_tx_authenticate(struct iovec *iov,
- size_t iov_len, void *user_data)
-{
- struct netdev *netdev = user_data;
- struct l_genl_msg *cmd_authenticate;
-
- cmd_authenticate = netdev_build_cmd_authenticate(netdev,
- NL80211_AUTHTYPE_FT);
- l_genl_msg_append_attrv(cmd_authenticate, NL80211_ATTR_IE, iov,
- iov_len);
-
- netdev->connect_cmd_id = l_genl_family_send(nl80211,
- cmd_authenticate,
- netdev_cmd_authenticate_ft_cb,
- netdev, NULL);
- if (!netdev->connect_cmd_id) {
- l_genl_msg_unref(cmd_authenticate);
- goto restore_snonce;
- }
-
- return;
-
-restore_snonce:
- memcpy(netdev->handshake->snonce, netdev->prev_snonce, 32);
-
- netdev_connect_failed(netdev, NETDEV_RESULT_AUTHENTICATION_FAILED,
- MMPDU_STATUS_CODE_UNSPECIFIED);
-}
-
static int netdev_ft_tx_associate(uint32_t ifindex, const uint8_t *prev_bssid,
struct iovec *ft_iov, size_t n_ft_iov)
{
@@ -4456,7 +4413,8 @@ static int netdev_ft_tx_associate(uint32_t ifindex, const uint8_t *prev_bssid,
return 0;
}
-static void prepare_ft(struct netdev *netdev, const struct scan_bss *target_bss)
+static void prepare_ft(struct netdev *netdev, const uint8_t *addr,
+ uint32_t frequency)
{
struct netdev_handshake_state *nhs;
@@ -4467,15 +4425,9 @@ static void prepare_ft(struct netdev *netdev, const struct scan_bss *target_bss)
*/
memcpy(netdev->prev_snonce, netdev->handshake->snonce, 32);
- netdev->frequency = target_bss->frequency;
-
- handshake_state_set_authenticator_address(netdev->handshake,
- target_bss->addr);
+ handshake_state_set_authenticator_address(netdev->handshake, addr);
- if (target_bss->rsne)
- handshake_state_set_authenticator_ie(netdev->handshake,
- target_bss->rsne);
- memcpy(netdev->handshake->mde + 2, target_bss->mde, 3);
+ netdev->frequency = frequency;
netdev->handshake->active_tk_index = 0;
netdev->associated = false;
@@ -4549,15 +4501,10 @@ static bool netdev_ft_work_ready(struct wiphy_radio_work_item *item)
{
struct netdev *netdev = l_container_of(item, struct netdev, work);
- if (netdev->ft_sm) {
- if (ft_associate(netdev->ft_sm, netdev->handshake->aa))
- goto assoc_failed;
-
- return false;
- }
+ if (ft_associate(netdev->ft_sm, netdev->handshake->aa))
+ goto assoc_failed;
- if (auth_proto_start(netdev->ap))
- return false;
+ return false;
assoc_failed:
/* Restore original nonce */
@@ -4572,6 +4519,27 @@ static const struct wiphy_radio_work_item_ops ft_work_ops = {
.do_work = netdev_ft_work_ready,
};
+static void netdev_ft_authenticate_cb(int err, const uint8_t *addr,
+ uint32_t frequency,
+ void *user_data)
+{
+ struct netdev *netdev = user_data;
+
+ if (err < 0)
+ goto ft_failed;
+
+ prepare_ft(netdev, addr, frequency);
+
+ wiphy_radio_work_insert(netdev->wiphy, &netdev->work,
+ WIPHY_WORK_PRIORITY_CONNECT, &ft_work_ops);
+
+ return;
+
+ft_failed:
+ netdev_connect_failed(netdev, NETDEV_RESULT_AUTHENTICATION_FAILED,
+ MMPDU_STATUS_CODE_UNSPECIFIED);
+}
+
int netdev_fast_transition(struct netdev *netdev,
const struct scan_bss *target_bss,
const struct scan_bss *orig_bss,
@@ -4580,25 +4548,20 @@ int netdev_fast_transition(struct netdev *netdev,
if (!netdev->operational)
return -ENOTCONN;
- if (!netdev->handshake->mde || !target_bss->mde_present ||
+ if (!netdev->ft_sm || !netdev->handshake->mde ||
+ !target_bss->mde_present ||
l_get_le16(netdev->handshake->mde + 2) !=
l_get_le16(target_bss->mde))
return -EINVAL;
netdev->connect_cb = cb;
- netdev->ap = ft_over_air_sm_new(netdev->handshake,
- netdev_ft_tx_authenticate,
- netdev_ft_tx_associate,
- netdev_get_oci, netdev);
- prepare_ft(netdev, target_bss);
-
- handshake_state_new_snonce(netdev->handshake);
-
- wiphy_radio_work_insert(netdev->wiphy, &netdev->work,
- WIPHY_WORK_PRIORITY_CONNECT, &ft_work_ops);
-
- return 0;
+ /*
+ * ft_authenticate uses offchannel so we cant start a wiphy work item
+ * until that completes
+ */
+ return ft_authenticate(netdev->ft_sm, target_bss,
+ netdev_ft_authenticate_cb, netdev);
}
int netdev_fast_transition_over_ds(struct netdev *netdev,
@@ -4617,7 +4580,7 @@ int netdev_fast_transition_over_ds(struct netdev *netdev,
netdev->connect_cb = cb;
- prepare_ft(netdev, target_bss);
+ prepare_ft(netdev, target_bss->addr, target_bss->frequency);
wiphy_radio_work_insert(netdev->wiphy, &netdev->work,
WIPHY_WORK_PRIORITY_CONNECT, &ft_work_ops);
--
2.34.3
next prev parent reply other threads:[~2022-09-15 22:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-15 22:07 [PATCH v3 01/14] frame-xchg: add type to frame_xchg_prefix James Prestwood
2022-09-15 22:07 ` [PATCH v3 02/14] station: don't set OCVC for FT AKMs James Prestwood
2022-09-15 22:07 ` [PATCH v3 03/14] ft: remove OCI element from auth/assoc James Prestwood
2022-09-16 16:05 ` Denis Kenzior
2022-09-16 16:18 ` James Prestwood
2022-09-15 22:07 ` [PATCH v3 04/14] frame-xchg: create global group enum James Prestwood
2022-09-16 16:06 ` Denis Kenzior
2022-09-16 16:28 ` James Prestwood
2022-09-15 22:07 ` [PATCH v3 05/14] ft: netdev: prep for FT isolation into ft.c James Prestwood
2022-09-15 22:07 ` [PATCH v3 06/14] netdev: use new ft_sm for over-DS James Prestwood
2022-09-15 22:07 ` [PATCH v3 07/14] ft: implement offchannel authentication James Prestwood
2022-09-15 22:07 ` James Prestwood [this message]
2022-09-15 22:07 ` [PATCH v3 09/14] ft: remove unused code after refactor James Prestwood
2022-09-15 22:07 ` [PATCH v3 10/14] ft: add ft_sm_can_associate James Prestwood
2022-09-15 22:07 ` [PATCH v3 11/14] netdev: check for authentication for FT-over-DS James Prestwood
2022-09-15 22:07 ` [PATCH v3 12/14] station: create list of roam candidates James Prestwood
2022-09-15 22:07 ` [PATCH v3 13/14] station: try multiple " James Prestwood
2022-09-15 22:07 ` [PATCH v3 14/14] netdev: add NETDEV_EVENT_FT_AUTHENTICATE, handle in station James Prestwood
2022-09-16 16:04 ` [PATCH v3 01/14] frame-xchg: add type to frame_xchg_prefix Denis Kenzior
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=20220915220741.1128728-8-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/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.