eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit 701085a0c6283557827aabd6d5cc0fa5c299307c
parent c0d6460e57c278916e5e6ccd2c07fd030602ad25
Author: illiliti <illiliti@protonmail.com>
Date:   Sat, 27 May 2023 20:12:04 +0300

Merge tag '2.5'

Release 2.5

Diffstat:
MAUTHORS | 1+
MChangeLog | 7+++++++
MMakefile.am | 52+++++++++++++++++++++++++++++++++-------------------
Macinclude.m4 | 1-
Mautotests/testPSK-roam/connection_test.py | 13++++++++-----
Mautotests/testPSK-roam/failed_roam_test.py | 33++++++++++++++++++++++-----------
Aautotests/testPSK-roam/ft-psk-ccmp-3.conf | 39+++++++++++++++++++++++++++++++++++++++
Mautotests/testPSK-roam/hw.conf | 3++-
Mautotests/testPSK-roam/roam_ap_disconnect_test.py | 6++++--
Mclient/display.c | 3++-
Mclient/known-networks.c | 3+--
Mconfigure.ac | 24+++++++++++++++++-------
Mlinux/nl80211.h | 39++++++++++++++++++++++++++++++++++++++-
Msrc/band.c | 4++--
Msrc/common.c | 1+
Msrc/dpp.c | 35+++++++++++++++++++++++++++++++----
Msrc/eap-mschapv2.c | 2+-
Msrc/eapol.c | 12++++++++++--
Msrc/ft.c | 5-----
Msrc/handshake.c | 2+-
Msrc/mpdu.h | 18+++++++++---------
Msrc/netdev.c | 2+-
Msrc/rrm.c | 2+-
Msrc/station.c | 159++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
Msrc/wiphy.c | 45+++++++++++++++++++++++++++++++++++++--------
Msrc/wiphy.h | 2++
Mtools/hwsim.c | 22+++++++++++++++-------
27 files changed, 381 insertions(+), 154 deletions(-)

diff --git a/AUTHORS b/AUTHORS @@ -40,3 +40,4 @@ Jesse Lentz <jesse@twosheds.org> Pinghao Wu <xdavidwuph@gmail.com> Neehar Vijay <env252525@gmail.com> Jiajie Chen <c@jia.je> +Ronan Pigott <ronan@rjp.ie> diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,10 @@ +ver 2.5: + Fix issue with HT40+/- checks when creating chandef. + Fix issue with handling support for FT-8021X-SHA384. + Fix issue with handling secure bit check in handshake 1/4. + Fix issue with allowing roaming before netconfig finishes. + Fix issue with double free when disconnecting during FT. + ver 2.4: Fix issue with FT-over-Air and same channel operation. Fix issue with AP mode and missing support for GTK. diff --git a/Makefile.am b/Makefile.am @@ -150,6 +150,14 @@ ell_shared = ell/useful.h ell/asn1-private.h ell_libell_internal_la_SOURCES = $(ell_headers) $(ell_sources) $(ell_shared) endif +if LIBEDIT +client_cflags = $(LIBEDIT_CFLAGS) +client_ldadd = $(LIBEDIT_LIBS) +else +client_cflags = +client_ldadd = $(READLINE_LIBS) +endif + bin_PROGRAMS = libexec_PROGRAMS = noinst_PROGRAMS = @@ -309,7 +317,7 @@ client_iwctl_SOURCES = client/main.c \ src/util.c src/util.h \ src/band.c src/band.h -client_iwctl_LDADD = $(ell_ldadd) $(READLINE_LIBS) +client_iwctl_LDADD = $(ell_ldadd) $(client_ldadd) if MANUAL_PAGES man_MANS += client/iwctl.1 @@ -370,6 +378,7 @@ endif endif if TOOLS +if DAEMON noinst_PROGRAMS += tools/probe-req tools/iwd-decrypt-profile tools_probe_req_SOURCES = tools/probe-req.c src/mpdu.h src/mpdu.c \ @@ -379,13 +388,14 @@ tools_probe_req_SOURCES = tools/probe-req.c src/mpdu.h src/mpdu.c \ src/common.h src/common.c \ src/band.h src/band.c tools_probe_req_LDADD = $(ell_ldadd) -endif tools_iwd_decrypt_profile_SOURCES = tools/iwd-decrypt-profile.c \ src/common.h src/common.c \ src/crypto.h src/crypto.c \ src/storage.h src/storage.c tools_iwd_decrypt_profile_LDADD = ${ell_ldadd} +endif +endif if HWSIM bin_PROGRAMS += tools/hwsim @@ -409,7 +419,10 @@ man_MANS += tools/hwsim.1 endif endif -unit_tests = unit/test-cmac-aes \ +unit_tests = + +if DAEMON +unit_tests += unit/test-cmac-aes \ unit/test-hmac-md5 unit/test-hmac-sha1 unit/test-hmac-sha256 \ unit/test-prf-sha1 unit/test-kdf-sha256 \ unit/test-crypto unit/test-eapol unit/test-mpdu \ @@ -417,6 +430,7 @@ unit_tests = unit/test-cmac-aes \ unit/test-arc4 unit/test-wsc unit/test-eap-mschapv2 \ unit/test-eap-sim unit/test-sae unit/test-p2p unit/test-band \ unit/test-dpp unit/test-json +endif if CLIENT unit_tests += unit/test-client @@ -426,6 +440,7 @@ if MAINTAINER_MODE noinst_PROGRAMS += $(unit_tests) endif +if DAEMON unit_test_eap_sim_SOURCES = unit/test-eap-sim.c \ src/crypto.h src/crypto.c src/simutil.h src/simutil.c \ src/ie.h src/ie.c \ @@ -439,7 +454,6 @@ unit_test_eap_sim_SOURCES = unit/test-eap-sim.c \ src/erp.h src/erp.c \ src/band.h src/band.c \ src/eap-sim.c - unit_test_eap_sim_LDADD = $(ell_ldadd) unit_test_cmac_aes_SOURCES = unit/test-cmac-aes.c \ @@ -448,7 +462,6 @@ unit_test_cmac_aes_LDADD = $(ell_ldadd) unit_test_arc4_SOURCES = unit/test-arc4.c \ src/crypto.h src/crypto.c - unit_test_arc4_LDADD = $(ell_ldadd) unit_test_hmac_md5_SOURCES = unit/test-hmac-md5.c \ @@ -537,19 +550,6 @@ unit_test_eap_mschapv2_SOURCES = src/eap-mschapv2.h src/eap-mschapv2.c \ unit/test-eap-mschapv2.c unit_test_eap_mschapv2_LDADD = $(ell_ldadd) -if CLIENT -unit_test_client_SOURCES = unit/test-client.c \ - client/adapter.c \ - client/agent.h client/agent.c \ - client/agent-manager.h client/agent-manager.c \ - client/command.h client/command.c \ - client/dbus-proxy.h client/dbus-proxy.c \ - client/display.h client/display.c \ - client/network.h client/network.c \ - client/properties.h client/properties.c -unit_test_client_LDADD = $(ell_ldadd) $(READLINE_LIBS) -endif - unit_test_sae_SOURCES = unit/test-sae.c \ src/sae.h src/sae.c \ src/crypto.h src/crypto.c \ @@ -578,6 +578,20 @@ unit_test_dpp_LDADD = $(ell_ldadd) unit_test_json_SOURCES = unit/test-json.c src/json.h src/json.c shared/jsmn.h unit_test_json_LDADD = $(ell_ldadd) +endif + +if CLIENT +unit_test_client_SOURCES = unit/test-client.c \ + client/adapter.c \ + client/agent.h client/agent.c \ + client/agent-manager.h client/agent-manager.c \ + client/command.h client/command.c \ + client/dbus-proxy.h client/dbus-proxy.c \ + client/display.h client/display.c \ + client/network.h client/network.c \ + client/properties.h client/properties.c +unit_test_client_LDADD = $(ell_ldadd) $(client_ldadd) +endif TESTS = $(unit_tests) @@ -589,7 +603,7 @@ EXTRA_DIST = src/genbuiltin src/iwd.service.in src/net.connman.iwd.service \ $(patsubst %.5,%.rst, \ $(patsubst %.8,%.rst,$(manual_pages)))) -AM_CFLAGS = $(ell_cflags) -fvisibility=hidden \ +AM_CFLAGS = $(ell_cflags) $(client_cflags) -fvisibility=hidden \ -DUNITDIR=\""$(top_srcdir)/unit/"\" \ -DCERTDIR=\""$(top_builddir)/unit/"\" diff --git a/acinclude.m4 b/acinclude.m4 @@ -58,7 +58,6 @@ AC_DEFUN([COMPILER_FLAGS], [ CFLAGS+=" -Wdeclaration-after-statement" CFLAGS+=" -Wmissing-declarations" CFLAGS+=" -Wredundant-decls" - CFALGS+=" -Wvariadic-macros" CFLAGS+=" -Wformat -Wformat-security" if ( $CC -v 2>/dev/null | grep "gcc version" ); then CFLAGS+=" -Wcast-align" diff --git a/autotests/testPSK-roam/connection_test.py b/autotests/testPSK-roam/connection_test.py @@ -48,7 +48,7 @@ class Test(unittest.TestCase): self.rule2.enabled = True # Send 100 packets (to be dropped), should trigger beacon loss testutil.tx_packets(device.name, self.bss_hostapd[0].ifname, 100) - device.wait_for_event('packet-loss-roam', timeout=30) + device.wait_for_event('packet-loss-roam', timeout=60) else: device.roam(self.bss_hostapd[1].bssid) @@ -173,19 +173,22 @@ class Test(unittest.TestCase): IWD.copy_to_storage('TestFT.psk') cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), - HostapdCLI(config='ft-psk-ccmp-2.conf') ] + HostapdCLI(config='ft-psk-ccmp-2.conf'), + HostapdCLI(config='ft-psk-ccmp-3.conf') ] + cls.bss_hostapd[2].disable() + rad0 = hwsim.get_radio('rad0') - rad2 = hwsim.get_radio('rad2') + rad3 = hwsim.get_radio('rad3') cls.rule0 = hwsim.rules.create() - cls.rule0.source = rad2.addresses[0] + cls.rule0.source = rad3.addresses[0] cls.rule0.bidirectional = True cls.rule0.signal = -2000 cls.rule0.prefix = 'b0' cls.rule0.drop = True cls.rule1 = hwsim.rules.create() - cls.rule1.source = rad2.addresses[0] + cls.rule1.source = rad3.addresses[0] cls.rule1.prefix = '08' cls.rule1.drop = True diff --git a/autotests/testPSK-roam/failed_roam_test.py b/autotests/testPSK-roam/failed_roam_test.py @@ -62,21 +62,17 @@ class Test(unittest.TestCase): self.rule0.enabled = True - device.roam(self.bss_hostapd[1].bssid) - - # Roam should fail... - device.wait_for_event('ft-roam-failed') + # IWD should connect, then attempt a roam to BSS 1, which should fail... + device.wait_for_event('ft-roam-failed', timeout=60) # ... but IWD should remain connected self.assertTrue(device.state == DeviceState.connected) self.rule0.enabled = False - # Try again once more - device.roam(self.bss_hostapd[1].bssid) - - self.verify_roam(wd, device, self.bss_hostapd[0], self.bss_hostapd[1]) + # IWD should then try BSS 2, and succeed + self.verify_roam(wd, device, self.bss_hostapd[0], self.bss_hostapd[2]) - self.bss_hostapd[1].deauthenticate(device.address) + self.bss_hostapd[2].deauthenticate(device.address) condition = 'obj.state == DeviceState.disconnected' wd.wait_for_object_condition(device, condition) @@ -88,6 +84,7 @@ class Test(unittest.TestCase): self.rule0.enabled = False self.rule1.enabled = False + self.rule2.enabled = False @classmethod def setUpClass(cls): @@ -96,14 +93,16 @@ class Test(unittest.TestCase): IWD.copy_to_storage('TestFT.psk') cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), - HostapdCLI(config='ft-psk-ccmp-2.conf') ] + HostapdCLI(config='ft-psk-ccmp-2.conf'), + HostapdCLI(config='ft-psk-ccmp-3.conf') ] cls.bss_hostapd[0].set_address('12:00:00:00:00:01') cls.bss_hostapd[1].set_address('12:00:00:00:00:02') + cls.bss_hostapd[2].set_address('12:00:00:00:00:03') # Drop Authenticate frames cls.rule0 = hwsim.rules.create() - cls.rule0.bidirectional = True + cls.rule0.source = hwsim.get_radio('rad1').addresses[0] cls.rule0.prefix = 'b0' cls.rule0.drop = True @@ -113,6 +112,18 @@ class Test(unittest.TestCase): cls.rule1.prefix = 'd0' cls.rule1.drop = True + # Causes IWD to immediately roam away from BSS 0 + cls.rule2 = hwsim.rules.create() + cls.rule2.source = hwsim.get_radio('rad0').addresses[0] + cls.rule2.signal = -8000 + cls.rule2.enabled = True + + # Causes IWD to first prefer BSS 1 to roam, then BSS 2. + cls.rule3 = hwsim.rules.create() + cls.rule3.source = hwsim.get_radio('rad2').addresses[0] + cls.rule3.signal = -7000 + cls.rule3.enabled = True + @classmethod def tearDownClass(cls): IWD.clear_storage() diff --git a/autotests/testPSK-roam/ft-psk-ccmp-3.conf b/autotests/testPSK-roam/ft-psk-ccmp-3.conf @@ -0,0 +1,39 @@ +hw_mode=g +channel=2 +ssid=TestFT +utf8_ssid=1 +ctrl_interface=/var/run/hostapd + +r1_key_holder=120000000002 +nas_identifier=dummy2 + +wpa=2 +# Can support WPA-PSK and FT-PSK (space separated list) and/or EAP at the same +# time but we want to force FT +wpa_key_mgmt=FT-PSK +wpa_pairwise=CCMP +wpa_passphrase=EasilyGuessedPassword +ieee80211w=1 +rsn_preauth=1 +rsn_preauth_interfaces=lo +disable_pmksa_caching=0 +# Allow PMK cache to be shared opportunistically among configured interfaces +# and BSSes (i.e., all configurations within a single hostapd process). +okc=1 +mobility_domain=1234 +reassociation_deadline=60000 +r0kh=12:00:00:00:00:01 dummy1 000102030405060708090a0b0c0d0e0f +r0kh=12:00:00:00:00:02 dummy2 000102030405060708090a0b0c0d0e0f +r1kh=12:00:00:00:00:01 00:00:00:00:00:01 000102030405060708090a0b0c0d0e0f +r1kh=12:00:00:00:00:02 00:00:00:00:00:02 000102030405060708090a0b0c0d0e0f +# Push mode only needed for 8021x, not PSK mode since msk already known +pmk_r1_push=0 +# Allow locally generated FT response so we don't have to configure push/pull +# between BSSes running as separate hostapd processes as in the test-runner +# case. Only works with FT-PSK, otherwise brctl needs to be installed and +# CONFIG_BRIDGE enabled in the kernel. +ft_psk_generate_local=1 +ft_over_ds=0 +ap_table_expiration_time=36000 +ap_table_max_size=10 +rrm_neighbor_report=1 diff --git a/autotests/testPSK-roam/hw.conf b/autotests/testPSK-roam/hw.conf @@ -1,8 +1,9 @@ [SETUP] -num_radios=3 +num_radios=4 start_iwd=0 hwsim_medium=yes [HOSTAPD] rad0=ft-psk-ccmp-1.conf rad1=ft-psk-ccmp-2.conf +rad2=ft-psk-ccmp-3.conf diff --git a/autotests/testPSK-roam/roam_ap_disconnect_test.py b/autotests/testPSK-roam/roam_ap_disconnect_test.py @@ -33,7 +33,7 @@ class Test(unittest.TestCase): # Since both BSS's have low signal, the roam should fail and trigger # another roam scan. device.wait_for_event('roam-scan-triggered', timeout=30) - device.wait_for_event('no-roam-candidates', timeout=30) + device.wait_for_event('no-roam-candidates', timeout=60) # Hostapd sends disconnect self.bss_hostapd[0].disable() @@ -70,8 +70,10 @@ class Test(unittest.TestCase): IWD.copy_to_storage('TestFT.psk') cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), - HostapdCLI(config='ft-psk-ccmp-2.conf') ] + HostapdCLI(config='ft-psk-ccmp-2.conf'), + HostapdCLI(config='ft-psk-ccmp-3.conf') ] cls.bss_hostapd[1].disable() + cls.bss_hostapd[2].disable() cls.bss_hostapd[0].set_value('ocv', '0') cls.bss_hostapd[0].set_value('ieee80211w', '0') diff --git a/client/display.c b/client/display.c @@ -890,7 +890,8 @@ void display_agent_prompt_release(const char *label) void display_quit(void) { - rl_crlf(); + if (command_is_interactive_mode()) + rl_crlf(); } static void window_change_signal_handler(void *user_data) diff --git a/client/known-networks.c b/client/known-networks.c @@ -24,8 +24,7 @@ #include <config.h> #endif -#define _XOPEN_SOURCE 700 - +#define _XOPEN_SOURCE #include <time.h> #include <ell/ell.h> diff --git a/configure.ac b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.69]) -AC_INIT([iwd],[2.4]) +AC_INIT([iwd],[2.5]) AC_CONFIG_HEADERS(config.h) AC_CONFIG_AUX_DIR(build-aux) @@ -158,11 +158,17 @@ AC_ARG_ENABLE([client], AS_HELP_STRING([--disable-client], [don't install iwctl client utility]), [enable_client=${enableval}]) if (test "${disable_dbus}" != "no" && test "${enable_client}" != "no"); then - AC_CHECK_HEADERS(readline/readline.h, enable_readline=yes, - AC_MSG_ERROR(readline header files are required)) - PKG_CHECK_MODULES(READLINE, readline, dummy=yes, READLINE_LIBS=-lreadline) - AC_SUBST(READLINE_CFLAGS) - AC_SUBST(READLINE_LIBS) + if (test "${enable_libedit}" = "yes"); then + PKG_CHECK_MODULES(LIBEDIT, libedit >= 3.1, dummy=yes, + AC_MSG_ERROR(Editline library is required)) + AC_SUBST(LIBEDIT_CFLAGS) + AC_SUBST(LIBEDIT_LIBS) + else + PKG_CHECK_MODULES(READLINE, readline, dummy=yes, + AC_MSG_ERROR(Readline library is required)) + AC_SUBST(READLINE_CFLAGS) + AC_SUBST(READLINE_LIBS) + fi fi AM_CONDITIONAL(CLIENT, test "${enable_client}" != "no" && test "${disable_dbus}" != "no") @@ -268,7 +274,7 @@ if (test "${enable_external_ell}" = "yes"); then test "${enable_monitor}" != "no" || test "${enable_wired}" = "yes" || test "${enable_hwsim}" = "yes"); then - ell_min_version="0.56" + ell_min_version="0.57" else ell_min_version="0.5" fi @@ -279,6 +285,10 @@ if (test "${enable_external_ell}" = "yes"); then fi AM_CONDITIONAL(EXTERNAL_ELL, test "${enable_external_ell}" = "yes") +AC_ARG_ENABLE([libedit], AS_HELP_STRING([--enable-libedit], + [enable Editline library instead of Readline]), + [enable_libedit=${enableval}]) +AM_CONDITIONAL(LIBEDIT, test "${enable_libedit}" = "yes") AC_ARG_ENABLE([wired], AS_HELP_STRING([--enable-wired], [enable Ethernet authentication support]), diff --git a/linux/nl80211.h b/linux/nl80211.h @@ -424,7 +424,8 @@ * interface identified by %NL80211_ATTR_IFINDEX. * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC * or, if no MAC address given, all stations, on the interface identified - * by %NL80211_ATTR_IFINDEX. %NL80211_ATTR_MGMT_SUBTYPE and + * by %NL80211_ATTR_IFINDEX. For MLD station, MLD address is used in + * %NL80211_ATTR_MAC. %NL80211_ATTR_MGMT_SUBTYPE and * %NL80211_ATTR_REASON_CODE can optionally be used to specify which type * of disconnection indication should be sent to the station * (Deauthentication or Disassociation frame and reason code for that @@ -1166,6 +1167,23 @@ * %NL80211_ATTR_STATUS_CODE attribute in %NL80211_CMD_EXTERNAL_AUTH * command interface. * + * Host driver sends MLD address of the AP with %NL80211_ATTR_MLD_ADDR in + * %NL80211_CMD_EXTERNAL_AUTH event to indicate user space to enable MLO + * during the authentication offload in STA mode while connecting to MLD + * APs. Host driver should check %NL80211_ATTR_MLO_SUPPORT flag capability + * in %NL80211_CMD_CONNECT to know whether the user space supports enabling + * MLO during the authentication offload or not. + * User space should enable MLO during the authentication only when it + * receives the AP MLD address in authentication offload request. User + * space shouldn't enable MLO when the authentication offload request + * doesn't indicate the AP MLD address even if the AP is MLO capable. + * User space should use %NL80211_ATTR_MLD_ADDR as peer's MLD address and + * interface address identified by %NL80211_ATTR_IFINDEX as self MLD + * address. User space and host driver to use MLD addresses in RA, TA and + * BSSID fields of the frames between them, and host driver translates the + * MLD addresses to/from link addresses based on the link chosen for the + * authentication. + * * Host driver reports this status on an authentication failure to the * user space through the connect result as the user space would have * initiated the connection through the connect request. @@ -2749,6 +2767,14 @@ enum nl80211_commands { * When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the ack RX * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates * the incoming frame RX timestamp. + * @NL80211_ATTR_TD_BITMAP: Transition Disable bitmap, for subsequent + * (re)associations. + * + * @NL80211_ATTR_PUNCT_BITMAP: (u32) Preamble puncturing bitmap, lowest + * bit corresponds to the lowest 20 MHz channel. Each bit set to 1 + * indicates that the sub-channel is punctured. Higher 16 bits are + * reserved. + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -3276,6 +3302,9 @@ enum nl80211_attrs { NL80211_ATTR_TX_HW_TIMESTAMP, NL80211_ATTR_RX_HW_TIMESTAMP, + NL80211_ATTR_TD_BITMAP, + + NL80211_ATTR_PUNCT_BITMAP, /* add attributes here, update the policy in nl80211.c */ @@ -5866,6 +5895,7 @@ enum plink_actions { #define NL80211_KEK_LEN 16 #define NL80211_KCK_EXT_LEN 24 #define NL80211_KEK_EXT_LEN 32 +#define NL80211_KCK_EXT_LEN_32 32 #define NL80211_REPLAY_CTR_LEN 8 /** @@ -6291,6 +6321,11 @@ enum nl80211_feature_flags { * might apply, e.g. no scans in progress, no offchannel operations * in progress, and no active connections. * + * @NL80211_EXT_FEATURE_PUNCT: Driver supports preamble puncturing in AP mode. + * + * @NL80211_EXT_FEATURE_SECURE_NAN: Device supports NAN Pairing which enables + * authentication, data encryption and message integrity. + * * @NUM_NL80211_EXT_FEATURES: number of extended features. * @MAX_NL80211_EXT_FEATURES: highest extended feature index. */ @@ -6359,6 +6394,8 @@ enum nl80211_ext_feature_index { NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD, NL80211_EXT_FEATURE_RADAR_BACKGROUND, NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE, + NL80211_EXT_FEATURE_PUNCT, + NL80211_EXT_FEATURE_SECURE_NAN, /* add new features before the definition below */ NUM_NL80211_EXT_FEATURES, diff --git a/src/band.c b/src/band.c @@ -1229,11 +1229,11 @@ int band_freq_to_ht_chandef(uint32_t freq, const struct band_freq_attrs *attr, if (band == BAND_FREQ_6_GHZ) break; - if (info->flags & PRIMARY_CHANNEL_UPPER && + if (info->flags & PRIMARY_CHANNEL_LOWER && attr->no_ht40_plus) continue; - if (info->flags & PRIMARY_CHANNEL_LOWER && + if (info->flags & PRIMARY_CHANNEL_UPPER && attr->no_ht40_minus) continue; diff --git a/src/common.c b/src/common.c @@ -78,6 +78,7 @@ bool security_from_str(const char *str, enum security *security) akm & (IE_RSN_AKM_SUITE_8021X | \ IE_RSN_AKM_SUITE_8021X_SHA256 | \ IE_RSN_AKM_SUITE_FT_OVER_8021X | \ + IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384 | \ IE_RSN_AKM_SUITE_FILS_SHA256 | \ IE_RSN_AKM_SUITE_FILS_SHA384 | \ IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256 | \ diff --git a/src/dpp.c b/src/dpp.c @@ -147,6 +147,7 @@ struct dpp_sm { bool mcast_support : 1; bool roc_started : 1; + bool channel_switch : 1; }; static bool dpp_get_started(struct l_dbus *dbus, @@ -2032,6 +2033,7 @@ static void authenticate_response(struct dpp_sm *dpp, const uint8_t *from, return; } + dpp->channel_switch = false; dpp->current_freq = dpp->new_freq; dpp_send_authenticate_confirm(dpp); @@ -2112,10 +2114,14 @@ static void dpp_handle_presence_announcement(struct dpp_sm *dpp, return; /* - * Should we wait for an ACK then go offchannel? + * Requested the peer to move to another channel for the remainder of + * the protocol. IWD's current logic prohibits a configurator from + * running while not connected, so we can assume here that the new + * frequency is the same of the connected BSS. Wait until an ACK is + * received for the auth request then cancel the offchannel request. */ if (dpp->current_freq != dpp->new_freq) - dpp_start_offchannel(dpp, dpp->new_freq); + dpp->channel_switch = true; } static void dpp_handle_frame(struct dpp_sm *dpp, @@ -2211,13 +2217,34 @@ static void dpp_mlme_notify(struct l_genl_msg *msg, void *user_data) if (dpp->state <= DPP_STATE_PRESENCE) return; + + if (dpp->frame_cookie != cookie) + return; + /* * Only want to handle the no-ACK case. Re-transmitting an ACKed * frame likely wont do any good, at least in the case of DPP. */ - if (dpp->frame_cookie != cookie || ack) - return; + if (!ack) + goto retransmit; + + /* + * Special handling for a channel transition when acting as a + * configurator. The auth request was sent offchannel so we need to + * wait for the ACK before going back to the connected channel. + */ + if (dpp->channel_switch) { + if (dpp->offchannel_id) { + offchannel_cancel(dpp->wdev_id, dpp->offchannel_id); + dpp->offchannel_id = 0; + } + + dpp->channel_switch = false; + } + + return; +retransmit: if (dpp->frame_retry > DPP_FRAME_MAX_RETRIES) { dpp_reset(dpp); return; diff --git a/src/eap-mschapv2.c b/src/eap-mschapv2.c @@ -73,7 +73,7 @@ struct mschapv2_response { /* This will always be sizeof(value) */ uint8_t val_length; struct mschapv2_value value; - char name[0]; + char name[]; } __attribute__((packed)); /** diff --git a/src/eapol.c b/src/eapol.c @@ -110,6 +110,9 @@ bool eapol_calculate_mic(enum ie_rsn_akm_suite akm, const uint8_t *kck, case IE_RSN_AKM_SUITE_OSEN: return cmac_aes(kck, 16, frame, frame_len, mic, mic_len); + case IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384: + return hmac_sha384(kck, 24, frame, frame_len, + mic, mic_len); case IE_RSN_AKM_SUITE_OWE: switch (mic_len) { case 16: @@ -164,6 +167,10 @@ bool eapol_verify_mic(enum ie_rsn_akm_suite akm, const uint8_t *kck, case IE_RSN_AKM_SUITE_OSEN: checksum = l_checksum_new_cmac_aes(kck, 16); break; + case IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384: + checksum = l_checksum_new_hmac(L_CHECKSUM_SHA384, + kck, 24); + break; case IE_RSN_AKM_SUITE_OWE: switch (mic_len) { case 16: @@ -270,6 +277,7 @@ uint8_t *eapol_decrypt_key_data(enum ie_rsn_akm_suite akm, const uint8_t *kek, case IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256: case IE_RSN_AKM_SUITE_OWE: case IE_RSN_AKM_SUITE_OSEN: + case IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384: if (key_data_len < 24 || key_data_len % 8) return NULL; @@ -315,6 +323,7 @@ uint8_t *eapol_decrypt_key_data(enum ie_rsn_akm_suite akm, const uint8_t *kek, case EAPOL_KEY_DESCRIPTOR_VERSION_AKM_DEFINED: switch (akm) { case IE_RSN_AKM_SUITE_OWE: + case IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384: switch (mic_len) { case 16: kek_len = 16; @@ -478,8 +487,7 @@ bool eapol_verify_ptk_1_of_4(const struct eapol_key *ek, size_t mic_len, if (ek->key_mic) return false; - if (ek->secure != ptk_complete) - return false; + L_WARN_ON(ek->secure != ptk_complete); if (ek->encrypted_key_data) return false; diff --git a/src/ft.c b/src/ft.c @@ -1060,11 +1060,6 @@ static void ft_authenticate_destroy(int error, void *user_data) struct ft_info *info = user_data; info->offchannel_id = 0; - - if (!info->parsed) { - l_queue_remove(info_list, info); - ft_info_destroy(info); - } } /* diff --git a/src/handshake.c b/src/handshake.c @@ -1004,7 +1004,7 @@ bool handshake_decode_fte_key(struct handshake_state *s, const uint8_t *wrapped, size_t key_len, uint8_t *key_out) { const uint8_t *kek; - size_t kek_len = 16; + size_t kek_len = handshake_state_get_kek_len(s); size_t padded_len = key_len < 16 ? 16 : align_len(key_len, 8); if (s->akm_suite & (IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256 | diff --git a/src/mpdu.h b/src/mpdu.h @@ -334,7 +334,7 @@ struct mmpdu_field_capability { struct mmpdu_association_request { struct mmpdu_field_capability capability; __le16 listen_interval; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.6 */ @@ -342,7 +342,7 @@ struct mmpdu_association_response { struct mmpdu_field_capability capability; __le16 status_code; __le16 aid; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.7 */ @@ -350,7 +350,7 @@ struct mmpdu_reassociation_request { struct mmpdu_field_capability capability; __le16 listen_interval; unsigned char current_ap_address[6]; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.8 */ @@ -358,13 +358,13 @@ struct mmpdu_reassociation_response { struct mmpdu_field_capability capability; __le16 status_code; __le16 aid; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.4 */ struct mmpdu_disassociation { __le16 reason_code; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.9 */ @@ -377,14 +377,14 @@ struct mmpdu_probe_response { __le64 timestamp; __le16 beacon_interval; struct mmpdu_field_capability capability; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.15 */ struct mmpdu_timing_advertisement { __le64 timestamp; struct mmpdu_field_capability capability; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.2 */ @@ -392,7 +392,7 @@ struct mmpdu_beacon { __le64 timestamp; __le16 beacon_interval; struct mmpdu_field_capability capability; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); /* 802.11, Section 8.3.3.11 */ @@ -406,7 +406,7 @@ struct mmpdu_authentication { /* 802.11, Section 8.3.3.12 */ struct mmpdu_deauthentication { __le16 reason_code; - uint8_t ies[0]; + uint8_t ies[]; } __attribute__ ((packed)); const struct mmpdu_header *mpdu_validate(const uint8_t *frame, int len); diff --git a/src/netdev.c b/src/netdev.c @@ -99,7 +99,7 @@ struct netdev_handshake_state { struct netdev_ext_key_info { uint16_t proto; bool noencrypt; - struct eapol_frame frame[0]; + struct eapol_frame frame[]; }; struct netdev { diff --git a/src/rrm.c b/src/rrm.c @@ -138,7 +138,7 @@ struct rrm_beacon_report { uint8_t bssid[6]; uint8_t antenna_id; __le32 parent_tsf; - uint8_t subelements[0]; + uint8_t subelements[]; } __attribute__ ((packed)); static struct l_queue *states; diff --git a/src/station.c b/src/station.c @@ -129,6 +129,7 @@ struct station { bool scanning : 1; bool autoconnect : 1; bool autoconnect_can_start : 1; + bool netconfig_after_roam : 1; }; struct anqp_entry { @@ -1693,6 +1694,7 @@ static void station_roam_state_clear(struct station *station) station->roam_scan_full = false; station->signal_low = false; station->roam_min_time.tv_sec = 0; + station->netconfig_after_roam = false; if (station->roam_scan_id) scan_cancel(netdev_get_wdev_id(station->netdev), @@ -1985,6 +1987,65 @@ static bool station_can_fast_transition(struct handshake_state *hs, return true; } +static void station_disconnect_on_error_cb(struct netdev *netdev, bool success, + void *user_data) +{ + struct station *station = user_data; + bool continue_autoconnect; + + station_enter_state(station, STATION_STATE_DISCONNECTED); + + continue_autoconnect = station->state == STATION_STATE_CONNECTING_AUTO; + + if (continue_autoconnect) { + if (station_autoconnect_next(station) < 0) { + l_debug("Nothing left on autoconnect list"); + station_enter_state(station, + STATION_STATE_AUTOCONNECT_FULL); + } + + return; + } + + if (station->autoconnect) + station_enter_state(station, STATION_STATE_AUTOCONNECT_QUICK); +} + +static void station_netconfig_event_handler(enum netconfig_event event, + void *user_data) +{ + struct station *station = user_data; + + switch (event) { + case NETCONFIG_EVENT_CONNECTED: + station_enter_state(station, STATION_STATE_CONNECTED); + break; + case NETCONFIG_EVENT_FAILED: + if (station->connect_pending) { + struct l_dbus_message *reply = dbus_error_failed( + station->connect_pending); + + dbus_pending_reply(&station->connect_pending, reply); + } + + if (L_IN_SET(station->state, STATION_STATE_CONNECTING, + STATION_STATE_CONNECTING_AUTO)) + network_connect_failed(station->connected_network, + false); + + netdev_disconnect(station->netdev, + station_disconnect_on_error_cb, + station); + station_reset_connection_state(station); + + station_enter_state(station, STATION_STATE_DISCONNECTING); + break; + default: + l_error("station: Unsupported netconfig event: %d.", event); + break; + } +} + static void station_roamed(struct station *station) { station->roam_scan_full = false; @@ -2013,7 +2074,14 @@ static void station_roamed(struct station *station) l_queue_clear(station->roam_bss_list, l_free); - station_enter_state(station, STATION_STATE_CONNECTED); + /* Re-enable netconfig if it never finished on the last BSS */ + if (station->netconfig_after_roam) { + station->netconfig_after_roam = false; + L_WARN_ON(!netconfig_configure(station->netconfig, + station_netconfig_event_handler, + station)); + } else + station_enter_state(station, STATION_STATE_CONNECTED); } static void station_roam_retry(struct station *station) @@ -2046,6 +2114,14 @@ static void station_roam_failed(struct station *station) return; } + /* Re-enable netconfig if needed, even on a failed roam */ + if (station->netconfig_after_roam) { + station->netconfig_after_roam = false; + L_WARN_ON(!netconfig_configure(station->netconfig, + station_netconfig_event_handler, + station)); + } + /* * We were told by the AP to roam, but failed. Try ourselves or * wait for the AP to tell us to roam again @@ -2074,65 +2150,6 @@ delayed_retry: station_roam_retry(station); } -static void station_disconnect_on_error_cb(struct netdev *netdev, bool success, - void *user_data) -{ - struct station *station = user_data; - bool continue_autoconnect; - - station_enter_state(station, STATION_STATE_DISCONNECTED); - - continue_autoconnect = station->state == STATION_STATE_CONNECTING_AUTO; - - if (continue_autoconnect) { - if (station_autoconnect_next(station) < 0) { - l_debug("Nothing left on autoconnect list"); - station_enter_state(station, - STATION_STATE_AUTOCONNECT_FULL); - } - - return; - } - - if (station->autoconnect) - station_enter_state(station, STATION_STATE_AUTOCONNECT_QUICK); -} - -static void station_netconfig_event_handler(enum netconfig_event event, - void *user_data) -{ - struct station *station = user_data; - - switch (event) { - case NETCONFIG_EVENT_CONNECTED: - station_enter_state(station, STATION_STATE_CONNECTED); - break; - case NETCONFIG_EVENT_FAILED: - if (station->connect_pending) { - struct l_dbus_message *reply = dbus_error_failed( - station->connect_pending); - - dbus_pending_reply(&station->connect_pending, reply); - } - - if (L_IN_SET(station->state, STATION_STATE_CONNECTING, - STATION_STATE_CONNECTING_AUTO)) - network_connect_failed(station->connected_network, - false); - - netdev_disconnect(station->netdev, - station_disconnect_on_error_cb, - station); - station_reset_connection_state(station); - - station_enter_state(station, STATION_STATE_DISCONNECTING); - break; - default: - l_error("station: Unsupported netconfig event: %d.", event); - break; - } -} - static void station_reassociate_cb(struct netdev *netdev, enum netdev_result result, void *event_data, @@ -2327,8 +2344,12 @@ static bool station_fast_transition(struct station *station, ft_authenticate(netdev_get_ifindex(station->netdev), bss); done: - wiphy_radio_work_insert(station->wiphy, &station->ft_work, - WIPHY_WORK_PRIORITY_CONNECT, &ft_work_ops); + if (station->ft_work.id) + wiphy_radio_work_reschedule(station->wiphy, &station->ft_work); + else + wiphy_radio_work_insert(station->wiphy, &station->ft_work, + WIPHY_WORK_PRIORITY_CONNECT, + &ft_work_ops); return true; } @@ -2418,8 +2439,20 @@ static void station_transition_start(struct station *station) l_free(rbss); } - if (!roaming) + if (!roaming) { station_roam_failed(station); + return; + } + + /* + * Netconfig could potentially be running and not completed yet. We + * still should roam in this case but need to restart netconfig once the + * roam is finished. + */ + if (station->netconfig && station->state != STATION_STATE_CONNECTED) { + netconfig_reset(station->netconfig); + station->netconfig_after_roam = true; + } } static void station_roam_scan_triggered(int err, void *user_data) diff --git a/src/wiphy.c b/src/wiphy.c @@ -2586,16 +2586,13 @@ static void wiphy_radio_work_next(struct wiphy *wiphy) { struct wiphy_radio_work_item *work; bool done; + uint32_t id; - work = l_queue_peek_head(wiphy->work); + work = l_queue_pop_head(wiphy->work); if (!work) return; - /* - * Ensures no other work item will get inserted before this one while - * the work is being done. - */ - work->priority = INT_MIN; + id = work->id; l_debug("Starting work item %u", work->id); @@ -2604,15 +2601,25 @@ static void wiphy_radio_work_next(struct wiphy *wiphy) wiphy->work_in_callback = false; if (done) { - work->id = 0; + /* Item was rescheduled, don't destroy */ + if (work->id != id) + goto next; - l_queue_remove(wiphy->work, work); + work->id = 0; wiphy->work_in_callback = true; destroy_work(work); wiphy->work_in_callback = false; +next: wiphy_radio_work_next(wiphy); + } else { + /* + * Ensures no other work item will get inserted before this one + * while the work is being done. + */ + work->priority = INT_MIN; + l_queue_push_head(wiphy->work, work); } } @@ -2696,6 +2703,28 @@ int wiphy_radio_work_is_running(struct wiphy *wiphy, uint32_t id) return item == l_queue_peek_head(wiphy->work) ? 1 : 0; } +uint32_t wiphy_radio_work_reschedule(struct wiphy *wiphy, + struct wiphy_radio_work_item *item) +{ + /* + * This should only be called from within the do_work callback, meaning + * the item should not be in the queue. Any re-insertion on a running + * item after do_work is not allowed. + */ + if (L_WARN_ON(wiphy_radio_work_is_running(wiphy, item->id) != -ENOENT)) + return 0; + + work_ids++; + + l_debug("Rescheduling work item %u, new id %u", item->id, work_ids); + + item->id = work_ids; + + l_queue_insert(wiphy->work, item, insert_by_priority, NULL); + + return item->id; +} + static int wiphy_init(void) { struct l_genl *genl = iwd_get_genl(); diff --git a/src/wiphy.h b/src/wiphy.h @@ -168,3 +168,5 @@ uint32_t wiphy_radio_work_insert(struct wiphy *wiphy, const struct wiphy_radio_work_item_ops *ops); void wiphy_radio_work_done(struct wiphy *wiphy, uint32_t id); int wiphy_radio_work_is_running(struct wiphy *wiphy, uint32_t id); +uint32_t wiphy_radio_work_reschedule(struct wiphy *wiphy, + struct wiphy_radio_work_item *item); diff --git a/tools/hwsim.c b/tools/hwsim.c @@ -2092,6 +2092,19 @@ static void setup_rule_manager_interface(struct l_dbus_interface *interface) rule_add, "o", "", "path"); } +static void destroy_rule(void *user_data) +{ + struct hwsim_rule *rule = user_data; + + if (rule->prefix) + l_free(rule->prefix); + + if (rule->match) + l_free(rule->match); + + l_free(rule); +} + static struct l_dbus_message *rule_remove(struct l_dbus *dbus, struct l_dbus_message *message, void *user_data) @@ -2102,13 +2115,8 @@ static struct l_dbus_message *rule_remove(struct l_dbus *dbus, path = rule_get_path(rule); l_queue_remove(rules, rule); - if (rule->prefix) - l_free(rule->prefix); + destroy_rule(rule); - if (rule->match) - l_free(rule->match); - - l_free(rule); l_dbus_unregister_object(dbus, path); return l_dbus_message_new_method_return(message); @@ -3131,7 +3139,7 @@ int main(int argc, char *argv[]) l_dbus_destroy(dbus); hwsim_radio_cache_cleanup(); - l_queue_destroy(rules, l_free); + l_queue_destroy(rules, destroy_rule); l_netlink_destroy(rtnl);