Commit Graph

2882 Commits

Author SHA1 Message Date
James Prestwood a17e5e0f7f station: create StationDiagnostic interface
This interface sits aside the regular station interface but
provides low level connection details for diagnostic and
testing purposes.
2021-01-14 15:02:13 -06:00
James Prestwood 93b5a5a4ae netdev: parse expected throughput in netdev_get_station 2021-01-14 14:58:33 -06:00
James Prestwood 0ba73ec139 netdev: parse rates in netdev_get_station 2021-01-14 14:57:19 -06:00
James Prestwood 08de8186c6 netdev: update RSSI polling to use station info parser 2021-01-12 13:39:14 -06:00
James Prestwood cf17d42972 netdev: add netdev_get_station/current_station
This adds a generalized API for GET_STATION. This API handles
calling and parsing the results into a new structure,
netdev_station_info. This results structure will hold any
data needed by consumers of netdev_get_station. A helper API
(netdev_get_current_station) was added as a convenience which
automatically passes handshake->aa as the MAC.

For now only the RSSI is parsed as this is already being
done for RSSI polling/events. Looking further more info will
be added such as rx/tx rates and estimated throughput.
2021-01-12 13:39:07 -06:00
James Prestwood 09b124f073 dbus: add helper for appending a dictionary
Arrays of dictionaries are quite common, and for basic
types this API makes things much more convenient by
putting all the enter/append/leave calls in one place.
2021-01-12 13:19:38 -06:00
James Prestwood 668b61ff3a dbus: add diagnostic interface definition 2021-01-11 14:51:48 -06:00
Andrew Zaborowski 9ef3d51f87 crypto: Update l_pkcs5_pbkdf2 call after rename 2021-01-07 14:05:40 -06:00
Andrew Zaborowski 047b0e71a1 eap-tls: Dump server certificate when IWD_TLS_DEBUG set 2021-01-04 12:17:00 -06:00
Carlo Abelli d3606cd255 doc: move EnableIPv6 under Network
The EnableIPv6 option is incorrectly documented under General but should
be documented under Network instead.
2020-12-22 09:35:48 -06:00
Andrew Zaborowski f5a30a1cfc station: Don't expire BSSes between freq subset scans
Add a parameter to station_set_scan_results to allow skipping the
removal of old BSSes.  In the DBus-triggered scan only expire BSSes
after having gone through the full supported frequency set.

It should be safe to pass partial scan results to
station_set_scan_results() when not expiring BSSes so using this new
parameter I guess we could also call it for roam scan results.
2020-12-17 20:22:47 -06:00
Andrew Zaborowski e3bece76f9 station: Split DBus scans into 3 frequency subsets
A scan normally takes about 2 seconds on my dual-band wifi adapter when
connected.  The drivers will normally probe on each supported channel in
some unspecified order and will have new partial results after each step
but the kernel sends NL80211_CMD_NEW_SCAN_RESULTS only when the full
scan request finishes, and for segmented scans we will wait for all
segments to finish before calling back from scan_active() or
scan_passive().

To improve user experience define our own channel order favouring the
2.4 channels 1, 6 and 11 and probe those as an individual scan request
so we can update most our DBus org.connman.iwd.Network objects more
quickly, before continuing with 5GHz band channels, updating DBus
objects again and finally the other 2.4GHz band channels.

The overall DBus-triggered scan on my wifi adapter takes about the same
time but my measurements were not very strict, and were not very
consistent with and without this change.  With the change most Network
objects are updated after about 200ms though, meaning that I get most
of the network updates in the nm-applet UI 200ms from opening the
network list.  The 5GHz band channels take another 1 to 1.5s to scan and
remaining 2.4GHz band channels another ~300ms.

Hopefully this is similar when using other drivers although I can easily
imagine a driver that parallelizes 2.4GHz and 5GHz channel probing using
two radios, or uses 2, 4 or another number of dual-band radios to probe
2, 4, ... channels simultanously.  We'd then lose some of the
performance benefit.  The faster scan results may be worth the longer
overall scan time anyway.
I'm also assuming that the wiphy's supported frequency list is exactly
what was scanned when we passed no frequency list to
NL80211_CMD_TRIGGER_SCAN and we won't get errors for passing some
frequency that shouldn't have been scanned.
2020-12-17 20:15:37 -06:00
James Prestwood f39d1b4ac2 netconfig: add ACD client for static configuration
When the IP is configured to be static we can now use ACD in
order to check that the IP is available and not already in
use. If a conflict is found netconfig will be reset and no IP
will be set on the interface. The ACD client is left with
the default 'defend once' policy, and probes are not turned
off. This will increase connection time, but for static IP's
it is the best approach.
2020-12-08 16:29:09 -06:00
James Prestwood 4353110684 doc: use real example for APRanges
The docs just specified what a IP prefix looks like, not an
actual example. Though its not recommended to just copy paste
blindly, its still useful to have some value in the man pages
that actually works if someone just wants to get a DHCP server
working.
2020-12-02 16:12:56 -06:00
Denis Kenzior 278abc66be netconfig: Also set the domains obtained from IPv6 2020-12-02 10:55:05 -06:00
Denis Kenzior 967b7e75e3 resolve: Handle empty dns/domain lists
In the strange case that the dns list or the domain list are empty and
openresolv is being used, delete the openresolv entry instance instead
of trying to set it to an empty value
2020-12-02 10:55:05 -06:00
Alvin Šipraga b647f8e1f0 network: clear info of removed known network before disconnect
Make sure to erase the network_info of a known network that has been
removed before disconnecting any stations connected to it. This fixes
the following warning observed when forgetting a connected network:

  WARNING: ../git/src/network.c:network_rank_update() condition n < 0 failed

This also fixes a bug where such a forgotten network would incorrectly
appear as the first element in the response to GetOrderedNetworks().  By
clearing the network_info, network_rank_update() properly negates the
rank of the now-unknown network.
2020-12-01 09:54:52 -06:00
James Prestwood ccf265b943 netconfig: fix freeing invalid pointer
If l_rtnl_ifaddr4_extract does not set the values they would
get freed. Instead initialize to NULL so the cleanup free is
a no op.
2020-11-23 23:29:54 -06:00
Denis Kenzior ebc42ccecf netconfig: Don't re-create address on RENEWAL
==5279== 104 bytes in 2 blocks are definitely lost in loss record 1 of 1
==5279==    at 0x4C2F0CF: malloc (vg_replace_malloc.c:299)
==5279==    by 0x4655CD: l_malloc (util.c:61)
==5279==    by 0x47116B: l_rtnl_address_new (rtnl.c:136)
==5279==    by 0x438F4B: netconfig_get_dhcp4_address (netconfig.c:429)
==5279==    by 0x438F4B: netconfig_ipv4_dhcp_event_handler
(netconfig.c:735)
==5279==    by 0x491C77: dhcp_client_event_notify (dhcp.c:332)
==5279==    by 0x491C77: dhcp_client_rx_message (dhcp.c:810)
==5279==    by 0x492A88: _dhcp_default_transport_read_handler
(dhcp-transport.c:151)
==5279==    by 0x46BECB: io_callback (io.c:118)
==5279==    by 0x46B10C: l_main_iterate (main.c:477)
==5279==    by 0x46B1DB: l_main_run (main.c:524)
==5279==    by 0x46B3EA: l_main_run_with_signal (main.c:646)
==5279==    by 0x403ECE: main (main.c:490)
2020-11-23 14:59:20 -06:00
Andrew Zaborowski 7c7831b53d doc: Update iwd.network.5 with changes from wiki
Fix the AlwaysRandomizeAddress setting name.

Add the stricter specification of the extension syntax.

Clarify that GTC and MD5 can't be used as outer EAP methods with wifi.
2020-11-19 14:21:42 -06:00
Denis Kenzior 69e86f4d21 netconfig: Remove tracking of addresses
Tracking of addresses that weren't set by us seemed a bit questionable.
Take this out for now.  If this is ever needed, then a queue with
l_rtnl_address objects should be used.
2020-11-19 14:19:17 -06:00
Denis Kenzior 6f5ec005e9 netconfig: Rework IPv4 address handling
Introduce a new v4_address member which will hold the currently
configured IPV4 address (static or obtained via DHCP).  Use the new
l_rtnl_address class for this.

As a side-effect, lease expiration will now properly remove the
configured address.
2020-11-19 14:19:13 -06:00
Denis Kenzior eb151efc81 netconfig: Rework static IPv6 address handling
This patch converts the code to use the new l_rtnl_address class.  The
settings parsing code will now return an l_rtnl_address object which
can be installed directly.

Also, address removal path for static addresses has been removed, since
netconfig_reset() sets disable_ipv6 setting to '1', which will remove
all IPV6 addresses for the interface.
2020-11-19 13:28:38 -06:00
Denis Kenzior b6cf9ef866 netconfig: Rework static IPv6 route handling
This patch converts the code to use the new l_rtnl_route class instead
of using l_rtnl_route6* utilities.  The settings parsing code will now
return an l_rtnl_route object which can be installed directly.

Also, the route removal path has been removed since netconfig_reset()
sets disable_ipv6 setting to '1' which will remove all IPV6 routes and
addresses for the interface.
2020-11-19 13:08:51 -06:00
Denis Kenzior 3890431090 netconfig: Install search domains obtained from DHCPv6 2020-11-18 12:00:17 -06:00
Denis Kenzior dcaf0150b9 netconfig: Re-start DHCPv6 client
If lease expired or was not obtained initially, re-start the DHCPv6
client.
2020-11-18 10:39:29 -06:00
Denis Kenzior c46a5d7c84 netconfig: Install DNS addresses obtained from DHCPv6
This also changes the resolve API a little bit to act as a 'set' API
instead of an incremental 'add' API.  This is actually easier to manage
in the resolve module since both systemd and resolvconf want changes
wholesale and not incrementally.
2020-11-18 10:39:16 -06:00
James Prestwood 845658bd32 station: get neighbor reports early
Waiting to request neighbor reports until we are in need of a roam
delays the roam time, and probably isn't as reliable since we are
most likely in a low RSSI state. Instead the neighbor report can
be requested immediately after connecting, saved, and used if/when
a roam is needed. The existing behavior is maintained if the early
neighbor report fails where a neighbor report is requested at the
time of the roam.

The code which parses the reports was factored out and shared
between the existing (late) neighbor report callback and the early
neighbor report callback.
2020-11-16 18:14:07 -06:00
James Prestwood fedfda9fb5 simauth: check driver for NULL before canceling request
If the ofono modem got removed before it was fully initialized this
could cause a crash.
2020-11-16 17:04:30 -06:00
Denis Kenzior 95df3e660b doc: Describe EnableIPv6 setting 2020-11-16 16:14:03 -06:00
Denis Kenzior 6f893dbc31 doc: Document IPv6 related network settings 2020-11-16 16:02:24 -06:00
Denis Kenzior 53c9a692fa netconfig: Add configs for controlling IPV6 support 2020-11-16 16:02:24 -06:00
Jonathan Liu 5e9f1a6806 ap: Fix handshake state gtk not being set
handshake_state_set_authenticator_ie must be called to set group_cipher
in struct handshake_shake before handshake_set_gtk_state, otherwise
handshake_set_gtk_state is unable to determine the key length to set
handshake state gtk.

Fixes: 4bc20a0979 ("ap: Start EAP-WSC authentication with WSC enrollees")
2020-11-16 13:35:51 -06:00
Denis Kenzior bb876953ac netconfig: Start RA & DHCPv6 clients
For now the RA client is ran automatically when DHCPv6 client starts.
RA takes care of installing / deleting prefix routes and installing the
default gateway.  If Router Advertisements indicate support DHCPv6, then
DHCPv6 transactions are kicked off and the address is set / removed
automatically.

Stateless configuration is not yet supported.
2020-11-12 15:36:56 -06:00
James Prestwood 1106514a38 netdev: remove handling of beacon loss event 2020-11-04 13:40:52 -06:00
James Prestwood 836beb1276 station/wsc: remove beacon loss handling
Modern kernels ~5.4+ have changed the way lost beacons are
reported and effectively make the lost beacon event useless
because it is immediately followed by a disconnect event. This
does not allow IWD enough time to do much of anything before
the disconnect comes in and we are forced to fully re-connect
to a different AP.
2020-11-04 13:40:25 -06:00
James Prestwood 32db13aef8 doc: document DHCP server options in AP profiles 2020-11-04 13:38:35 -06:00
James Prestwood 946a67502b doc: add APRanges documentation 2020-11-04 13:37:55 -06:00
James Prestwood 39ca2c3e05 doc: add man pages for AP provisioning files 2020-11-04 13:37:18 -06:00
James Prestwood acb31477c1 ap: make APRanges optional
If EnableNetworkConfiguration was enabled ap.c required that
APRanges also be set. This prevents IWD from starting which
effects a perfectly valid station configuration. Instead if
APRanges is not provided IWD still allows ap_init to pass but
DHCP just will not be enabled.
2020-11-03 13:58:23 -06:00
James Prestwood 5420fdaf01 ap: fixup incorrect return
If an RTNL address change fails -EIO should be returned, not
false (aka "success").
2020-11-02 14:23:53 -06:00
James Prestwood e1b3e73c2b ap: allow DHCP settings in provisioning files
Users can now supply an AP provisioning file containing an [IPv4]
section and define various DHCP settings:

[IPv4]
Address=<address>
Netmask=<netmask>
Gateway=<gateway>
IPRange=<start_address>,<end_address>
DNSList=<dns1>,<dns2>,...<dnsN>
LeaseTime=<lease_time>

There are a few notes/requirements to keep in mind when using a
provisioning file:

 - All settings are optional but [IPv4].Address is required if the
   interface does not already have an address set.
 - If no [IPv4].Address is defined in the provisioning file and the AP
   interface does not already have an address set, StartWithConfig()
   will fail with -EINVAL.
 - If a provisioning file is provided it will take precedence, and the
   AP will not pull from the IP pool.
 - A provisioning file containing an IPv4 section assumes DHCP is being
   enabled and will override [General].EnableNetworkConfiguration.
 - Any address that AP sets on the interface will be deleted when the AP
   is stopped.
2020-11-02 13:47:24 -06:00
James Prestwood 5153b88cbe ap: add StartProfile DBus method
Users can now start an AP from settings based on a profile
on disk. The only argument is the SSID which will be used to
lookup the profile. If no profile is found a NotFound error
will be returned. Any invalid profiles will result in an
Invalid return.
2020-11-02 13:39:25 -06:00
James Prestwood c0149f1106 frame-xchg: fix invalid read
This seems to happen occationally with testAP (potentially others).
The invalid read appears to happen when the frame_xchg_tx_cb detects
an early status and no ACK. In this particular case there is no
retry interval so we reach the retry limit and 'done' the frame.
This frees the 'fx' data all before the destroy callback can get
called. Once we finally return and the destroy callback is called
'fx' is freed and we see the invalid write.

==206== Memcheck, a memory error detector
==206== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==206== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==206== Command: iwd -p rad1,rad2,rad3,rad4 -d
==206== Parent PID: 140
==206==
==206== Invalid write of size 4
==206==    at 0x4493A0: frame_xchg_tx_destroy (frame-xchg.c:941)
==206==    by 0x46DAF6: destroy_request (genl.c:673)
==206==    by 0x46DAF6: process_unicast (genl.c:1002)
==206==    by 0x46DAF6: received_data (genl.c:1101)
==206==    by 0x46AA4B: io_callback (io.c:118)
==206==    by 0x469D6C: l_main_iterate (main.c:477)
==206==    by 0x469E1B: l_main_run (main.c:524)
==206==    by 0x469E1B: l_main_run (main.c:506)
==206==    by 0x46A02B: l_main_run_with_signal (main.c:646)
==206==    by 0x403E78: main (main.c:490)
==206==  Address 0x4c59c6c is 172 bytes inside a block of size 176 free'd
==206==    at 0x483B9F5: free (vg_replace_malloc.c:538)
==206==    by 0x40F14C: destroy_work (wiphy.c:248)
==206==    by 0x40F14C: wiphy_radio_work_done (wiphy.c:1578)
==206==    by 0x44A916: frame_xchg_tx_cb (frame-xchg.c:930)
==206==    by 0x46DAD9: process_unicast (genl.c:993)
==206==    by 0x46DAD9: received_data (genl.c:1101)
==206==    by 0x46AA4B: io_callback (io.c:118)
==206==    by 0x469D6C: l_main_iterate (main.c:477)
==206==    by 0x469E1B: l_main_run (main.c:524)
==206==    by 0x469E1B: l_main_run (main.c:506)
==206==    by 0x46A02B: l_main_run_with_signal (main.c:646)
==206==    by 0x403E78: main (main.c:490)
==206==  Block was alloc'd at
==206==    at 0x483A809: malloc (vg_replace_malloc.c:307)
==206==    by 0x4643CD: l_malloc (util.c:61)
==206==    by 0x44AF8C: frame_xchg_startv (frame-xchg.c:1155)
==206==    by 0x44B2A4: frame_xchg_start (frame-xchg.c:1108)
==206==    by 0x42BC55: ap_send_mgmt_frame (ap.c:709)
==206==    by 0x42F513: ap_probe_req_cb (ap.c:1869)
==206==    by 0x449752: frame_watch_unicast_notify (frame-xchg.c:233)
==206==    by 0x46DA2F: dispatch_unicast_watches (genl.c:961)
==206==    by 0x46DA2F: process_unicast (genl.c:980)
==206==    by 0x46DA2F: received_data (genl.c:1101)
==206==    by 0x46AA4B: io_callback (io.c:118)
==206==    by 0x469D6C: l_main_iterate (main.c:477)
==206==    by 0x469E1B: l_main_run (main.c:524)
==206==    by 0x469E1B: l_main_run (main.c:506)
==206==    by 0x46A02B: l_main_run_with_signal (main.c:646)
==206==
2020-11-02 11:39:03 -06:00
Denis Kenzior 304627e086 scan: Fix crash when a canceled scan gets aborted 2020-10-30 14:06:31 -05:00
James Prestwood 18d1c752f4 ap: add support for DHCPv4 server
The DHCP server can be enabled by enabling network configuration
with [General].EnableNetworkConfiguration. If an IP is not set
on the interface before the AP is started a valid IP range must
also be provided under [General].APRanges in IP prefix format e.g.

[General]
EnableNetworkConfiguration=true
APRanges=192.168.1.1/24

Each AP started will get assigned a new subnet within the range
specified by APRanges as to not conflict with other AP interfaces.
If there are no subnets left in the pool when an AP is started
it will fail with -EEXIST. Any AP's that are stopped will release
their subnet back into the pool to be used with other APs.

The DHCP IP pool will be automatically chosen by the ELL DHCP
implementation (+1 the AP's IP to *.254). The remaining DHCP
settings will be defaults chosen by ELL (DNS, lease time, etc).
2020-10-27 16:19:47 -05:00
James Prestwood 42605c9e76 util: add util_ip_prefix_tohl
Parses an IP prefix notation string into prefix, start, end, and
netmask. All values are returned in host order.
2020-10-26 16:16:12 -05:00
James Prestwood b7e2a98628 ap: add error out param to ap_start
This allows the caller to extract a bit more information about what
exactly went wrong.
2020-10-26 14:30:34 -05:00
Andrew Zaborowski 1f89ebb86a station: Fix .Scanning being reset early
periodic_scan_stop is called whenever we exit the autoscan state but a
periodic scan may not be running at the time.  If we have a
user-triggered scan running, or the autoconnect_quick scan, and we reset
Scanning to false before that scan finished, a client could en up
calling GetOrderedNetwork too early and not receiving the scan results.
2020-10-14 13:01:18 -05:00
Andrew Zaborowski 9815fb38cf network: Check if network busy before new connection
Check if we have an ongoing agent call before starting a new connection
attempt and potentially overwriting network->agent_request.
2020-10-08 10:08:20 -05:00