Commit Graph

6809 Commits

Author SHA1 Message Date
Denis Kenzior f56d01d25e netdev: constify struct scan_bss use
netdev does not keep any pointers to struct scan_bss arguments that are
passed in.  Make this explicitly clear by modifying the API definitions
and mark these as const.
2022-08-23 11:24:04 -05:00
James Prestwood 950624761c auto-t: remove bringing up lo interface
Several tests were setting lo up which is already done by
test-runner.
2022-08-22 12:53:16 -05:00
James Prestwood 4545f80e58 auto-t: update tests to use set_address/group_neighbors
This reduces the big blocks of copied code with a few function calls.
2022-08-22 12:53:16 -05:00
James Prestwood 3439d09817 auto-t: hostapd: add set_address/group_neighbors
This adds a few utilities for setting up an FT environment. All the
roaming tests basically copy/paste the same code for setting up the
hostapd instances and this can cause problems if not done correctly.

set_address() sets the MAC address on the device, and restarts hostapd
group_neighbors() takes a list of HostapdCLI objects and makes each a
    neighbor to the others.

The neighbor report element requires the operating class which isn't
advertised by hostapd. For this we assume operating class 81 but this
can be set explicitly if it differs. Currently no roaming tests use
5/6GHz frequencies, and just in case an exception will be thrown if
the channel is greater than 14 and the op_class didn't change.
2022-08-22 12:53:16 -05:00
James Prestwood 90dc2e5547 test-runner: double RAM for --valgrind
It seems 256MB was right on the edge if valgrind was being used and
sometimes the test would fail with OOM exceptions.
2022-08-22 12:53:16 -05:00
James Prestwood 41ce56bf0d auto-t: fix unreliable behavior in testPSK-roam
The packet loss test had a few problems. First being that the RSSI for
the original BSS was not low enough to change the rank. This meant any
roam was just lucky that the intended BSS was first in the results.

The second problem is timing related, and only happens on UML. Disabling
the rules after the roaming condition sometimes allows IWD to fully
roam and connect before the next state change checks.
2022-08-22 12:53:16 -05:00
James Prestwood fb76a4ef13 auto-t: add packet loss test to testPSK-roam
A new test which blocks all data frames once connected, then tries
to send 100 packets. This should result in the kernel sending a
packet loss event to userspace, which IWD should react to and roam.
2022-08-16 15:30:03 -05:00
James Prestwood 1e1a6d6754 auto-t: add generic tx_packet function
This sends data over the raw sockets similar to test_ifaces_connected
2022-08-16 15:29:59 -05:00
James Prestwood 77c366ba2e netdev: handle packet loss notification
This attribute was already handled and simply printed. Now a
netdev event will be sent to notify any listeners.
2022-08-16 15:29:52 -05:00
James Prestwood 103eeb2cc6 station: react to (new) netdev packet loss event
This adds a new netdev event for packet loss notifications from
the kernel. Depending on the scenario a station may see packet
loss events without any other indications like low RSSI. In these
cases IWD should still roam since there is no data flowing.
2022-08-16 15:29:28 -05:00
James Prestwood 69e9945ef7 device: command: remove default device concept
There was quite a bit of framework behind setting/resetting a default
device, which is now no longer needed.
2022-08-11 15:47:20 -05:00
James Prestwood fce1bb60a8 client: fix station autocomplete with multiple phys
The limitations of readline required that the autocompletion choose
a 'default' device. With multiple phys this doesn't work. Now the
readline limitation has been worked around and station can look up
the device for the command completion.
2022-08-11 15:47:15 -05:00
James Prestwood be02c3fa3d client: add station-debug command interface
This lets iwctl call methods on .StationDebug. The command
name is called 'debug'. This can only be used when IWD is
in developer mode
2022-08-11 15:47:08 -05:00
James Prestwood 9aefec6124 client: allow entity name to be passed to completion
There is a limitation of libreadline where no context/userdata
can be passed to completion functions. Thi affects iwctl since
the entity value isn't known to completion functions.

Workarounds such as getting the default device are employed but
its not a great solution.

Instead hack around this limitation by parsing the prompt to
extract the entity (second arg). Then use a generic match function
given to readline which can call the actual match function and
include the entity.
2022-08-11 15:47:02 -05:00
James Prestwood 8091d5a53d station: add debug method GetNetworks
This gets all networks but includes individual entries for each
BSS.
2022-08-11 15:46:50 -05:00
James Prestwood 9ae4b959a2 doc: add documentation for StationDebug 2022-08-11 15:46:35 -05:00
James Prestwood fa56dcfe91 client: add STATION_DEBUG_INTERFACE definition 2022-08-11 09:45:48 -05:00
James Prestwood 99a71ee819 station: check for matching SSID in Roam()
This is a debug method, but still should verify the SSID in the
target matches the current BSS.
2022-08-11 09:10:47 -05:00
James Prestwood 143b346a4b network: make network const in network_bss_list_get_entries
No reason for this to not be const.
2022-08-11 09:10:40 -05:00
James Prestwood 85dd94dfcf monitor: add support for HE element
Support for the HE IE.
2022-08-09 15:48:28 -05:00
James Prestwood 3940453ad2 monitor: print out type of unknown element
This changes the string from "Reserved" to "Unknown" which feels
more fitting, and also prints out the NL type of the unknown
element.
2022-08-09 15:48:24 -05:00
James Prestwood 0fdc5e87d1 monitor: add better array type support
The ATTR_ARRAY type was quite limited, only supporting u16/u32 and
addresses. This changes the union to a struct so nested/function
can be defined along with array_type.
2022-08-09 15:48:21 -05:00
James Prestwood e67169337f monitor: parse RNR element 2022-08-09 15:47:37 -05:00
James Prestwood 5374e44354 station: re-try OWE if buggy AP is detected
Some APs use an older hostapd OWE implementation which incorrectly
derives the PTK. To work around this group 19 should be used for
these APs. If there is a failure (reason=2) and the AKM is OWE
set force default group into network and retry. If this has been
done already the behavior is no different and the BSS will be
blacklisted.
2022-08-08 13:37:23 -05:00
James Prestwood 7e99f1343c network: add setter/getter/flag for forcing default OWE group
If a OWE network is buggy and requires the default group this info
needs to be stored in network in order for it to set this into the
handshake on future connect attempts.
2022-08-08 13:37:17 -05:00
James Prestwood b094f734e4 owe: allow OWE to force group 19
Similarly with SAE, some AP's either don't do group negotiations
right, or specifically with OWE, incorrectly derive the PTK unless
group 19 is used.
2022-08-08 13:37:08 -05:00
James Prestwood 38ed5e5039 handshake: add force_default_owe_group flag
Indicates the OWE SM should only use the default group
2022-08-08 13:37:05 -05:00
James Prestwood d6b3d6d730 scan: watch for regdom updates to enable 6GHz
This functionality works around the kernel's behavior of allowing
6GHz only after a regulatory domain update. If the regdom updates
scan.c needs to be aware in order to split up periodic scans, or
insert 6GHz frequencies into an ongoing periodic scan. Doing this
allows any 6GHz BSS's to show up in the scan results rather than
needing to issue an entirely new scan to see these BSS's.
2022-08-05 13:38:26 -05:00
James Prestwood 69339c7a97 util: guard against NULL 'freqs' in scan_freq_set_free
Since this can be used with the _auto_ macro it must be able to handle
a NULL input for error paths.
2022-08-05 12:26:54 -05:00
James Prestwood 91df2ee364 scan: split full scans by band to enable 6GHz
The kernel's regulatory domain updates after some number of beacons
are processed. This triggers a regulatory domain update (and wiphy
dump) but only after a scan request. This means a full scan started
prior to the regdom being set will not include any 6Ghz BSS's even
if the regdom was unlocked during the scan.

This can be worked around by splitting up a large scan request into
multiple requests allowing one of the first commands to trigger a
regdom update. Once the regdom updates (and wiphy dumps) we are
hopefully still scanning and could append an additional request to
scan 6GHz.
2022-08-05 12:02:19 -05:00
James Prestwood 0bc44a038b util: add scan_freq_set_clone
This creates a new scan_freq_set from an input set which only contains
frequencies from bands included in the mask.
2022-08-05 11:49:18 -05:00
Denis Kenzior 8c01edf74b scan: Don't crash on external scans
In the case of an external scan, we won't have a scan_request object,
sr.  Make sure to not crash in this case.

Also, since scan_request can no longer carry the frequency set in all
cases, add a new member to scan_results in order to do so.

Fixes: 27d8cf4ccc ("scan: track scanned frequencies for entire request")
2022-08-05 11:17:56 -05:00
Denis Kenzior 3d691038bc station: Fix memory leak
Make sure that the known frequency set is always cleaned up on error.

Fixes: bb604b92f1 ("station: fallback to periodic scan if regdom unset")
2022-08-05 11:17:41 -05:00
Denis Kenzior 82f873a025 util: Allow scan_freq_set to be autodestructed 2022-08-05 09:27:59 -05:00
James Prestwood bb604b92f1 station: fallback to periodic scan if regdom unset
The kernel handles setting the regulatory domain by receiving beacons
which set the country IE. Presumably since most regulatory domains
disallow 6GHz the default (world) domain also disables it. This means
until the country is set, 6GHz is disabled.

This poses a problem for IWD's quick scanning since it only scans a few
frequencies and this likely isn't enough beacons for the firmware to
update the country, leaving 6Ghz inaccessable to the user without manual
intervention (e.g. iw scan passive, or periodic scans by IWD).

To try and work around this limitation the quick scan logic has been
updated to check if a 6GHz AP has been connected to before and if that
frequency is disabled (but supported). If this is the case IWD will opt
for a full passive scan rather than scanning a limited set of
frequencies.
2022-08-04 14:16:51 -05:00
James Prestwood 911572f09a wiphy: don't re-dump wiphy if the regdom didn't change
For whatever reason the kernel will send regdom updates even if
the regdom didn't change. This ends up causing wiphy to dump
which isn't needed since there should be no changes in disabled
frequencies.

Now the previous country is checked against the new one, and if
they match the wiphy is not dumped again.
2022-08-04 14:03:28 -05:00
James Prestwood 1709148484 wiphy: add wiphy_regdom_is_updating
This allows a module to check the current status of the regdom
in case it misses the wiphy event (e.g. registers after the
STARTED event).
2022-08-04 14:03:15 -05:00
James Prestwood 83a5f6edd1 wiphy: dump wiphy's on regulatory domain change
A change in regulatory domain can result in frequencies being
enabled or disabled depending on the domain. This effects the
frequencies stored in wiphy which other modules depend on
such as scanning, offchannel work etc.

When the regulatory domain changes re-dump the wiphy in order
to update any frequency restrictions.
2022-08-04 14:02:39 -05:00
James Prestwood dfcba7c83c wiphy: track GET_REG ID
Keep track of the GET_REG call so it can be canceled if the wiphy
goes down.
2022-08-04 14:02:25 -05:00
James Prestwood 544aafb675 wiphy: add wiphy_country_is_unknown
A helper to check whether the country code corresponds to a
real country, or some special code indicating the country isn't
yet set. For now, the special codes are OO (world roaming) and
XX (unknown entity).
2022-08-04 11:48:08 -05:00
James Prestwood aa0d8f1283 wiphy: add two regulatory domain state events
Events to indicate when a regulatory domain wiphy dump has
started and ended. This is important because certain actions
such as scanning need to be delayed until the dump has finished.
2022-08-04 10:30:46 -05:00
James Prestwood 9b628dd02d wiphy: use nl80211_parse_supported_frequencies
Removes the parser in wiphy and uses the helper instead
2022-08-04 10:25:58 -05:00
James Prestwood 471d34704f wiphy: track self-managed flag
Check if the SELF_MANAGED_REG flag is set and set into wiphy.
2022-08-04 10:25:52 -05:00
James Prestwood 907a2fd7b9 nl80211util: add nl80211_parse_supported_frequencies
A helper function to parse supported and disabled frequencies.
2022-08-04 10:25:45 -05:00
James Prestwood 27d8cf4ccc scan: track scanned frequencies for entire request
The NEW_SCAN_RESULTS handling was written to only parse the frequency
list if there were no additional scan commands to send. This results in
the scan callback containing frequencies of only the last CMD_TRIGGER.

Until now this worked fine because a) the queue is only used for hidden
networks and b) frequencies were never defined by any callers scanning
for hidden networks (e.g. dbus/periodic scans).

Soon the scan command queue will be used to break up scan requests
meaning only the last scan request frequencies would be used in the
callback, breaking the logic in station.

Now the NEW_SCAN_RESULTS case will parse the frequencies for each scan
command rather than only the last.
2022-08-04 10:21:31 -05:00
James Prestwood f555e5dda2 wiphy: fix runtime error from bit shift
The compiler treated the '1' as an int type which was not big enough
to hold a bit shift of 31:

runtime error: left shift of 1 by 31 places cannot be represented in
		type 'int'

Instead of doing the iftype check manually, refactor
wiphy_get_supported_iftypes by adding a subroutine which just parses
out iftypes from a mask into a char** list. This removes the need to
case each iftype into a string.
2022-08-04 10:20:59 -05:00
Denis Kenzior 61682cdc97 gitignore: Add tools/iwd-psk 2022-08-04 10:20:10 -05:00
Alexander Kobel cfd2fe7d33 manager: Fix typo 2022-08-04 09:15:50 -05:00
Michael Johnson 6b87d3e7e2 netdev: Add logging for CQM messages
Add extra logging around CQM events to help track wifi status. This is
useful for headless systems that can only be accessed over the network
and so information in the logs is invaluable for debugging outages.

Prior to this change, the only log for CQM messages is saying one was
received. This adds details to what attributes were set and the
associated data with them.

The signal strength log format was chosen to roughly match
wpa_supplicant's which looks like this:

CTRL-EVENT-SIGNAL-CHANGE above=1 signal=-60 noise=-96 txrate=6000
2022-08-02 11:11:18 -05:00
Michael Johnson f4c3278a7b station: Log scan results during a roam
Provides useful information on why a roam might have failed, such as
failing to find the BSS or the BSS being ranked lower, and why that
might be.

The output format is the same as station_add_seen_bss for consistency.
2022-08-01 10:17:23 -05:00