Commit Graph

2961 Commits

Author SHA1 Message Date
James Prestwood 7b2ce98abd station: fix leak on parse_neighbor_report 2021-01-29 17:22:20 -06:00
James Prestwood 9f33740d41 ap: fix off by one error
The RSN element was not being allocated properly which caused
an invalid read in some cases.
2021-01-29 15:04:10 -06:00
Denis Kenzior ed0f3e87ca netdev: Fix re-entrancy bug in netdev_shutdown
netdev_shutdown calls queue_destroy on the netdev_list, which in turn
calls netdev_free.  netdev_free invokes the watches to notify them about
the netdev being removed.  Those clients, or anything downstream can
still invoke netdev_find.  Unfortunately queue_destroy is not re-entrant
safe, so netdev_find might return stale data.  Fix that by using
l_queue_peek_head / l_queue_pop_head instead.

src/station.c:station_enter_state() Old State: connecting, new state:
connected
^CTerminate
src/netdev.c:netdev_free() Freeing netdev wlan1[6]
src/device.c:device_free()
Removing scan context for wdev 100000001
src/scan.c:scan_context_free() sc: 0x4ae9ca0
src/netdev.c:netdev_free() Freeing netdev wlan0[48]
src/device.c:device_free()
src/station.c:station_free()
src/netconfig.c:netconfig_destroy()
==103174== Invalid read of size 8
==103174==    at 0x467AA9: l_queue_find (queue.c:346)
==103174==    by 0x43ACFF: netconfig_reset (netconfig.c:1027)
==103174==    by 0x43AFFC: netconfig_destroy (netconfig.c:1123)
==103174==    by 0x414379: station_free (station.c:3369)
==103174==    by 0x414379: station_destroy_interface (station.c:3466)
==103174==    by 0x47C80C: interface_instance_free (dbus-service.c:510)
==103174==    by 0x47C80C: _dbus_object_tree_remove_interface
(dbus-service.c:1694)
==103174==    by 0x47C99C: _dbus_object_tree_object_destroy
(dbus-service.c:795)
==103174==    by 0x409A87: netdev_free (netdev.c:770)
==103174==    by 0x4677AE: l_queue_clear (queue.c:107)
==103174==    by 0x4677F8: l_queue_destroy (queue.c:82)
==103174==    by 0x40CDC1: netdev_shutdown (netdev.c:5089)
==103174==    by 0x404736: iwd_shutdown (main.c:78)
==103174==    by 0x404736: iwd_shutdown (main.c:65)
==103174==    by 0x46BD61: handle_callback (signal.c:78)
==103174==    by 0x46BD61: signalfd_read_cb (signal.c:104)
2021-01-29 15:02:19 -06:00
Denis Kenzior bd6d19e084 netdev: Squash memory leak on module_init failure
In the case of module_init failing due to a module that comes after
netdev, the netdev module doesn't clean up netdev_list properly.

==6254== 24 bytes in 1 blocks are still reachable in loss record 1 of 1
==6254==    at 0x483777F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==6254==    by 0x4675ED: l_malloc (util.c:61)
==6254==    by 0x46909D: l_queue_new (queue.c:63)
==6254==    by 0x406AE4: netdev_init (netdev.c:5038)
==6254==    by 0x44A7B3: iwd_modules_init (module.c:152)
==6254==    by 0x404713: nl80211_appeared (main.c:171)
==6254==    by 0x4713DE: process_unicast (genl.c:993)
==6254==    by 0x4713DE: received_data (genl.c:1101)
==6254==    by 0x46E00B: io_callback (io.c:118)
==6254==    by 0x46D20C: l_main_iterate (main.c:477)
==6254==    by 0x46D2DB: l_main_run (main.c:524)
==6254==    by 0x46D2DB: l_main_run (main.c:506)
==6254==    by 0x46D502: l_main_run_with_signal (main.c:656)
==6254==    by 0x403EDB: main (main.c:490)
2021-01-29 13:39:20 -06:00
James Prestwood aefcaf8559 ap: handle GET_KEY error setting RSC to zero
Rather than the previous hack which disabled group traffic it
was found that the GTK RSC could be manually set to zero which
allows group traffic. This appears to fix AP mode on brcmfmac
along with the previous fixes. This is not documented in
nl80211, but appears to work with this driver.
2021-01-29 13:15:36 -06:00
James Prestwood 4635e095ba ap: rename ap_parse_ie to be more descriptive
This is only used for NEW_STATION parsing so name appropriately
2021-01-29 13:15:24 -06:00
James Prestwood 32028f6daf ap: add DEL_STATION path to fullmac AP handling
This is how a fullmac card tells userspace that a station has
left. This fixes the issue where the same client cannot re-connect
to the same AP multiple times. ap_new_station was renamed to
ap_handle_new_station for consistency.
2021-01-29 11:36:09 -06:00
James Prestwood 7429b2162d ap: allow no group traffic on GET_KEY error
Some fullmac cards were found to be buggy with getting the GTK
where it returns a BIP key for the GTK index, even after creating
a GTK with NEW_KEY explicitly. In an effort to get these cards
semi-working we can treat this just as a warning and continue with
the handshake without a GTK set which disables group traffic. A
warning is printed in this case so the user is not completely in
the dark.
2021-01-28 13:41:43 -06:00
Alvin Šipraga a04b61ec77 netdev: preserve cur_rssi_low across reassociation
Fix an issue with the recent changes to signal monitoring from commit
f456501b ("station: retry roaming unless notified of a high RSSI"):

    1. driver sends NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW
    2. netdev->cur_rssi_low changes from FALSE to TRUE
    3. netdev sends NETDEV_EVENT_RSSI_THRESHOLD_LOW to station
    4. on roam reassociation, cur_rssi_low is reset to FALSE
    5. station still assumes RSSI is low, periodically roams
       until netdev sends NETDEV_EVENT_RSSI_THRESHOLD_HIGH
    6. driver sends NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH
    7. netdev->cur_rssi_low doesn't change (still FALSE)
    8. netdev never sends NETDEV_EVENT_RSSI_THRESHOLD_HIGH
    9. station remains stuck in an infinite roaming loop

The commit in question introduced the logic in (5). Previously the
assumption in station was - like in netdev - that if the signal was
still low, the driver would send a duplicate LOW event after
reassociation. This change makes netdev follow the same new logic as
station, i.e. assume the same signal state (LOW/HIGH) until told
otherwise by the driver.
2021-01-28 13:40:10 -06:00
James Prestwood 63c8df78a3 ap: handle NEW_STATION for fullmac cards
Since fullmac cards handle auth/assoc in firmware IWD must
react differently while in AP mode just as it does in station.
For fullmac cards a NEW_STATION event is emitted post association
and from here the 4-way handshake can begin. In this NEW_STATION
handler a new sta_state is created and the needed members are
set in order to inject us back into the normal code execution
for softmac post association (i.e. creating group keys and
starting the 4-way handshake). From here everything works the
same as softmac.
2021-01-28 13:25:18 -06:00
Denis Kenzior 6db352a82d manager: UseDefaultInterface for bcmsdh_sdmmc
This driver is used on some ARM based devices
2021-01-27 09:58:34 -06:00
Andrew Zaborowski 6f62056fcf eap-tls: Use the right variable in settings check 2021-01-27 09:52:47 -06:00
James Prestwood a9c32d85ea station: cancel quick scans on Connect()
At some point the non-interactive client tests began failing.
This was due to a bug in station where it would transition from
'connected' to 'autoconnect' due to a failed scan request. This
happened because a quick scan got scheduled during an ongoing
scan, then a Connect() gets issued. The work queue treats the
Connect as a priority so it delays the quick scan until after the
connection succeeds. This results in a failed quick scan which
IWD does not expect to happen when in a 'connected' state. This
failed scan actually triggers a state transition which then
gets IWD into a strange state where its connected from the
kernel point of view but does not think it is:

src/station.c:station_connect_cb() 13, result: 0
src/station.c:station_enter_state() Old State: connecting, new state: connected
src/wiphy.c:wiphy_radio_work_done() Work item 6 done
src/wiphy.c:wiphy_radio_work_next() Starting work item 5
src/station.c:station_quick_scan_triggered() Quick scan trigger failed: -95
src/station.c:station_enter_state() Old State: connected, new state: autoconnect_full

To fix this IWD should simply cancel any pending quick scans
if/when a Connect() call comes in.
2021-01-26 14:45:00 -06:00
Andrew Zaborowski 5c95c5cc16 netconfig: Set more correct buffer length
Use INET_ADDRSTRLEN as the IPv4 address buffer size to avoid confusion.
2021-01-25 14:01:58 -06:00
Andrew Zaborowski 54e3bb385a doc: Specify the DNS format as string lists 2021-01-25 14:01:58 -06:00
Andrew Zaborowski d6e99c1197 doc: Update EAP-TLS client key setting information 2021-01-25 14:01:58 -06:00
Andrew Zaborowski 84cae48c1b eap-tls: Make use of l_cert_load_container_file
Switch EAP-TLS-ClientCert and EAP-TLS-ClientKey to use
l_cert_load_container_file for file loading so that the file format is
autodetected.  Add new setting EAP-TLS-ClientKeyBundle for loading both
the client certificate and private key from one file.
2021-01-25 14:01:58 -06:00
Andrew Zaborowski b0aa1e4e88 eap-tls: Drop EAP-{TTLS,PEAP}-Client{Cert,Key}
As requested move the client certificate and private key loading from
eap-tls-common.c to eap-tls.c.  No man page change needed because those
two settings weren't documented in it in the first place.
2021-01-25 14:01:58 -06:00
James Prestwood 9c33572aee ap: add AP diagnostic interface
This adds a new AccessPointDiagnostic interface. This interface
provides similar low level functionality as StationDiagnostic, but
for when IWD is in AP mode. This uses netdev_get_all_stations
which will dump all stations, parse, and return each station in
an individual callback. Once the dump is complete the destroy is
called and all data is packaged as an array of dictionaries.
2021-01-22 15:00:48 -06:00
James Prestwood 158dc40340 station: refactor to use diagnostic_info_to_dict 2021-01-22 14:59:47 -06:00
James Prestwood b5d927ec3b diagnostic: commonize the building of diagnostic dict
AP mode will use the same structure for its diagnostic interface
and mostly the same dictionary keys. Apart from ConnectedBss and
Address being different, the remainder are the same so the
diagnostic_station_info to DBus dictionary conversion has been made
common so both station and AP can use it to build its diagnostic
dictionaries.
2021-01-22 14:41:20 -06:00
James Prestwood 5a6b474a14 netdev: move netdev_station_info to diagnostic.h
With AP now getting its own diagnostic interface it made sense
to move the netdev_station_info struct definition into its own
header which eventually can be accompanied by utilities in
diagnostic.c. These utilities can then be shared with AP and
station as needed.
2021-01-22 14:40:45 -06:00
Alvin Šipraga e03b1e263d build: add After=network-pre.target to service files
systemd specifies a special passive target unit 'network-pre.target'
which may be pulled in by services that want to run before any network
interface is brought up or configured. Correspondingly, network
management services such as iwd and ead should specify
After=network-pre.target to ensure a proper ordering with respect to
this special target. For more information on network-pre.target, see
systemd.special(7).

Two examples to explain the rationale of this change:

1. On one of our embedded systems running iwd, a oneshot service is
   run on startup to configure - among other things - the MAC address of
   the wireless network interface based on some data in an EEPROM.
   Following the systemd documentation, the oneshot service specifies:

        Before=network-pre.target
        Wants=network-pre.target

   ... to ensure that it is run before any network management software
   starts. In practice, before this change, iwd was starting up and
   connecting to an AP before the service had finished. iwd would then
   get kicked off by the AP when the MAC address got changed. By
   specifying After=network-pre.target, systemd will take care to avoid
   this situation.

2. An administrator may wish to use network-pre.target to ensure
   firewall rules are applied before any network management software is
   started. This use-case is described in the systemd documentation[1].
   Since iwd can be used for IP configuration, it should also respect
   the After=network-pre.target convention.

Note that network-pre.target is a passive unit that is only pulled in if
another unit specifies e.g. Wants=network-pre.target. If no such unit
exists, this change will have no effect on the order in which systemd
starts iwd or ead.

[1] https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
2021-01-22 14:17:16 -06:00
Alvin Šipraga 947d7c611b doc: describe RoamRetryInterval setting 2021-01-22 13:48:02 -06:00
Alvin Šipraga 4266b88658 station: add RoamRetryInterval setting 2021-01-22 13:46:25 -06:00
Alvin Šipraga f456501b9e station: retry roaming unless notified of a high RSSI
Following a successful roaming sequence, schedule another attempt unless
the driver has sent a high RSSI notification. This makes the behaviour
analogous to a failed roaming attempt where we remained connected to the
same BSS.

This makes iwd compatible with wireless drivers which do not necessarily
send out a duplicate low RSSI notification upon reassociation. Without
this change, iwd risks getting indefinitely stuck to a BSS with low
signal strength, even though a better BSS might later become available.

In the case of a high RSSI notification, the minimum roam time will also
be reset to zero. This preserves the original behaviour in the case
where a high RSSI notification is processed after station_roamed().
Doing so also gives a chance for faster roaming action in the following
example scenario:

    1. RSSI LOW
    2. schedule roam in 5 seconds
        (5 seconds pass)
    3. try roaming
    4. roaming fails, same BSS
    5. schedule roam in 60 seconds
        (20 seconds pass)
    6. RSSI HIGH
    7. cancel scheduled roam
        (20 seconds pass)
    8. RSSI LOW
    9. schedule roam in 5 seconds or 20 seconds?

By resetting the minimum roam time, we can avoid waiting 20 seconds when
the station may have moved considerably. And since the high/low RSSI
notifications are configured with a hysteresis, we should still be
protected against too frequent spurious roaming attempts.
2021-01-22 13:41:07 -06:00
James Prestwood 8e03d56688 netdev: add netdev_get_all_stations
This is a nl80211 dump version of netdev_get_station aimed at
AP mode. This will dump all stations, parse into
netdev_station_info structs, and call the callback for each
individual station found. Once the dump is completed the destroy
callback is called.
2021-01-20 14:01:15 -06:00
James Prestwood 8620698b66 dbus: add AccessPointDiagnostic interface 2021-01-20 14:01:10 -06:00
Alvin Šipraga 9edd941bc2 station: remove unused roam_no_orig_ap state variable
Since commit 836beb1276 removed beacon
loss handling, the roam_no_orig_ap variable has no use and is always set
to false. This commit removes it.
2021-01-20 11:14:06 -06:00
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
Andrew Zaborowski 758dba214e station: Make Disconnect() cancel ConnectHiddenNetwork()
ConnectHiddenNetwork can be seen a triggering this sequence:
1. the active scan,
2. the optional agent request,
3. the Authentication/Association/4-Way Handshake/netconfig,
4. connected state

Currently Disconnect() interrupts 3 and 4, allow it to also interrupt
state 1.  It's difficult to tell whether we're in state 2 from within
station.c.
2020-10-08 08:54:01 -05:00
Andrew Zaborowski d5c7b47745 p2p: Respond to Probe Requests when in discovery
Since our DBus API and our use cases only support initiating connections
and not accepting incoming connections we don't really need to reply to
Probe Requests on the P2P-Device interface.  Start doing it firstly so
that we can test the scenario where we get discovered and pre-authorized
to connect in an autotest (wpa_supplicant doesn't seem to have a way to
authorize everyone, which is probably why most Wi-Fi Display dongles
don't do it and instead reply with "Fail: Information not available" and
then restart connection from their side) and secondly because the spec
wants us to do it.
2020-09-29 13:14:28 -05:00
Andrew Zaborowski ef902c5f7e p2p: Fix adding peers from Probe Request info
Make sure dev->peer_list is non-NULL before using l_queue_push_tail()
same as we do when the peer info comes from a Probe Response (active
scan in Find Phase).  Otherwise peers discovered through Probe Requests
before any Probe Responses are received will be lost.
2020-09-29 13:14:12 -05:00
Andrew Zaborowski 520ad56f83 scan: Drop unused frequency list parsing 2020-09-29 13:14:06 -05:00
Andrew Zaborowski 975696c5e0 wscutil: Fix subcategory string lookup
The device type category array is indexed by the category ID so if we're
skipping i == 0 in the iteration, we should also skip the 0'th element
in device_type_categories.
2020-09-29 13:11:07 -05:00
Andrew Zaborowski fab764967b frame-xchg: Cancel NL80211_CMD_FRAME commands when interrupted
The callback for the FRAME command was causing a crash in
wiphy_radio_work_done when not cancelled when the wiphy was being
removed from the system.  This was likely to happen if this radio work
item was waiting for another item to finish.  When the first one was
being cancelled due to the wiphy being removed, this one would be
started and immediately stopped by the radio work queue.

Now this crash could be fixed by dropping all frame exchange instances
on an interface that is being removed which is easy to do, but properly
cancelling the commands saves us the headache of analysing whether
there's a race condition in other situations where a frame exchange is
being aborted.
2020-09-29 13:10:23 -05:00
Andrew Zaborowski 3de345e903 frame-xchg: Add no-cck-rate flag only for P2P interfaces
We want to use this flag only on the interfaces with one of the three
P2P iftypes so set the flag automatically depending on the iftype from
the last 'config' notification.
2020-09-29 13:09:05 -05:00
Andrew Zaborowski c51e187462 ap: Use frame-xchg when sending frames
Convert ap_send_mgmt_frame() to use frame_xchg_start for sending frames,
this fixes among other things the ACK-received checks.

One side effect is that we're no longer sending Probe Responses with the
don't-wait-for-ack flag because frame-xchg doesn't support it, but other
AP implementations don't use that flag either.

Another side-effect is that we do use the no-cck-rate flag
unconditionally, something we may want to fix but would need to add
another parameter to frame-xchg.
2020-09-21 22:13:38 -05:00
Andrew Zaborowski 311e91b944 p2p: Free response frame payloads 2020-09-21 22:13:32 -05:00
Andrew Zaborowski c58b91dfd4 p2p: Free parsed frame data in p2p_go_negotiation_confirm_cb 2020-09-21 22:13:24 -05:00
Andrew Zaborowski 47596c67d3 p2p: Free peer->wfd in p2p_peer_free 2020-09-21 22:13:21 -05:00
Andrew Zaborowski ee4e1368d2 p2p: Try IP allocation during 4-Way handshake on client 2020-09-16 17:25:44 -05:00
Andrew Zaborowski 68cb9d38bf p2p: Start a basic P2P Group after GO Negotiation
Use the ap.c API to start an AP on a P2P_GO interface after we've been
selected as the GO in the GO Negotiation.
2020-09-16 17:25:44 -05:00
Andrew Zaborowski 185b676f31 ap: Rename wpa2_psk to wpa2_passphrase on DBus
Use the passphrase naming instead of PSK.
2020-09-16 17:25:44 -05:00
Andrew Zaborowski fbe7e0bd36 ap: Support working without passphrase
Add a "psk" setting to allow the user to pass the binary PSK directly
instead of generating it from the passphrase and the SSID.  In that case
we'll only send the PSK to WSC enrollees.
2020-09-16 17:25:44 -05:00
Andrew Zaborowski 1f68696578 ap: Pass "ops" struct to ap_start()
Pass the event callback function pointer in a "struct ap_ops" instead of
as individual ap_start() argument to make adding new callbacks easier.
2020-09-16 17:25:34 -05:00
Andrew Zaborowski 8e9a2fe05d treewide: Use l_settings_{set,get}_bytes 2020-09-16 16:46:02 -05:00
James Prestwood 18531a524f plugin: remove plugin source 2020-09-16 14:31:21 -05:00
James Prestwood 83a9de58c2 ofono: convert to module 2020-09-16 14:31:07 -05:00
James Prestwood bbcfde8743 plugins: remove dependency on ELL plugins
There has been a desire to remove the ELL plugin dependency from
IWD which is the only consumer of the plugin API. This removes
the dependency and prepares the tree for converting the existing
ofono plugin into a regular module.

sim_hardcoded was removed completely. This was originall implemented
before full ofono support purely to test the IWD side of EAP-SIM/AKA.
Since the ofono plugin (module-to-be) is now fully implemented there
really isn't a need for sim_hardcoded.
2020-09-16 14:30:14 -05:00
James Prestwood 2a8d7d4835 adhoc: delay setting Started
The Started property was being set in the Join IBSS callback which
isn't really when the IBSS has been started. The kernel automatically
scans for IBSS networks which takes some time. Its better to wait
on setting Started until we get the Join IBSS event.
2020-09-14 16:44:53 -05:00