Commit Graph

3265 Commits

Author SHA1 Message Date
Denis Kenzior 308071796a network: Update comment 2021-07-07 21:03:06 -05:00
Denis Kenzior 1d64c96a5c pwd/sae/owe: Update to ell ecc API changes 2021-07-07 20:56:53 -05:00
Denis Kenzior dfdc8716be network: Rename _sync_psk to _sync_settings
There will be additional security-related settings that will be
introduced for settings files.  In particular, Hash-to-Curve PT
elements, Transition Disable settings and potentially others in the
future.  Since PSK is now not the only element that would require
update, rename this function to better reflect this.
2021-07-06 11:46:33 -05:00
Denis Kenzior dcd48e1f66 anqp: Ensure a random token is used 2021-07-05 20:25:14 -05:00
Denis Kenzior 667023b01b wiphy: ensure CCMP support when considering SAE 2021-07-05 19:53:52 -05:00
Denis Kenzior fbe8b7a3c0 crypto: Add prf_plus function
PRF+ from RFC 5295 is the more generic function using which HKDF_Expand
is defined.  Allow this function to take a vararg list of arguments to
be hashed (these are referred to as 'S' in the RFCs).

Implement hkdf_expand in terms of prf_plus and update all uses to the
new syntax.
2021-06-29 20:37:38 -05:00
Denis Kenzior 412fea3ffa crypto: Make hkdf_extract take void *
This makes it easier to use from unit tests and other places which might
be dealing with const char * data.
2021-06-29 11:55:16 -05:00
Michael Johnson ed283d7b14 iwd.service: Add CAP_NET_BIND_SERVICE
This fixes an issue where the udp port was not being opened due to a
permission denied error. The result of this was the dhcp client would
fail to send the renewal request and so the dhcp lease would expire.

The addition of the CAP_NET_BIND_SERVICE capability allows the service
to open sockets in the restricted port range (<1024) which is required
for dhcp.
2021-06-29 11:43:26 -05:00
Michael Johnson b6236255d2 Send hostname as part of DHCP request.
This is based on a previous patch by Roberto Santalla Fernández.

A new config is introduced into the network config file under IPv4
called SendHostname. If this is set to true then we add the hostname
into all DHCP requests. The default is false.
2021-06-18 13:05:59 -05:00
Andrew Zaborowski 19e5cc9b0d station: Remove diagnostics interface reliably
If the idea is that the interface should only be present when connected
then don't do this in the DISCONNECTING state as there are various
possible transitions from CONNECTED or ROAMING directly to DISCONNECTED.
2021-06-18 10:06:57 -05:00
Andrew Zaborowski 002fc2d632 station: Check if busy in station_get_diagnostics 2021-06-18 09:58:42 -05:00
Joseph Benden 7436cef012 eapol: Use constant-time comparison
This closes the possibility of a timing attack against PMKIDs.
2021-06-14 09:07:53 -05:00
Denis Kenzior eb84e29c81 agent: Send Release/Cancel with no_reply flag set
These method calls did not process or expect a reply.
2021-06-09 10:34:22 -05:00
Andrew Zaborowski d9c324a511 netconfig: Make gateway optional for client
Don't require a gateway address from the settings file or from the DHCP
server when doing netconfig.  Failing when the gateway address was
missing was breaking P2P but also small local networks.
2021-06-08 10:25:49 -05:00
Denis Kenzior 7f4dd181b2 ip-pool: Take out un-needed cast 2021-06-07 17:30:25 -05:00
Denis Kenzior 3dcf1fd9d8 ip-pool: Sanity check addr_str_list 2021-06-07 17:22:43 -05:00
Andrew Zaborowski c295fba546 ip-pool: Validate prefix lengths in used addresses
Be paranoid and check that the prefix length in addresses from
used_addr4_list are not zero (they shouldn't be) and that address family
is AF_INET (it should be), mainly to quiet coverity warnings:

While there also fix one line's indentation.
2021-06-07 17:03:23 -05:00
Andrew Zaborowski b1c8a57047 ip-pool: Make host address valid even if prefix_len != 24
At the end of ip_pool_select_addr4() we'd check if the selected address
is equal to the subnet address and increment it by 1 to produce a valid
host address for the AP.  That check was always correct only with 24-bit
prefix, extend it to actually use the prefix-dependent mask instead of
0xff.  Fixes a testAP failure triggered 50% of the times because the
netmask is 28 bit long there.
2021-06-07 17:02:09 -05:00
Denis Kenzior 6f99368935 ip-pool: Use inet_ntop instead of inet_ntoa 2021-06-04 14:11:25 -05:00
Denis Kenzior 094537efc6 netconfig: Use inet_ntop instead of inet_ntoa 2021-06-04 13:53:31 -05:00
Denis Kenzior 772aa687d7 ip-pool: Do not use inet_aton 2021-06-04 12:31:53 -05:00
Denis Kenzior 75a9199bc4 ap: Do not use inet_aton 2021-06-04 12:31:36 -05:00
Andrew Zaborowski 617e99a423 p2p: Set Linkmode/operstate on GO connection 2021-06-04 11:56:23 -05:00
Andrew Zaborowski 04bfe55c36 p2p: As GO delay connect success until client gets IP
Don't signal the connected state until the client has obtained a DHCP
lease and we can set the ConnectedIP property.  From now on that
property is always set when there's a connection.
2021-06-04 11:56:02 -05:00
Andrew Zaborowski f7c6fe0ed6 p2p: Also set a DHCP timeout in Group Owner role
Move the loading of the [P2P].DHCPTimeout setting to initialization and
set the timeout both in P2P Client and P2P GO roles.
2021-06-04 11:55:29 -05:00
Andrew Zaborowski 0e865a7028 ap: Forward DHCP events to AP event handler 2021-06-04 11:55:06 -05:00
Andrew Zaborowski 42afc31cbe p2p: Fix parsing of Association Req P2P IEs
p2p_parse_association_req() already extracts the P2P IE payload from the
IE sequence, there's no need to call ie_tlv_extract_p2p_payload before
it.  Pass the IE sequence directly to p2p_parse_association_req().
2021-06-04 11:54:48 -05:00
Andrew Zaborowski 1399b5688b p2p: Fix a leak of ie_tlv_extract_p2p_payload() result 2021-06-04 11:54:40 -05:00
Andrew Zaborowski 69d9a07e34 p2putil: Ensure non-negative index in p2p_get_random_string 2021-06-04 11:53:31 -05:00
Andrew Zaborowski d96f542951 wscutil: Fix a return statement
Fixes: 8d58f5b679 ('wscutil: Move DeviceType parsing from p2p & eap-wsc to a function')
2021-06-04 11:53:25 -05:00
Andrew Zaborowski ec9260fa0c ap: Fix leaking of ap->wsc_pbc_timeout 2021-06-04 11:53:20 -05:00
Andrew Zaborowski aa9a914975 ap: Warn about APRanges having been deprecated 2021-06-04 11:53:14 -05:00
Andrew Zaborowski e9a33524a2 ap: Drop unneeded broadcast address calculation
It's already done in l_rtnl_address_new().
2021-06-04 11:53:04 -05:00
Denis Kenzior 45c7aa0d18 netconfig: Check l_rtnl_address_get_address return 2021-06-04 10:26:18 -05:00
Denis Kenzior 03b48b5621 station: Pretty-print the estimated BSS data rate 2021-06-04 10:14:04 -05:00
Denis Kenzior 647f1e9b91 ie: Remove old data rate estimation utilities 2021-06-04 10:14:04 -05:00
Denis Kenzior 43692cb377 wiphy: Use new data rate estimation utilities 2021-06-04 10:14:04 -05:00
Denis Kenzior 2d480f12e1 band: Add utility for estimating non-ht data rate 2021-06-04 10:14:04 -05:00
Denis Kenzior 575f603f89 band: Add HT RX rate estimation
Similarly to commit
27d302a0 ("band: Add a utility to estimate VHT rx data rate"), this
commit adds an RX data rate estimation utility for HT connections.
2021-06-04 10:14:04 -05:00
Denis Kenzior a17745661e band: Add a utility to estimate VHT rx data rate
This function is meant to supercede a similar function in ie.c.  The
current approach results in very optimistic data rate estimates since it
only takes into account the VHT/HT Capabilities IEs.  It does not take
into account any local hardware limitations (such as no VHT/HT support),
limited RX MCS sets & number of spatial streams.  It also does not take
into account that the AP might not be actually operating on higher
bandwidth channels.

This function is meant to address that by matching peer TX MCS sets with
the local hardware RX MCS set capability.  It also takes into account
channel bandwidth capabilities of the local hardware, as well as whether
the AP is actually operating on a wider channel.
2021-06-04 10:14:04 -05:00
Denis Kenzior 842a70a307 band: Move ht/vht data rate calculation out of ie.c 2021-06-04 10:14:04 -05:00
Denis Kenzior e41bee377d band: Add band.[ch]
Move the band definition out of wiphy.c and into band.[ch].  This is
done to make certain utilities that depend on band information capable
of being tested from unit tests.

The band concept will most likely grow over time.  For now, the only
user will be wiphy.c and unit tests, so the structures are kept public.
2021-06-04 10:14:04 -05:00
Denis Kenzior 46f6fb1bd1 netconfig: Cancel pending address set command
It is possible that the address set command succeeds just after a
netconfig object has been destroyed.

==6485== Invalid read of size 8
==6485==    at 0x458A6D: netconfig_ipv4_routes_install (netconfig.c:629)
==6485==    by 0x458D1C: netconfig_ipv4_ifaddr_add_cmd_cb (netconfig.c:689)
==6485==    by 0x4A5E7B: process_message (netlink.c:181)
==6485==    by 0x4A626A: can_read_data (netlink.c:289)
==6485==    by 0x4A3E19: io_callback (io.c:120)
==6485==    by 0x4A27B5: l_main_iterate (main.c:478)
==6485==    by 0x4A28F6: l_main_run (main.c:525)
==6485==    by 0x4A2C0E: l_main_run_with_signal (main.c:647)
==6485==    by 0x404D27: main (main.c:542)
==6485==  Address 0x4a47290 is 32 bytes inside a block of size 104 free'd
==6485==    at 0x48399CB: free (vg_replace_malloc.c:538)
==6485==    by 0x49998B: l_free (util.c:136)
==6485==    by 0x457699: netconfig_free (netconfig.c:130)
==6485==    by 0x45A038: netconfig_destroy (netconfig.c:1163)
==6485==    by 0x41FD16: station_free (station.c:3613)
==6485==    by 0x42020E: station_destroy_interface (station.c:3710)
==6485==    by 0x4B990E: interface_instance_free (dbus-service.c:510)
==6485==    by 0x4BC193: _dbus_object_tree_remove_interface (dbus-service.c:1694)
==6485==    by 0x4BA22A: _dbus_object_tree_object_destroy (dbus-service.c:795)
==6485==    by 0x4B078D: l_dbus_unregister_object (dbus.c:1537)
==6485==    by 0x417ACB: device_netdev_notify (device.c:361)
==6485==    by 0x4062B6: netdev_free (netdev.c:808)
==6485==  Block was alloc'd at
==6485==    at 0x483879F: malloc (vg_replace_malloc.c:307)
==6485==    by 0x499857: l_malloc (util.c:62)
==6485==    by 0x459DC0: netconfig_new (netconfig.c:1115)
==6485==    by 0x41FC29: station_create (station.c:3592)
==6485==    by 0x4207B3: station_netdev_watch (station.c:3864)
==6485==    by 0x411A17: netdev_initial_up_cb (netdev.c:5588)
==6485==    by 0x4A5E7B: process_message (netlink.c:181)
==6485==    by 0x4A626A: can_read_data (netlink.c:289)
==6485==    by 0x4A3E19: io_callback (io.c:120)
==6485==    by 0x4A27B5: l_main_iterate (main.c:478)
==6485==    by 0x4A28F6: l_main_run (main.c:525)
==6485==    by 0x4A2C0E: l_main_run_with_signal (main.c:647)
==6485==
2021-06-04 10:14:04 -05:00
Denis Kenzior e39cdc7a29 wiphy: Print basic VHT info for each band 2021-06-04 10:14:04 -05:00
Denis Kenzior 77ea7ad437 netdev: Better detect connecting state
netdev_free relies on netdev->connected being set to detect whether a
connection is in progress.  This variable is only set once the driver
has been connected however, so for situations where a CMD_CONNECT is
still 'in flight' or if the wiphy work is still pending, the ongoing
connection will not be canceled.  Fix that by being more thorough when
trying to detect that a connection is in progress.

src/wiphy.c:wiphy_radio_work_next() Starting work item 2
Terminate
src/netdev.c:netdev_free() Freeing netdev wlan0[9]
src/device.c:device_free()
src/station.c:station_free()
src/netconfig.c:netconfig_destroy()
Removing scan context for wdev c
src/scan.c:scan_context_free() sc: 0x4a44c80
src/netdev.c:netdev_mlme_notify() MLME notification New Station(19)
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
==6356== Invalid write of size 4
==6356==    at 0x40A253: netdev_cmd_connect_cb (netdev.c:2522)
==6356==    by 0x4A8886: process_unicast (genl.c:986)
==6356==    by 0x4A8C48: received_data (genl.c:1098)
==6356==    by 0x4A3DFD: io_callback (io.c:120)
==6356==    by 0x4A2799: l_main_iterate (main.c:478)
==6356==    by 0x4A28DA: l_main_run (main.c:525)
==6356==    by 0x4A2BF2: l_main_run_with_signal (main.c:647)
==6356==    by 0x404D27: main (main.c:542)
==6356==  Address 0x4a3e418 is 152 bytes inside a block of size 472 free'd
==6356==    at 0x48399CB: free (vg_replace_malloc.c:538)
==6356==    by 0x49996F: l_free (util.c:136)
==6356==    by 0x406662: netdev_free (netdev.c:886)
==6356==    by 0x4129C2: netdev_shutdown (netdev.c:5980)
==6356==    by 0x403A14: iwd_shutdown (main.c:79)
==6356==    by 0x403A7D: signal_handler (main.c:90)
==6356==    by 0x4A2AFB: sigint_handler (main.c:612)
==6356==    by 0x4A2F3B: handle_callback (signal.c:78)
==6356==    by 0x4A3030: signalfd_read_cb (signal.c:104)
==6356==    by 0x4A3DFD: io_callback (io.c:120)
==6356==    by 0x4A2799: l_main_iterate (main.c:478)
==6356==    by 0x4A28DA: l_main_run (main.c:525)
==6356==  Block was alloc'd at
==6356==    at 0x483879F: malloc (vg_replace_malloc.c:307)
==6356==    by 0x49983B: l_malloc (util.c:62)
==6356==    by 0x4121BD: netdev_create_from_genl (netdev.c:5776)
==6356==    by 0x451F6F: manager_new_station_interface_cb (manager.c:173)
==6356==    by 0x4A8886: process_unicast (genl.c:986)
==6356==    by 0x4A8C48: received_data (genl.c:1098)
==6356==    by 0x4A3DFD: io_callback (io.c:120)
==6356==    by 0x4A2799: l_main_iterate (main.c:478)
==6356==    by 0x4A28DA: l_main_run (main.c:525)
==6356==    by 0x4A2BF2: l_main_run_with_signal (main.c:647)
==6356==    by 0x404D27: main (main.c:542)
2021-06-01 18:16:03 -05:00
Denis Kenzior 683ff1a4e4 wiphy: Return -errno instead of false 2021-06-01 16:46:23 -05:00
Denis Kenzior d773c0b4ac netdev: Do not leak netdev objects
If the daemon is started and killed rapidly on startup, it is possible
for netdev_shutdown to be called prior to manager processing messages
that actually create the netdev itself.  Since the netdev_list has
already been freed, the storage is lost.  Fix that by destroying
netdev_list only when the module is unloaded.
2021-06-01 13:41:56 -05:00
Denis Kenzior 2b0b5d4173 netdev: Check ifi_flags in netdev_connect/disconnect
Also, set the flags appropriately when removing the netdev object.  This
prevents callers from accidentally starting any actions that will simply
fail.
2021-06-01 13:41:56 -05:00
Denis Kenzior 11f42e2476 netdev: Always cleanup disconnect_cmd_id 2021-06-01 13:41:56 -05:00
Denis Kenzior f6f5570bc8 netdev: Notify EVENT_DEL earlier
If we're going down, make sure to notify any watches about EVENT_DEL
earlier.  Not doing so might result in us not cleaning up requests that
might have been started as the result of this event.
2021-06-01 13:41:56 -05:00
Denis Kenzior cf950f6d3f station: Do not call netdev_disconnect on in station_free
station_free() is invoked when one of two possibilities happen:
- Device has been powered down, and EVENT_DOWN has been emitted
- Device has been removed, and EVENT_DEL has been emitted

In both cases there is not much point for netdev_disconnect to be
invoked as that tries to cleanly shut down an existing connection.  The
only thing the ABORTED error accomplishes in this case is to send a
dbus_aborted_error for the pending_connect message, if it exists.
There's already code for doing this in station_free().

src/station.c:station_enter_state() Old State: autoconnect_quick, new state: connecting (auto)
src/scan.c:scan_cancel() Trying to cancel scan id 1 for wdev 7
src/wiphy.c:wiphy_radio_work_done() Work item 1 done
src/wiphy.c:wiphy_radio_work_next() Starting work item 2
Terminate
src/netdev.c:netdev_free() Freeing netdev wlan0[9]
src/device.c:device_free()
src/station.c:station_free()
src/wiphy.c:wiphy_radio_work_done() Work item 2 done
src/station.c:station_connect_cb() 9, result: 5
src/netconfig.c:netconfig_destroy()
Removing scan context for wdev 7
src/scan.c:scan_context_free() sc: 0x4a39490
src/netdev.c:netdev_mlme_notify() MLME notification New Station(19)
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/netdev.c:netdev_mlme_notify() MLME notification Authenticate(37)
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/netdev.c:netdev_mlme_notify() MLME notification Associate(38)
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/netdev.c:netdev_mlme_notify() MLME notification Connect(46)
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/wiphy.c:wiphy_reg_notify() Notification of command Reg Change(36)
src/wiphy.c:wiphy_update_reg_domain() New reg domain country code for (global) is US
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/netdev.c:netdev_unicast_notify() Unicast notification 129
src/netdev.c:netdev_mlme_notify() MLME notification Del Station(20)
src/netdev.c:netdev_mlme_notify() MLME notification Deauthenticate(39)
src/netdev.c:netdev_mlme_notify() MLME notification Disconnect(48)
src/wiphy.c:wiphy_reg_notify() Notification of command Reg Change(36)
src/wiphy.c:wiphy_update_reg_domain() New reg domain country code for (global) is XX
==20311== Invalid write of size 4
==20311==    at 0x406E74: netdev_cmd_disconnect_cb (netdev.c:1130)
==20311==    by 0x4A78A8: process_unicast (genl.c:986)
==20311==    by 0x4A7C6A: received_data (genl.c:1098)
==20311==    by 0x4A2E1F: io_callback (io.c:120)
==20311==    by 0x4A17BB: l_main_iterate (main.c:478)
==20311==    by 0x4A18FC: l_main_run (main.c:525)
==20311==    by 0x4A1C14: l_main_run_with_signal (main.c:647)
==20311==    by 0x404D27: main (main.c:542)
==20311==  Address 0x4a37a0c is 156 bytes inside a block of size 472 free'd
==20311==    at 0x48399CB: free (vg_replace_malloc.c:538)
==20311==    by 0x498991: l_free (util.c:136)
==20311==    by 0x406651: netdev_free (netdev.c:883)
==20311==    by 0x412976: netdev_shutdown (netdev.c:5970)
==20311==    by 0x403A14: iwd_shutdown (main.c:79)
==20311==    by 0x403A7D: signal_handler (main.c:90)
==20311==    by 0x4A1B1D: sigint_handler (main.c:612)
==20311==    by 0x4A1F5D: handle_callback (signal.c:78)
==20311==    by 0x4A2052: signalfd_read_cb (signal.c:104)
==20311==    by 0x4A2E1F: io_callback (io.c:120)
==20311==    by 0x4A17BB: l_main_iterate (main.c:478)
==20311==    by 0x4A18FC: l_main_run (main.c:525)
2021-06-01 13:41:56 -05:00
Denis Kenzior dbd66bd497 wiphy: Print more basic wiphy info 2021-06-01 13:41:56 -05:00
Denis Kenzior 709b77794b scan: Use wiphy_estimate_data_rate 2021-06-01 13:41:56 -05:00
Denis Kenzior 74761fcdd3 wiphy: Add wiphy_estimate_data_rate
The data rate estimation belongs in wiphy since it should take hardware
capabilities into account.  Right now the data rate calculation simply
assumes the hardware is as capable as the AP.  scan.c will be ported to
use this utility and the data rate estimation will be expanded to take
wiphy capabilities into account.
2021-06-01 13:41:56 -05:00
Denis Kenzior 8679b82db4 scan: Simplify parsing logic
scan_parse_result used to parse the wdev and return this to the caller
where it was compared against the expected wdev.  Simplify this by
extract the wdev first, and proceeding with the bss parsing afterwards.
2021-06-01 13:41:56 -05:00
Denis Kenzior 10ac107ba6 wiphy: Parse HT Capabilities & MCS Set 2021-06-01 13:41:56 -05:00
Denis Kenzior ea9bc11fc8 wiphy: Parse VHT Capabilities & MCS Set 2021-06-01 13:41:56 -05:00
Denis Kenzior 7a4d48c16d wiphy: Add a more formal representation of band
Right now a very limited set of band parameters are parsed into wiphy.
This includes the supported rates and the supported frequencies.
However, there is much more information that is given for each band.
Introduce a new band object that will store this information and can be
extended for future use.
2021-06-01 13:41:55 -05:00
Denis Kenzior 29f2ac2070 eap-md5: Do not check deprecated MD5-Secret 2021-06-01 10:44:57 -05:00
Denis Kenzior d8b305d799 eap-gtc: Do not check deprecated GTC-Secret 2021-06-01 10:44:23 -05:00
Denis Kenzior 6d9d2f5b89 knownnetworks: Do not check legacy Autoconnect setting 2021-06-01 10:32:48 -05:00
Denis Kenzior b9304eaf20 manager: Do not check deprecated use_default_interface 2021-06-01 10:29:42 -05:00
Denis Kenzior d50ee161f5 resolve: Do not check deprecated dns_resolve_method 2021-06-01 10:28:47 -05:00
Denis Kenzior f1bc1ed4be station: Do not check deprecated enable_network_config
Enough time has passed where everyone should have had the chance to
update this to the new setting.
2021-06-01 10:26:18 -05:00
Andrew Zaborowski 2471d4c3cd doc: Update AP settings in iwd.ap(5) and iwd.config(5) 2021-06-01 10:20:50 -05:00
Andrew Zaborowski 7163a9d9d7 ap: Save AP address as l_rtnl_address
Change the char *addr_str and uint8_t prefix_len pair to an
l_rtnl_address object and use ell/rtnl.h utilities that use that
directly.  Extend broadcast_from_ip to handle prefix_len.
2021-06-01 10:15:43 -05:00
Andrew Zaborowski a6002562ef ap: Send a specific error message on async AP start failure
We generate the DBus error reply type from the errno only when
ap_start() was failing synchronously, now also send the errno through
the callbacks so that we can also return a specific DBus reply when
failing asynchronously.  Thea AP autotest relies on receiving the
AlreadyExists DBus error.
2021-06-01 10:15:16 -05:00
Andrew Zaborowski ff2840f95f ap: Refactor global address pool loading
Deprecate the global [General].APRanges setting in favour of
[IPv4].APAddressPool with an extended (but backwards-compatible) syntax.
Drop the existing address pool creation code.

The new APAddressPool setting has the same syntax as the profile-local
[IPv4].Address setting and the subnet selection code will fall back
to the global setting if it's missing, this way we use common code to
handle both settings.
2021-06-01 10:11:37 -05:00
Andrew Zaborowski c5d1a5c31f ap: Refactor DHCP settings loading
Extend the [IPv4].Address setting's syntax to allow a new format: a list
of <IP>/<prefix_len> -form strings that define the address space from
which a subnet is selected.  Rewrite the DHCP settings loading with
other notable changes:

 * validate some of the settings more thoroughly,
 * name all netconfig-related ap_state members with the netconfig_
   prefix,
 * make sure we always call l_dhcp_server_set_netmask(),
 * allow netmasks other than 24-bit and change the default to 28 bits,
 * as requested avoid using the l_net_ ioctl-based functions although
   l_dhcp still uses them internally,
 * as requested avoid touching the ap_state members until the end of
   some functions so that on error they're basically a no-op (for
   readability).
2021-06-01 10:04:35 -05:00
Andrew Zaborowski e56e4ade90 ip-pool: Add subnet address selection logic
Add the ip_pool_select_addr4 function to select a random subnet of requested
size from an address space defined by a string list (for use with the
AP profile [IPv4].Address and the global [IPv4].APAddressPool settings),
avoiding those subnets that conflict with subnets in use.  We take care
to give a similar weight to all subnets contained in the specified
ranges regardless of how many ranges contain each, basically so that
overlapping ranges don't affect the probabilities (debatable.)
2021-06-01 10:03:04 -05:00
Andrew Zaborowski 6e5b26ba64 ip-pool: Track IPv4 addresses in use
Add the ip-pool submodule that tracks IPv4 addresses in use on the
system for use when selecting the address for a new AP.  l_rtnl_address
is used internally because if we're going to return l_rtnl_address
objects it would be misleading if we didn't fill in all of their
properties like flags etc.
2021-06-01 10:03:00 -05:00
Denis Kenzior 9518d68d9a eapolutil: Use flexible-array member
Instead of zero-length array, use the more preferred flexible-array
member.  See https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
2021-05-28 10:57:11 -05:00
Alvin Šipraga 920ac37a40 station: update current BSS frequency on netdev channel switch event
If the connected BSS changes channel, netdev will emit an event with the
new channel's frequency. In response, have station change the frequency
of the connected scan_bss struct and inform network about the update.
2021-05-27 13:53:51 -05:00
Alvin Šipraga 5eb0b7ca8e netdev: add a channel switch event
If the connected BSS announces that it is switching operating channel,
the kernel may emit the NL80211_CMD_CH_SWTICH_NOTIFY event when the
switch is complete. Add a new netdev event NETDEV_EVENT_CHANNEL_SWITCHED
to signal to interested modules that the connected BSS has changed
channel. The event carries a pointer to the new channel's frequency.
2021-05-27 13:53:02 -05:00
Alvin Šipraga f50a51d943 network: sync known network frequency on BSS update
When a scan_bss is updated in the BSS list of a known network, it may be
on a new frequency. Sync the known frequencies list accordingly.
2021-05-27 13:49:43 -05:00
Alvin Šipraga 38ded68a38 scan: parse NL80211_BSS_LAST_SEEN_BOOTTIME in units of nanoseconds
NL80211_BSS_LAST_SEEN_BOOTTIME is expressed in nanoseconds, while BSS
timestamps are expressed in microseconds internally. Convert the
attribute to microseconds when using it to timestamp a BSS. This makes
iwd expire absent BSSes within 30 seconds as intended.

Fixes: 454cee12d4 ("scan: Use kernel-reported time-stamp if provided")
2021-05-26 10:20:48 -05:00
Denis Kenzior 1822062d55 station: Continue trying to autoconnect on failure
Right now, if a connection to a network selected by auto-connect fails,
the entire autoconnect process is restarted.  This means that scans are
kicked off again, auto-connect list is rebuilt, etc.  This was due to
auto-connect reusing the same failure path as connections triggered via
D-Bus.

The above behavior can lead to weird situations in certain corner cases.
For example, a highly preferred network configured with the wrong
password would result in auto-connect entering an infinite loop.

Fix this by making sure that all auto-connect entries are tried and
exhausted prior to re-scanning again.
2021-05-25 18:42:57 -05:00
Denis Kenzior ca561be4b9 network: Clear temporary ban list in network_disconnected
The temporary ban list is cleared when a network is connected to
successfully, and also in network_connect_failed.  Unfortunately,
network_connect_failed is not called in all paths (i.e. during
autoconnect) since it messes with the state of secrets and passphrases.

Clear the list in network_disconnected() instead, since it is guaranteed
to be called in every circumstance.
2021-05-25 18:42:57 -05:00
Denis Kenzior db3024eed6 station: Introduce CONNECTING_AUTO state
This will be effectively the same as the CONNECTING state, but can be
used to enable differing behavior, depending on whether connection was
triggered by autoconnect or via D-Bus.
2021-05-25 18:42:57 -05:00
Denis Kenzior 00763fde0d station: Break up station_connect_cb
Break this up into two parts, one handling the successful connect case,
the other for handling error conditions
2021-05-25 18:42:57 -05:00
Denis Kenzior e265f95f45 ie: Fix VHT Capabilities to Data Rate conversion
Code that walked the VHT TX/RX MCS maps seemed to assume that bit_field
operated on bits that start at '1'.  But this utility actually operates
on bits that start at '0'.  I.e. the least significant bit is at
position 0.

While we're at it, rename the mcs variable into bitoffset to make it
clearer how the maps are being iterated over.  Supported MCS is actually
the value found in the map.
2021-05-25 18:42:57 -05:00
Denis Kenzior efa5b0cc62 main: Document '-E', --developer option 2021-05-25 13:30:29 -05:00
Denis Kenzior e47bc6ede4 main: Remove dbus-debug -B option
This option has not been used in a very long time, and is of limited
utility since the only thing D-Bus debugging does is hexdumps the
content of D-Bus messages to the terminal.
2021-05-25 13:20:07 -05:00
Denis Kenzior c3b1425edd ie: Fix up HT/VHT data rate calculation
The current calculation was giving erroneous results when it came to VHT
MCS index 4 and VHT MCS index 8 & 9.

Switch to a precomputed look up table and add a multiplication factor
for short GI.
2021-05-24 18:39:26 -05:00
Denis Kenzior edf7294c06 ap: Do not leak ap->server
ap_reset() seems to be called whenever the AP is stopped or removed due
to interface shutdown.  For some reason ap_reset did not remove the DHCP
server object, resulting in leaks:

==211==    at 0x483879F: malloc (vg_replace_malloc.c:307)
==211==    by 0x46B5AD: l_malloc (util.c:62)
==211==    by 0x49B0E2: l_dhcp_server_new (dhcp-server.c:715)
==211==    by 0x433AA3: ap_setup_dhcp (ap.c:2615)
==211==    by 0x433AA3: ap_load_dhcp (ap.c:2645)
==211==    by 0x433AA3: ap_load_config (ap.c:2753)
==211==    by 0x433AA3: ap_start (ap.c:2885)
==211==    by 0x434A96: ap_dbus_start_profile (ap.c:3329)
==211==    by 0x482DA9: _dbus_object_tree_dispatch (dbus-service.c:1815)
==211==    by 0x47A4D9: message_read_handler (dbus.c:285)
==211==    by 0x4720EB: io_callback (io.c:120)
==211==    by 0x47130C: l_main_iterate (main.c:478)
==211==    by 0x4713DB: l_main_run (main.c:525)
==211==    by 0x4713DB: l_main_run (main.c:507)
==211==    by 0x4715EB: l_main_run_with_signal (main.c:647)
==211==    by 0x403EE1: main (main.c:550)
2021-05-24 14:31:04 -05:00
Denis Kenzior 23451be606 netconfig: Do not leak l_acd if static IP is used
==209==    by 0x43E48A: netconfig_ipv4_select_and_install (netconfig.c:887)
==209==    by 0x43E48A: netconfig_configure (netconfig.c:1025)
==209==    by 0x41743C: station_connect_cb (station.c:2556)
==209==    by 0x408E0D: netdev_connect_ok (netdev.c:1311)
==209==    by 0x47549E: process_unicast (genl.c:994)
==209==    by 0x47549E: received_data (genl.c:1102)
==209==    by 0x4720EB: io_callback (io.c:120)
==209==    by 0x47130C: l_main_iterate (main.c:478)
==209==    by 0x4713DB: l_main_run (main.c:525)
==209==    by 0x4713DB: l_main_run (main.c:507)
==209==    by 0x4715EB: l_main_run_with_signal (main.c:647)
==209==    by 0x403EE1: main (main.c:550)
2021-05-24 14:31:04 -05:00
Denis Kenzior 66b73262df station: Check return of network_bss_select
network_bss_select can return NULL if no suitable BSSes are found, or if
all of them are blacklisted.  Make sure to skip the network if this
happens.
2021-05-19 09:56:59 -05:00
James Prestwood 877d910a44 station: autoconnect based on network, not BSS
Prior to the BSS blacklist a BSS based autoconnect list made
the most sense, but now station actually retries all BSS's upon
failure. This means that for each BSS in the autoconnect list
every other BSS under that SSID will be attempted to connect to
if there is a failure. Essentially this is a network based
autoconnect list, just an indirect way of doing it.

Intead the autoconnect list can be purely network based, using
the network rank for sorting. This avoids the need for a special
autoconnect_entry struct as well as ensures the last connected
network is chosen first (simply based on existing network ranking
logic).
2021-05-19 09:44:18 -05:00
James Prestwood 0be5beffc8 network: use WPA version and privacy for ranking
These ranking factors were moved out of scan.c and into
network.c as they are more relevant for network ranking
than BSS ranking.
2021-05-19 09:32:28 -05:00
James Prestwood 3fde169001 scan: rework BSS ranking
It was observed that IWD's ranking for BSS's did not always
end up with the fastest being chosen. This was due to IWD's
heavy weight on signal strength. This is a decent way of ranking
but even better is calculating a theoretical data rate which
was also done and factored in. The problem is the data rate
factor was always outdone by the signal strength.

Intead remove signal strength entirely as this is already taken
into account with the data rate calculation. This also removes
the check for rate IEs. If no IEs are found the parser will
base the data rate soley on RSSI.

There were a few other factors removed which will be added back
when ranking *networks* rather than BSS's. WPA version (or open)
was removed as well as the privacy capability. These values really
should not differ between BSS's in the same SSID and as such
should be used for network ranking instead.
2021-05-19 09:32:17 -05:00
James Prestwood 7c9561f027 ie: refactor parsing supported data rates
Both ext/supported rates IEs are obtained from scan results. These
IEs are passed to ie_tlv_init/ie_tlv_next, as well as direct length
checks (for supported rates at least, extended supported rates can
be as long as a single byte integer can hold, 1 - 255) which verifies
that the length in the IE matches the overall IE length that is
stored in scan_bss. Because of this, ie_parse_supported_rates_from_data
was doing double duty re-initializing a TLV iterator.

Intead, since we know the IE length is within bounds, the length/data
can simply be directly accessed out of the buffer. This avoids the need
for a wrapper function entirely.

The length parameters were also removed, since this is now obtained
directly from the IE.
2021-05-14 14:28:23 -05:00
Andrew Zaborowski 02e46542e3 ap: Make rtnl global static 2021-05-14 09:49:08 -05:00
James Prestwood df04877a67 station: use IE_AKM_IS_FT when possible
Update a check to use IE_AKM_IS_FT as the condition is identical
to the macro.
2021-05-12 18:04:30 -05:00
James Prestwood 7fc0a8fc0f station: make station_can_fast_transition more robust
Check that the current handshake is using an FT AKM and that the
target BSS AKM suites contain an FT AKM.
2021-05-12 18:04:30 -05:00
James Prestwood 9a3639f2fa ie: use bitwise compare for IE_AKM_IS_FT
This has the same effect when passing a single AKM value, but also
handles AKM bit fields (e.g. ie_rsn_info->akm_suites)
2021-05-12 18:04:30 -05:00
James Prestwood e5fcc93a9e netdev: remove callback/userdata/timeout from FT-over-DS action
Since netdev maintains the list of FT over DS info structs there is not
any need for station to get callbacks when the initial action frame
is received, or not. This removes the need for the callback handler,
user data, and response timeout.
2021-05-12 18:04:30 -05:00
James Prestwood 7385e2c90e station: send FT-over-DS actions upon connection
Roam times can be slightly improved by sending out the FT-over-DS
action frames to any BSS in the mobility domain immediately after
connecting. This preauthenticates IWD to each AP which means
Reassociation can happen right away when a roam is needed.

When a roam is needed station_transition_start will first try
FT-over-DS (if supported) via netdev_fast_transtion_over_ds. The
return is checked and if netdev has no cached entries FT-over-Air
will be used instead.
2021-05-12 18:04:30 -05:00
James Prestwood 78fe1cc0ef network: add network_bss_list_get_entries
Gets the first l_queue_entry in the networks BSS list. Useful
for iterating only a given networks BSS's outside of network.c.
2021-05-12 18:04:30 -05:00
James Prestwood 9b7d761db5 netdev: handle multiple concurrent FT-over-DS action frames
The beauty of FT-over-DS is that a station can send and receive
action frames to many APs to prepare for a future roam. Each
AP authenticates the station and when a roam happens the station
can immediately move to reassociation.

To handle this a queue of netdev_ft_over_ds_info structs is used
instead of a single entry. Using the new ft.c parser APIs these
info structs can be looked up when responses come in. For now
the timeouts/callbacks are kept but these will be removed as it
really does not matter if the AP sends a response (keeps station
happy until the next patch).
2021-05-12 18:04:30 -05:00
James Prestwood ff333a112b ft: break up FT action parsing into two steps
This is to prepare for multiple concurrent FT-over-DS action frames.
A list will be kept in netdev and for lookup reasons it needs to
parse the start of the frame to grab the aa/spa addresses. In this
call the IEs are also returned and passed to the new
ft_over_ds_parse_action_response.

For now the address checks have been moved into netdev, but this will
eventually turn into a queue lookup.
2021-05-12 18:04:30 -05:00