Commit Graph

7234 Commits

Author SHA1 Message Date
James Prestwood d2cda84383 station: add handshake-started debug event 2024-07-18 16:08:32 -05:00
James Prestwood af1b017003 eapol: move HANDSHAKE_STARTED_EVENT to eapol_start()
This event is not used anywhere and can be leveraged in autotesting.
Move the event to eapol_start() so it gets called unconditionally
when the 4-way handshake is started.
2024-07-18 16:08:17 -05:00
James Prestwood 556f90ec28 netdev: handle disconnect event during a connection
If a disconnect arrives at any point during the 4-way handshake or
key setting this would result in netdev sending a disconnect event
to station. If this is a reassociation this case is unhandled in
station and causes a hang as it expects any connection failure to
be handled via the reassociation callback, not a random disconnect
event.

To handle this case we can utilize netdev_disconnected() along with
the new NETDEV_RESULT_DISCONNECTED result to ensure the connect
callback gets called if it exists (indicating a pending connection)

Below are logs showing the "Unexpected disconnect event" which
prevents IWD from cleaning up its state and ultimately results in a
hang:

Jul 16 18:16:13: src/station.c:station_transition_reassociate()
Jul 16 18:16:13: event: state, old: connected, new: roaming
Jul 16 18:16:13: src/wiphy.c:wiphy_radio_work_done() Work item 65 done
Jul 16 18:16:13: src/wiphy.c:wiphy_radio_work_next() Starting work item 66
Jul 16 18:16:13: src/netdev.c:netdev_mlme_notify() MLME notification Del Station(20)
Jul 16 18:16:13: src/netdev.c:netdev_link_notify() event 16 on ifindex 6
Jul 16 18:16:13: src/netdev.c:netdev_mlme_notify() MLME notification Deauthenticate(39)
Jul 16 18:16:13: src/netdev.c:netdev_deauthenticate_event()
Jul 16 18:16:13: src/netdev.c:netdev_mlme_notify() MLME notification New Station(19)
Jul 16 18:16:13: src/station.c:station_netdev_event() Associating
Jul 16 18:16:13: src/netdev.c:netdev_mlme_notify() MLME notification Authenticate(37)
Jul 16 18:16:13: src/netdev.c:netdev_authenticate_event()
Jul 16 18:16:13: src/netdev.c:netdev_mlme_notify() MLME notification Associate(38)
Jul 16 18:16:13: src/netdev.c:netdev_associate_event()
Jul 16 18:16:13: src/netdev.c:netdev_link_notify() event 16 on ifindex 6
Jul 16 18:16:13: src/netdev.c:netdev_mlme_notify() MLME notification Connect(46)
Jul 16 18:16:13: src/netdev.c:netdev_connect_event()
Jul 16 18:16:13: src/netdev.c:netdev_connect_event() aborting and ignore_connect_event not set, proceed
Jul 16 18:16:13: src/netdev.c:netdev_connect_event() expect_connect_failure not set, proceed
Jul 16 18:16:13: src/netdev.c:parse_request_ies()
Jul 16 18:16:13: src/netdev.c:netdev_connect_event() Request / Response IEs parsed
Jul 16 18:16:13: src/netdev.c:netdev_get_oci()
Jul 16 18:16:13: src/netdev.c:netdev_link_notify() event 16 on ifindex 6
Jul 16 18:16:13: src/netdev.c:netdev_link_notify() event 16 on ifindex 6
Jul 16 18:16:13: src/netdev.c:netdev_link_notify() event 16 on ifindex 6
Jul 16 18:16:13: src/netdev.c:netdev_get_oci_cb() Obtained OCI: freq: 5220, width: 3, center1: 5210, center2: 0
Jul 16 18:16:13: src/eapol.c:eapol_start()
Jul 16 18:16:13: src/netdev.c:netdev_unicast_notify() Unicast notification Control Port Frame(129)
Jul 16 18:16:13: src/netdev.c:netdev_control_port_frame_event()
Jul 16 18:16:13: src/eapol.c:eapol_handle_ptk_1_of_4() ifindex=6
Jul 16 18:16:13: src/netdev.c:netdev_mlme_notify() MLME notification Control Port TX Status(139)
Jul 16 18:16:14: src/netdev.c:netdev_mlme_notify() MLME notification Notify CQM(64)
Jul 16 18:16:14: src/netdev.c:netdev_cqm_event() Signal change event (above=1 signal=-60)
Jul 16 18:16:17: src/netdev.c:netdev_link_notify() event 16 on ifindex 6
Jul 16 18:16:17: src/netdev.c:netdev_mlme_notify() MLME notification Del Station(20)
Jul 16 18:16:17: src/netdev.c:netdev_mlme_notify() MLME notification Deauthenticate(39)
Jul 16 18:16:17: src/netdev.c:netdev_deauthenticate_event()
Jul 16 18:16:17: src/netdev.c:netdev_mlme_notify() MLME notification Disconnect(48)
Jul 16 18:16:17: src/netdev.c:netdev_disconnect_event()
Jul 16 18:16:17: Received Deauthentication event, reason: 15, from_ap: true
Jul 16 18:16:17: src/wiphy.c:wiphy_radio_work_done() Work item 66 done
Jul 16 18:16:17: src/station.c:station_disconnect_event() 6
Jul 16 18:16:17: Unexpected disconnect event
Jul 16 18:16:17: src/netdev.c:netdev_link_notify() event 16 on ifindex 6
Jul 16 18:16:17: src/wiphy.c:wiphy_reg_notify() Notification of command Reg Change(36)
Jul 16 18:16:17: src/wiphy.c:wiphy_update_reg_domain() New reg domain country code for (global) is XX
2024-07-18 16:07:41 -05:00
James Prestwood 22f238706c station: update logic for handshake failure
After adding the NETDEV_RESULT_DISCONNECTED enum, handshake failures
initiated by the AP come in via this result so the existing logic
to call network_connect_failed() was broken. We could still get a
handshake failure generated internally, so that has been preserved
(via NETDEV_RESULT_HANDSHAKE_FAILED) but a check for a 4-way
handshake timeout reason code was also added.
2024-07-18 16:06:41 -05:00
James Prestwood 906afefbf3 station: handle NETDEV_RESULT_DISCONNECTED
This new event is sent during a connection if netdev recieves a
disconnect event. This patch cleans up station to handle this
case and leave the existing NETDEV_EVENT_DISCONNECTED_BY_{AP,SME}
handling only for CONNECTED, NETCONFIG, and FW_ROAMING states.
2024-07-18 16:05:37 -05:00
James Prestwood 38c36ff145 netdev: add NETDEV_RESULT_DISCONNECTED
This new result is meant to handle cases where a disconnect
event (deauth/disassoc) was received during an ongoing connection.
Whether that's during authentication, association, the 4-way
handshake, or key setting.
2024-07-18 16:05:14 -05:00
James Prestwood 9ea0117dc4 station: print unknown channel number in neighbor report
If the channel number resulted in a failure to parse the neighbor
report entry, print it for debugging.
2024-07-18 16:05:01 -05:00
Kasper Kantz 4f81953338 p2putil: remove static from const strlen
src/p2putil.c: In function 'p2p_get_random_string':
 src/p2putil.c:2641:37: error: initializer element is not constant     2641 |
        static const int set_size = strlen(CHARSET);         |
                     ^~~~~~
2024-07-12 16:24:00 -05:00
Steve Schrock ffc6d6325d main: update usage with logger option 2024-07-12 11:58:51 -05:00
Steve Schrock 6d46698494 main: set the identity in the logger
This causes "iwd" to be output in each message sent to syslog to help
quickly identify iwd messages.
2024-07-11 17:13:43 -05:00
Marcel Holtmann b54dcafa80 Release 2.19 2024-07-08 22:12:42 +02:00
Marcel Holtmann ac0f13798b build: Add test-nl80211util binary to ignore list 2024-07-08 22:12:20 +02:00
Marcel Holtmann 51771694cd build: Require at least version 0.67 when building with external ELL 2024-07-08 22:11:24 +02:00
James Prestwood 9232991e25 auto-t: add test for a deauth coming in during an FT-roam 2024-06-26 09:38:06 -05:00
James Prestwood 71dc347582 station: add debug event prior to sending an FT-auth frame 2024-06-26 09:38:06 -05:00
James Prestwood 31b18a8c8b auto-t: add test for deauth after authentication
This code path is not exercised in the autotest but commonly does
happen in the real world. There is no associated bug with this, but
its helpful to have this event triggered in case something got
introduced in the future.
2024-06-26 09:38:06 -05:00
James Prestwood d92e4c5663 station: add auth/assoc debug events
These will be useful to trigger behavior around authentication and
association.
2024-06-26 09:38:06 -05:00
James Prestwood 300f0ddac5 netdev: reuse NETDEV_EVENT_{AUTHENTICATING,ASSOCIATING}
The authenticating event was not used anymore and the associating
event use was questionable (after the CMD_CONNECT callback).

No other modules actually utilize these events but they are useful
for autotests. Move these events around to map 1:1 when the kernel
sends the auth/assoc events.
2024-06-26 09:38:06 -05:00
James Prestwood 77cf621f15 nl80211util: use nl80211_parse_attrs/nested for get_key_seq
This really reduces the number of checks needed and overall function
length by using the helper APIs.
2024-06-26 09:38:06 -05:00
James Prestwood 5c824cc24e netdev: use nl80211_parse_attrs for deauth event
Especially for parsing a single attribute, nl80211_parse_attrs
makes the most sense to use here.
2024-06-26 09:38:06 -05:00
James Prestwood 3fd5250c0d station: refactor the printing of scan results, print SNR/load
There are a few values which are nice to see in debug logs. Namely
the BSS load and SNR. Both of these values may not be available
either due to the AP or local hardware limiations. Rather than print
dummy values for these refactor the print so append the values only
if they are set in the scan result.
2024-06-20 10:51:00 -05:00
James Prestwood 8de70b1952 scan: add flag if BSS load was advertised
For ranking purposes the utilization was defaulted to a valid (127)
which would not change the rank if that IE was not found in the
scan results. Historically this was printed (debug) as part of the
scan results but that was removed as it was somewhat confusing. i.e.
did the AP _really_ have a utilization of 127? or was the IE not
found?

Since it is useful to see the BSS load if that is advertised add a
flag to the scan_bss struct to indicate if the IE was present which
can be checked.
2024-06-20 10:51:00 -05:00
James Prestwood 35808debae scan: use GET_SURVEY for SNR calculation in ranking
This issues a GET_SURVEY dump after scan results are available and
populates the survey information within the scan results. Currently
the only value obtained is the noise for a given frequency but the
survey results structure was created if in the future more values
need to be added.

From the noise, the SNR can be calculated. This is then used in the
ranking calculation to help lower BSS ranks that are on high noise
channels.
2024-06-20 10:51:00 -05:00
James Prestwood 685d105739 unit: add simple test for nl80211util 2024-06-20 10:51:00 -05:00
James Prestwood 43d5e89fac scan: fixed flush flag parsing
Parsing the flush flag for external scans was not done correctly
as it was not parsing the ATTR_SCAN_FLAGS but instead the flag
bitmap. Fix this by parsing the flags attribute, then checking if
the bit is set.
2024-06-20 10:51:00 -05:00
James Prestwood 88a71eca72 nl80211util: add ATTR_SCAN_FLAGS 2024-06-20 10:51:00 -05:00
James Prestwood b4983fdcae nl80211util: add nl80211_parse_nested
Add a nested attribute parser. For the first supported attribute
add NL80211_ATTR_SURVEY_INFO.

This allows parsing of nested attributes in the same convenient
way as nl80211_parse_attrs but allows for support of any level of
nested attributes provided that a handler is added for each.
2024-06-20 10:51:00 -05:00
James Prestwood 16a05316b2 nl80211util: refactor nl80211_parse_attrs for nested variant
To prep for adding a _nested() variant of this function refactor
this to act on an l_genl_attr object rather than the message itself.
In addition a handler specific to the attribute being parsed is
now passed in, with the current "handler_for_type" being renamed to
"handler_for_nl80211" that corresponds to root level attributes.
2024-06-20 10:51:00 -05:00
James Prestwood 1dda441b85 nl80211util: add ATTR_SURVEY_INFO to parse_attrs 2024-06-20 10:51:00 -05:00
James Prestwood 5cf826c73a netdev: downgrade L_WARN_ON for ensure_eapol_registered
This warning is guaranteed to happen for SAE networks where there are
multiple netdev_authenticate_events. This should just be a check so
we don't register eapol twice, not a warning.
2024-06-20 10:51:00 -05:00
Marcel Holtmann 9a5c64481e Release 2.18 2024-06-04 15:36:50 +02:00
Marcel Holtmann 6de09a5eba build: Require at least version 0.66 when building with external ELL 2024-06-03 20:33:31 +02:00
Laura Peeters 03645acf4f eap-tls: Allow tls_msg_len to be zero
EAP-TTLS Start packets are empty by default, but can still be sent with
the L flag set. When attempting to reassemble a message we should not
fail if the length of the message is 0, and just treat it as any other
unfragmented message with the L flag set.
2024-05-31 16:23:15 -05:00
Denis Kenzior c1e2a6c44c build: Add notifylist.[ch] from ell 2024-05-31 15:45:11 -05:00
Denis Kenzior b3e7b7539e watchlist: Remove unused APIs
watchlist_new and watchlist_free were never used.  Get rid of them.
2024-05-29 17:52:23 -05:00
James Prestwood fdbbd8b383 unit: add test for band fallback
This test uses the same country/country3 values seen by an AP vendor
which causes issues with IWD. The alpha2 is ES (Spain) and the 3rd
byte is 4, indicating to use the E-4. The issue then comes when the
neighbor report claims the BSS is under operating class 3 which is
not part of E-4.

With the fallback implemented, this test will pass since it will
try and lookup only on ES (the EU table) which operating class 3 is
part of.
2024-05-14 10:30:48 -05:00
James Prestwood 70d1d71612 band: support band lookup fallback for buggy APs
Its been seen that some vendors incorrectly set the 3rd byte of the
country code which causes the band lookup to fail with the provided
operating class. This isn't compliant with the spec, but its been
seen out in the wild and it causes IWD to behave poorly, specifically
with roaming since it cannot parse neighbor reports. This then
requires IWD to do a full scan on each roam.

Instead of a hard rejection, IWD can instead attempt to determine
the band by ignoring that 3rd byte and only use the alpha2 string.
This makes IWD slightly less strict but at the advantage of not being
crippled when exposed to poor AP configurations.
2024-05-14 10:27:36 -05:00
James Prestwood 4bfc794a37 auto-t: remove default group SAE test for specific OUI
There are already tests for UseDefaultEccGroup and this test is
not longer valid as the static OUI list has been removed.
2024-05-14 10:26:17 -05:00
James Prestwood 8a1f8d1a9a ie: remove is_ie_default_sae_group_oui
This is no longer used and instead a generic option was added
rather than referencing a static OUI list.
2024-05-14 10:26:11 -05:00
James Prestwood b05c1cafcd scan: remove force_default_sae_group from scan_bss
This was added to support a single buggy AP model that failed to
negotiate the SAE group correctly. This may still be a problem but
since then the [Network].UseDefaultEccGroup option has been added
which accomplishes the same thing.

Remove the special handling for this specific OUI and rely on the
user setting the new option if they have problems.
2024-05-14 10:25:46 -05:00
James Prestwood 3be01a83ab build: Create ell directory for ell/ell.h target
Both ell/shared and ell/internal targets first create the ell/
directory within IWD. This apparently was just luck that one of
these always finished first in parallel builds. On my system at
least when building using dpkg-buildpackage IWD fails to build
due to the ell/ directory missing. From the logs it appears that
both the shared/internal targets were started but didn't complete
(or at least create the directory) before the ell/ell.h target:

make[1]: Entering directory '/home/jprestwood/tmp/iwd'
/usr/bin/mkdir -p ell
/usr/bin/mkdir -p ell
echo -n > ell/ell.h
/usr/bin/mkdir -p src
/bin/bash: line 1: ell/ell.h: No such file or directory
make[1]: *** [Makefile:4028: ell/ell.h] Error 1

Creating the ell/ directory within the ell/ell.h target solve
the issue. For reference this is the configure command dpkg
is using:

./configure --build=x86_64-linux-gnu \
	--prefix=/usr \
	--includedir=/usr/include \
	--mandir=/usr/share/man \
	--infodir=/usr/share/info \
	--sysconfdir=/etc \
	--localstatedir=/var \
	--disable-option-checking \
	--disable-silent-rules \
	--libdir=/usr/lib/x86_64-linux-gnu \
	--runstatedir=/run \
	--disable-maintainer-mode \
	--disable-dependency-tracking \
	--enable-tools \
	--enable-dbus-policy
2024-05-14 10:24:09 -05:00
James Prestwood 26efca80d7 nlmon: parse/print neighbor reports
Adds an IE parser for neighbor report elements
2024-05-09 10:23:45 -05:00
John Brandt 5fb3ac5937 eapol: include IGTK in 4-way handshake as AP
When SAE with MFP is being used, include the IGTK in message 3 of the
4-way handshake.
2024-05-07 11:19:51 -05:00
John Brandt 9274f70fec handshake: add functions to save and set IGTK
To add MFP support in the AP mode, add utility functions to save the
IGTK and to add the IGTK to handshake messages.
2024-05-07 11:15:25 -05:00
John Brandt 78bdb26296 eapol: encrypt key data for AKM-defined ciphers
Support encrypting key data when the cipher is AKM-defined. This is
needed to support SAE in AP mode.
2024-05-07 11:03:45 -05:00
John Brandt 3132e9f595 eapol: support PTK derivation with SHA256
Support PTK derivation in case the negotiated AKM requires SHA256. This
is needed to support SAE in AP mode.
2024-05-07 10:52:20 -05:00
John Brandt b9e4dfbd40 sae: support reception of Confirm frame by AP
Experimental AP-mode support for receiving a Confirm frame when in the
COMMITTED state. The AP will reply with a Confirm frame.

Note that when acting as an AP, on reception of a Commit frame, the AP
only replies with a Commit frame. The protocols allows to also already
send the Confirm frame, but older clients may not support simultaneously
receiving a Commit and Confirm frame.
2024-05-07 10:50:39 -05:00
John Brandt 2e80a09184 sae: refactor and add function sae_calculate_keys
Refactor code by moving code to the new function sae_calculate_keys.
This will make it easier in the next commits to add SAE support for AP
mode.
2024-05-07 10:50:39 -05:00
John Brandt 49cddea10b unit: fix SAE unit tests
Don't mark either client as being the authenticator. In the current unit
tests, both instances act as clients to test functionality. This ensures
the unit does not show an error during the following commits where SAE
for AP mode is added.
2024-05-07 10:50:39 -05:00
Marcel Holtmann be3f6a2ca0 udev: Add module for checking interface renaming actions 2024-04-16 14:57:57 +02:00