doc: add DisableOCV setting
James Prestwood
PATCH v2 1/9 doc: add DisableOCV setting
--- src/iwd.config.rst | 7 +++++++ 1 file changed, 7 insertions(+)
src/iwd.config.rst +7 -0
@@ -181,6 +181,13 @@ The group ``[General]`` contains general settings. off by default. If you want to easily utilize Hotspot 2.0 networks, then setting ``DisableANQP`` to ``false`` is recommended. + * - DisableOCV + - Value: **false**, true + + Disable Operating Channel Validation. Support for this is not advertised + by the kernel so if kernels/drivers exist which don't support OCV it can + be disabled here. + Network -------
Signature · 1 line
2.31.1
James Prestwood
PATCH v2 2/9 eapol: fix incorrect increment appending OCI
This was addign an extra byte to the buffer which hostapd accepted unless there was additional data, like the RSNXE.
--- src/eapol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/eapol.c +1 -1
@@ -1256,7 +1256,7 @@ static void eapol_handle_ptk_1_of_4(struct eapol_sm *sm, ies[ies_len++] =4 +3 ;l_put_be32 (HANDSHAKE_KDE_OCI , ies + ies_len); ies_len +=4 ; -oci_from_chandef (sm->handshake->chandef, ies + ies_len++); +oci_from_chandef (sm->handshake->chandef, ies + ies_len); ies_len +=3 ; }
Signature · 1 line
2.31.1
James Prestwood
PATCH v2 3/9 auth-proto: add auth_proto_rx_oci
In reply to James PrestwoodThis allows auth protos to get notified when the chandef has been set. Since netdev sets chandef already there is no arguments.
--- src/auth-proto.h | 9 +++++++++ 1 file changed, 9 insertions(+)
src/auth-proto.h +9 -0
@@ -44,6 +44,7 @@ struct auth_proto { const uint8_t *frame, size_t len);int (*rx_associate)(struct auth_proto *driver,const uint8_t *frame,size_t len); +int (*rx_oci)(struct auth_proto *driver);bool (*auth_timeout)(struct auth_proto *ap);bool (*assoc_timeout)(struct auth_proto *ap);uint8_t prev_bssid[6 ];
@@ -98,3 +99,11 @@ static inline bool auth_proto_assoc_timeout(struct auth_proto *ap)return false; } + +static inline int auth_proto_rx_oci (struct auth_proto *ap) +{ +if (ap && ap->rx_oci) +return ap->rx_oci (ap); + +return -ENOTSUP ; +}
Signature · 1 line
2.31.1
James Prestwood
PATCH v2 4/9 netdev: change netdev_get_oci to be used as a callback
In reply to James PrestwoodThis can be reused to be called from ft.c
--- src/netdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
src/netdev.c +2 -1
@@ -2077,8 +2077,9 @@ done:L_WARN_ON (!eapol_start (netdev->sm)); } -static int netdev_get_oci (struct netdev *netdev) +static int netdev_get_oci (void *user_data) { +struct netdev *netdev = user_data;struct l_genl_msg *msg =l_genl_msg_new_sized (NL80211_CMD_GET_INTERFACE ,64 );
Signature · 1 line
2.31.1
James Prestwood
PATCH v2 5/9 ft: get OCI prior to reassociation
In reply to James PrestwoodThis modifies the FT logic to fist call get_oci() before reassociation. This allows the OCI to be included in reassociation and in the 4-way handshake later on.
The code path for getting the OCI had to be slightly changed to handle an OCI that is already set. First the handshake chandef is NULL'ed out for any new connection. This prevents a stale OCI from being used. Then some checks were added for this case in netdev_connect_event and if chandef is already set, start the 4-way handshake.
--- src/ft.c | 13 ++++++++++++- src/ft.h | 2 ++ src/netdev.c | 29 ++++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 4 deletions(-)
src/ft.c +12 -1
@@ -40,6 +40,7 @@ struct ft_sm {ft_tx_authenticate_func_t tx_auth;ft_tx_associate_func_t tx_assoc; +ft_get_oci get_oci;void *user_data; };
@@ -640,7 +641,7 @@ static int ft_rx_authenticate(struct auth_proto *ap, const uint8_t *frame,if (ret <0 ) goto auth_error; -return ft_tx_reassociate (ft); +return ft->get_oci (ft->user_data); auth_error:return (int )status_code;
@@ -783,6 +784,13 @@ static int ft_rx_associate(struct auth_proto *ap, const uint8_t *frame,return 0 ; } +static int ft_rx_oci (struct auth_proto *ap) +{ + struct ft_sm *ft = l_container_of(ap, struct ft_sm, ap); + +return ft_tx_reassociate (ft); +} +static void ft_sm_free (struct auth_proto *ap) { struct ft_sm *ft = l_container_of(ap, struct ft_sm, ap);
@@ -890,12 +898,14 @@ static bool ft_start(struct auth_proto *ap)struct auth_proto *ft_over_air_sm_new (struct handshake_state *hs,ft_tx_authenticate_func_t tx_auth,ft_tx_associate_func_t tx_assoc, +ft_get_oci get_oci,void *user_data) { struct ft_sm *ft = l_new(struct ft_sm, 1); ft->tx_auth = tx_auth; ft->tx_assoc = tx_assoc; + ft->get_oci = get_oci; ft->hs = hs; ft->user_data = user_data;
@@ -903,6 +913,7 @@ struct auth_proto *ft_over_air_sm_new(struct handshake_state *hs, ft->ap.rx_associate = ft_rx_associate; ft->ap.start = ft_start; ft->ap.free = ft_sm_free; + ft->ap.rx_oci = ft_rx_oci;return &ft->ap; }
src/ft.h +2 -0
@@ -26,6 +26,7 @@ typedef void (*ft_tx_authenticate_func_t)(struct iovec *iov, size_t iov_len, void *user_data);typedef int (*ft_tx_associate_func_t )(struct iovec *ie_iov,size_t iov_len,void *user_data); +typedef int (*ft_get_oci )(void *user_data);typedef void (*ft_ds_free_func_t )(void *user_data);
@@ -60,6 +61,7 @@ bool ft_over_ds_parse_action_ies(struct ft_ds_info *info,struct auth_proto *ft_over_air_sm_new (struct handshake_state *hs,ft_tx_authenticate_func_t tx_auth,ft_tx_associate_func_t tx_assoc, +ft_get_oci get_oci,void *user_data); struct auth_proto *ft_over_ds_sm_new(struct handshake_state *hs,
src/netdev.c +26 -3
@@ -2074,6 +2074,21 @@ static void netdev_get_oci_cb(struct l_genl_msg *msg, void *user_data)handshake_state_set_chandef (netdev->handshake,l_steal_ptr (chandef)); done: +if (netdev->ap) { +/* +* Cant do much here. IWD assumes every kernel/driver supports +* this. There is no way of detecting support either. +*/ +if (L_WARN_ON (err <0 )) +netdev_connect_failed (netdev, +NETDEV_RESULT_AUTHENTICATION_FAILED , +MMPDU_STATUS_CODE_UNSPECIFIED ); +else +auth_proto_rx_oci (netdev->ap); + +return ; + } +L_WARN_ON (!eapol_start (netdev->sm)); }
@@ -2581,8 +2596,11 @@ process_resp_ies: }if (netdev->sm) { -if (netdev_get_oci (netdev) <0 ) - goto deauth; +if (!netdev->handshake->chandef) { +if (netdev_get_oci (netdev) <0 ) + goto deauth; + }else if (!eapol_start (netdev->sm)) + goto deauth;return ; }
@@ -3633,6 +3651,8 @@ static void netdev_connect_common(struct netdev *netdev, netdev->privacy = bss->capability &IE_BSS_CAP_PRIVACY ;handshake_state_set_authenticator_address (hs, bss->addr); +handshake_state_set_chandef (hs,NULL ); +if (!is_rsn) goto build_cmd_connect;
@@ -4099,6 +4119,8 @@ static void prepare_ft(struct netdev *netdev, const struct scan_bss *target_bss) netdev->operational = false; netdev->in_ft = true; +handshake_state_set_chandef (netdev->handshake,NULL ); +/* * Cancel commands that could be running because of EAPoL activity * like re-keying, this way the callbacks for those commands don't
@@ -4273,7 +4295,8 @@ int netdev_fast_transition(struct netdev *netdev, netdev->ap =ft_over_air_sm_new (netdev->handshake, netdev_ft_tx_authenticate, - netdev_ft_tx_associate, netdev); + netdev_ft_tx_associate, + netdev_get_oci, netdev);memcpy (netdev->ap->prev_bssid, orig_bss->addr,ETH_ALEN ); wiphy_radio_work_insert(netdev->wiphy, &netdev->work, 1,
Signature · 1 line
2.31.1
James Prestwood
PATCH v2 6/9 station: set OCVC for handshakes
In reply to James PrestwoodSetting OCVC true for all connections unless disabled
--- src/station.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
src/station.c +8 -1
@@ -995,14 +995,15 @@ static int station_build_handshake_rsn(struct handshake_state *hs,struct network *network, struct scan_bss *bss) { + const struct l_settings *settings = iwd_get_config();enum security security =network_get_security (network);bool add_mde = false;struct erp_cache_entry *erp_cache =NULL ; -struct ie_rsn_info bss_info;uint8_t rsne_buf[256 ];struct ie_rsn_info info;uint8_t *ap_ie; +bool disable_ocv;memset (&info,0 ,sizeof (info));
@@ -1080,6 +1081,12 @@ static int station_build_handshake_rsn(struct handshake_state *hs, goto not_supported; build_ie: +if (!l_settings_get_bool (settings,"General" ,"DisableOCV" , + &disable_ocv)) + disable_ocv = false; + + info.ocvc = !disable_ocv; +/* RSN takes priority */ if (bss->rsne) { ap_ie = bss->rsne;
Signature · 1 line
2.31.1
James Prestwood
PATCH v2 7/9 auto-t: set ocv on PSK FT test
In reply to James Prestwood--- autotests/testPSK-roam/connection_test.py | 4 ++++ 1 file changed, 4 insertions(+)
autotests/testPSK-roam/connection_test.py +4 -0
@@ -100,11 +100,13 @@ class Test(unittest.TestCase): self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-PSK') self.bss_hostapd[0].set_value('ft_over_ds', '0') + self.bss_hostapd[0].set_value('ocv', '1') self.bss_hostapd[0].reload() self.bss_hostapd[0].wait_for_event("AP-ENABLED") self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-PSK') self.bss_hostapd[1].set_value('ft_over_ds', '0') + self.bss_hostapd[0].set_value('ocv', '1') self.bss_hostapd[1].reload() self.bss_hostapd[1].wait_for_event("AP-ENABLED")
@@ -115,11 +117,13 @@ class Test(unittest.TestCase): self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-PSK') self.bss_hostapd[0].set_value('ft_over_ds', '1') + self.bss_hostapd[0].set_value('ocv', '1') self.bss_hostapd[0].reload() self.bss_hostapd[0].wait_for_event("AP-ENABLED") self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-PSK') self.bss_hostapd[1].set_value('ft_over_ds', '1') + self.bss_hostapd[1].set_value('ocv', '1') self.bss_hostapd[1].reload() self.bss_hostapd[1].wait_for_event("AP-ENABLED")
Signature · 1 line
2.31.1
James Prestwood
PATCH v2 8/9 ft: make Authenticate OCVC settable by caller
In reply to James PrestwoodThe FT-over-DS action stage builds an FT-Request which contains an RSNE. Since FT-over-DS will not support OCV add a boolean to ft_build_authenticate_ies so the OCVC bit can be disabled rather than relying on the handshake setting.
--- src/ft.c | 6 ++++-- src/ft.h | 2 +- src/netdev.c | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-)
src/ft.c +4 -2
@@ -805,7 +805,7 @@ static bool ft_over_ds_start(struct auth_proto *ap)return ft_tx_reassociate (ft) ==0 ; } -bool ft_build_authenticate_ies (struct handshake_state *hs, +bool ft_build_authenticate_ies (struct handshake_state *hs,bool ocvc,const uint8_t *new_snonce,uint8_t *buf,size_t *len) {
@@ -834,6 +834,7 @@ bool ft_build_authenticate_ies(struct handshake_state *hs, rsn_info.num_pmkids =1 ; rsn_info.pmkids = hs->pmk_r0_name; + rsn_info.ocvc = ocvc;ie_build_rsne (&rsn_info, ptr); ptr += ptr[1 ] +2 ;
@@ -884,7 +885,8 @@ static bool ft_start(struct auth_proto *ap)uint8_t buf[512 ];size_t len; -if (!ft_build_authenticate_ies (hs, hs->snonce, buf, &len)) +if (!ft_build_authenticate_ies (hs, hs->supplicant_ocvc, hs->snonce, + buf, &len))return false; iov.iov_base = buf;
src/ft.h +1 -1
@@ -44,7 +44,7 @@ struct ft_ds_info {void ft_ds_info_free (struct ft_ds_info *info); -bool ft_build_authenticate_ies (struct handshake_state *hs, +bool ft_build_authenticate_ies (struct handshake_state *hs,bool ocvc,const uint8_t *new_snonce,uint8_t *buf,size_t *len);
src/netdev.c +3 -1
@@ -4402,7 +4402,9 @@ int netdev_fast_transition_over_ds_action(struct netdev *netdev, iovs[0 ].iov_base = ft_req; iovs[0 ].iov_len =sizeof (ft_req); -if (!ft_build_authenticate_ies (hs, info->super.snonce, buf, &len)) + +if (!ft_build_authenticate_ies (hs, false, info->super.snonce, + buf, &len)) goto failed; iovs[1 ].iov_base = buf;
Signature · 1 line
2.31.1
James Prestwood
PATCH v2 9/9 netdev: rebuild RSNE for FT-over-DS
In reply to James PrestwoodFT-over-DS cannot use OCV due to how the kernel works. This means we could connect initially with OCVC set, but a FT-over-DS attempt needs to unset OCVC. To do this we must rebuild the RSNE and explicitly set OCVC to false.
--- src/netdev.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
src/netdev.c +15 -0
@@ -4097,6 +4097,8 @@ static int netdev_ft_tx_associate(struct iovec *ft_iov, size_t n_ft_iov,static void prepare_ft (struct netdev *netdev,const struct scan_bss *target_bss) {struct netdev_handshake_state *nhs; +uint8_t rsne_buf[256 ]; +struct ie_rsn_info info;/* * We reuse the handshake_state object and reset what's needed.
@@ -4119,6 +4121,19 @@ static void prepare_ft(struct netdev *netdev, const struct scan_bss *target_bss) netdev->operational = false; netdev->in_ft = true; +/* Always disable OCVC for FT-over-DS */ +if (netdev->handshake->mde[4 ] &1 ) { +ie_parse_rsne_from_data (netdev->handshake->supplicant_ie, + netdev->handshake->supplicant_ie[1 ] +2 , + &info); + + info.ocvc = false; + +ie_build_rsne (&info, rsne_buf); + +handshake_state_set_supplicant_ie (netdev->handshake, rsne_buf); + } +handshake_state_set_chandef (netdev->handshake,NULL );/*
Signature · 1 line
2.31.1
Denis Kenzior
Re: [PATCH v2 5/9] ft: get OCI prior to reassociation
In reply to James PrestwoodHi James,
Quoted 16 lines · James Prestwood
This modifies the FT logic to fist call
get_oci()before reassociation. This allows the OCI to be included in reassociation and in the 4-way handshake later on.The code path for getting the OCI had to be slightly changed to handle an OCI that is already set. First the handshake chandef is NULL'ed out for any new connection. This prevents a stale OCI from being used. Then some checks were added for this case in
netdev_connect_eventand if chandef is already set, start the 4-way handshake.--- src/ft.c | 13 ++++++++++++- src/ft.h | 2 ++ src/netdev.c | 29 ++++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 4 deletions(-)
<snip>
src/netdev.c static void netdev_connect_common(struct netdev *netdev, · line 3658
Quoted 9 lines
src/netdev.c +2
-0@@ -3633,6 +3651,8 @@ static void netdev_connect_common(struct netdev *netdev, netdev->privacy = bss->capability &IE_BSS_CAP_PRIVACY ;handshake_state_set_authenticator_address (hs, bss->addr); +handshake_state_set_chandef (hs,NULL ); +if (!is_rsn) goto build_cmd_connect;
netdev_connect_common always operates on a brand new handshake, so this should not be needed. I took this out for now.
Patches 1-8 applied, thanks.
Regards,
-Denis
Denis Kenzior
Re: [PATCH v2 9/9] netdev: rebuild RSNE for FT-over-DS
In reply to James PrestwoodQuoted 22 lines · James Prestwood
FT-over-DS cannot use OCV due to how the kernel works. This means we could connect initially with OCVC set, but a FT-over-DS attempt needs to unset OCVC. To do this we must rebuild the RSNE and explicitly set OCVC to false.
--- src/netdev.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)src/netdev.c +2
-0@@ -4097,6 +4097,8 @@ static int netdev_ft_tx_associate(struct iovec *ft_iov, size_t n_ft_iov,static void prepare_ft (struct netdev *netdev,const struct scan_bss *target_bss) {struct netdev_handshake_state *nhs; +uint8_t rsne_buf[256 ]; +struct ie_rsn_info info;/* * We reuse the handshake_state object and reset what's needed.
src/netdev.c static void prepare_ft(struct netdev *netdev, const struct scan_bss *target_bss) · line 4125
Quoted 5 lines
src/netdev.c +2
-0@@ -4119,6 +4121,19 @@ static void prepare_ft(struct netdev *netdev, const struct scan_bss *target_bss) netdev->operational = false; netdev->in_ft = true; +/* Always disable OCVC for FT-over-DS */ +if (netdev->handshake->mde[4 ] &1 ) {
Is this really a good indicator of whether we're using FT-over-DS or not? Station might choose different heuristics / policy at a later time, so making this more explicit would be better.
src/netdev.c static void prepare_ft(struct netdev *netdev, const struct scan_bss *target_bss) · line 4134
Quoted 9 lines
src/netdev.c +9
-0+ie_parse_rsne_from_data (netdev->handshake->supplicant_ie, + netdev->handshake->supplicant_ie[1 ] +2 , + &info); + + info.ocvc = false; + +ie_build_rsne (&info, rsne_buf); + +handshake_state_set_supplicant_ie (netdev->handshake, rsne_buf);
Also, why are you rebuilding the RSN here and not prior to sending the ReAssociate, where it is being rebuilt anyway?
src/netdev.c static void prepare_ft(struct netdev *netdev, const struct scan_bss *target_bss) · line 4139
Quoted 6 lines
src/netdev.c +2
-0+ } +handshake_state_set_chandef (netdev->handshake,NULL );/*
Regards,
-Denis