Commit Graph

4759 Commits

Author SHA1 Message Date
Andrew Zaborowski 2fa3495e74 test: Set WSC.PushButton call timeout to 120s 2020-07-13 14:15:24 -05:00
Andrew Zaborowski ee933c6b58 man iwd.debug: Document IWD_GENL_DEBUG 2020-07-13 14:14:41 -05:00
Andrew Zaborowski c8f4b9d98f p2p: Implement the Peer.Device property
Add the net.connman.iwd.p2p.Peer.Device property as listed in
doc/p2p-peer-api.txt
2020-07-13 14:12:44 -05:00
Andrew Zaborowski a09d7628dd p2p: Use nl80211_parse_attrs
Simplify p2p_device_update_from_genl by making use of nl80211_parse_attrs.
2020-07-13 14:11:07 -05:00
Andrew Zaborowski 09c9482045 p2p: Initialize dev->discovery_users in p2p_device_request_discovery
Make sure dev->discovery_users points at a queue before we try adding
user records to it.
2020-07-13 14:10:44 -05:00
Andrew Zaborowski 7d3092e1ca p2p: Update peer->device_addr when updating peer->bss
peer->device_addr is a pointer to the Device Address contained in
one of two possible places in peer->bss.  If during discovery we've
received a new beacon/probe response for an existing peer and we're
going to replace peer->bss, we also have to update peer->device_addr.
2020-07-13 14:09:42 -05:00
Andrew Zaborowski 122ea7a8aa p2p: Stop discovery after GO Negotiation Req error
If we were in discovery only to be able to receive the target peer's
GO Negotiation Request (i.e. we have no users requesting discovery)
and we've received the frame and decided that the connection has
failed, exit discovery.
2020-07-13 14:08:51 -05:00
James Prestwood 5f7b28d501 scan: refactor to use wiphy radio work queue
To use the wiphy radio work queue, scanning mostly remained the same.
start_next_scan_request was modified to be used as the work callback,
as well as not start the next scan if the current one was done
(since this is taken care of by wiphy work queue now). All
calls to start_next_scan_request were removed, and more or less
replaced with wiphy_radio_work_done.

scan_{suspend,resume} were both removed since radio management
priorities solve this for us. ANQP requests can be inserted ahead of
scan requests, which accomplishes the same thing.
2020-07-10 13:23:58 -05:00
James Prestwood a3d0eebe74 station: cancel hidden network scan when connecting
Before connecting to a hidden network we must scan. During this scan
if another connection attempt comes in the expected behavior is to
abort the original connection. Rather than waiting for the scan to
complete, then canceling the original hidden connection we can just
cancel the hidden scan immediately, reply to dbus, and continue with
the new connection attempt.
2020-07-09 10:00:55 -05:00
James Prestwood 7e0084e6ae anqp: refactor to use frame-xchg
The new frame-xchg module now handles a lot of what ANQP used to do. ANQP
now does not need to depend on nl80211/netdev for building and sending
frames. It also no longer needs any of the request lookups, frame watches
or to maintain a queue of requests because frame-xchg filters this for us.

From an API perspective:
 - anqp_request() was changed to take the wdev_id rather than ifindex.
 - anqp_cancel() was added so that station can properly clean up ANQP
   requests if the device disappears.

During testing a bug was also fixed in station on the timeout path
where the request queue would get popped twice.
2020-07-09 09:58:21 -05:00
James Prestwood 98cf2bf3ec frame-xchg: refactor to use wiphy work queue
In order to first integrate frame-xchg some refactoring needed to
be done. First it is useful to allow queueing frames up rather than
requiring the module (p2p, anqp etc) to wait for the last frame to
finish. This can be aided by radio management but frame-xchg needed
some refactoring as well.

First was getting rid of this fx pointer re-use. It looks like this
was done to save a bit of memory but things get pretty complex
needed to check if the pointer is stale or has been reset. Instead
of this we now just allocate a new pointer each frame-xchg. This
allows for the module to queue multiple requests as well as removes
the complexity of needed to check if the fx pointer is stale.

Next was adding the ability to track frame-xchgs by ID. If a module
can queue up multiple requests it also needs to be able to cancel
them individually vs per-wdev. This comes free with the wiphy work
queue since it returns an ID which can be given directly to the
caller.

Then radio management was simply piped in by adding the
insert/done APIs.
2020-07-09 09:58:16 -05:00
James Prestwood 771f292939 wiphy: introduce new radio management APIs
These APIs will handle fairness and order in any operations which
radios can only do sequentially (offchannel, scanning, connection etc.).

Both scan and frame-xchg are complex modules (especially scanning)
which is why the radio management APIs were implemented generic enough
where the changes to both modules will be minimal. Any module that
requires this kind of work can push a work item into the radio
management work queue (wiphy_radio_work_insert) and when the work
is ready to be started radio management will call back into the module.
Once the work is completed (and this may be some time later e.g. in
scan results or a frame watch) the module can signal back that the
work is finished (wiphy_radio_work_done). Wiphy will then pop the
queue and continue with the next work item.

A concept of priority was added in order to allow important offchannel
operations (e.g. ANQP) to take priority over other work items. The
priority is an integer, where lower values are of a higher priority.
The concept of priority cleanly solves a lot of the complexity that
was added in order to support ANQP queries (suspending scanning and
waiting for ANQP to finish before connecting).

Instead ANQP queries can be queued at a higher priority than scanning
which removes the need for suspending scans. In addition we can treat
connections as radio management work and insert them at a lower
priority than ANQP, but higher than scanning. This forces the
connection to wait for ANQP without having to track any state.
2020-07-09 09:57:13 -05:00
James Prestwood 0fdc3b3ed6 auto-t: remove busy wait for eapol reauth
Many tests force a reauth after the initial connection. When the tests
were written there was no way of ensuring the reauth completed except
waiting (IWD.wait()). Now we can wait for hostapd events in the tests,
which is faster and more reliable than busy waiting.
2020-07-08 18:29:01 -05:00
James Prestwood 38c8fe06a4 auto-t: increase wait time for blacklist test
This test was not reliably passing. Busy waiting is not really reliable,
but in this specific case its really the only option as the blacklist
must expire based on time.
2020-07-08 18:28:58 -05:00
James Prestwood 70824d7b5a wiphy: add convenience API wiphy_find_by_wdev 2020-07-02 17:07:21 -05:00
Denis Kenzior a1b41f786e station: Re-attempt roam with a full scan
When roaming, iwd tries to scan a limited number of frequencies to keep
the roaming latency down.  Ideally the frequency list would come in from
a neighbor report, but if neighbor reports are not supported, we fall
back to our internal database for known frequencies of this network.

iwd tries to keep the number of scans down to a bare minimum, which
means that we might miss APs that are in range.  This could happen
because the user might have moved physically and our frequency list is
no longer up to date, or if the AP frequencies have been reconfigured.

If a limited scan fails to find any good roaming candidates, re-attempt
a full scan right away.
2020-06-30 12:34:41 -05:00
Denis Kenzior b026e6740b station: Return errno from station_roam_scan 2020-06-30 12:29:22 -05:00
Denis Kenzior 10e83aa347 station: Return errno from station_roam_scan_known_freqs 2020-06-30 12:05:51 -05:00
Denis Kenzior 05b803cb76 station: reflow station_roam_failed
If the roam failed and we are no longer connected, station_disassociated
is called which ends up calling station_roam_state_clear.  Thus
resetting the variables is not needed.  Reflow the logic to make this a
bit more explicit.
2020-06-30 10:58:05 -05:00
Denis Kenzior faa31802c5 station: Don't reset roam_no_orig_ap on roam failure
If the roam attempt fails, do not reset this to false.  Generally this
is set by the fact that we lost beacon and to not attempt neighbor
reports, etc.  This hint should be preserved across roam attempts.
2020-06-30 10:23:40 -05:00
Denis Kenzior ec7044d615 main: Do not always return -ENOTSUP
Fixes: 19b0d0f2e2 ("main: Rework kernel option detection logic")
2020-06-23 12:25:18 -05:00
James Prestwood 05ad0120a8 frame-xchg: add destroy function to start() APIs
This makes things more consistent with other IWD APIs as well as
prepares for unifying frame-xchg and scanning.
2020-06-23 10:45:31 -05:00
James Prestwood f7c036a801 test-runner: use WNOHANG option waiting for PID
If an application has a bug and hangs on SIGTERM this causes
test-runner to hang as well. This is obviously an issue with
the application in question, but test-runner should have a way
of continuing onto the next test rather than hanging.

Instead we can use WNOHANG and a sleep to allow applications
some amount of time to exit, and if they haven't use SIGKILL
instead as well as print an error. Similar to how
wait_for_socket works. The timeout is hard coded to 2 seconds
(100ms sleep + 20 iterations).
2020-06-22 10:52:32 -05:00
James Prestwood 6c9c65a5de frame-xchg: fix incorrect length check
frame_xchg_startv was using sizeof(mmpdu) to check the minimum length
for a frame. Instead mmpdu_header_len should be used since this checks
fc.order and returns either 24 or 28 bytes, not 28 bytes always.

This change adds the requirement that the first iovec in the array
must contain at least the first 2 bytes (mmpdu_fc) of the header.
This really shouldn't be a problem since all current users of
frame-xchg put the entire header (or entire frame) into the first
iovec in the array.
2020-06-22 10:27:59 -05:00
Fabrice Fontaine 6bf5c3ddbd p2p: fix build with uclibc
explicit_bzero is used in src/p2p.c since commit
1675c765a3 but src/missing.h is not
included, as a result build with uclibc fails on:

/home/naourr/work/instance-0/output-1/per-package/iwd/host/opt/ext-toolchain/bin/../lib/gcc/mips64el-buildroot-linux-uclibc/5.5.0/../../../../mips64el-buildroot-linux-uclibc/bin/ld: src/p2p.o: in function `p2p_connection_reset':
p2p.c:(.text+0x2cf4): undefined reference to `explicit_bzero'
/home/naourr/work/instance-0/output-1/per-package/iwd/host/opt/ext-toolchain/bin/../lib/gcc/mips64el-buildroot-linux-uclibc/5.5.0/../../../../mips64el-buildroot-linux-uclibc/bin/ld: p2p.c:(.text+0x2cfc): undefined reference to `explicit_bzero'
2020-06-22 10:27:19 -05:00
Denis Kenzior 19b0d0f2e2 main: Rework kernel option detection logic
This logic was using l_hashmap_insert, which supports duplicates.  Since
some entries were inserted multiple times, they ended up being printed
multiple times.  Fix that by introducing a macro that uses
l_hashmap_replace instead.
2020-06-22 10:12:34 -05:00
James Prestwood 19cce531ca plugins: ofono: remove newline from debug print 2020-06-22 09:51:58 -05:00
Marcel Holtmann a01754f56a Release 1.8 2020-06-15 17:22:57 +02:00
Denis Kenzior 254cefcc96 station: Give network a connection failed hint
Right now, if the connection fails, then network always thinks that the
password should be re-asked.  Loosen this to only do so if the
connection failed at least in the handshake phase.  If the connection
failed due to Association / Authentication timeout, it is likely that
something is wrong with the AP and it can't respond.
2020-06-12 15:21:39 -05:00
James Prestwood e70b252e19 auto-t: add test for delayed ANQP response 2020-06-12 15:04:43 -05:00
James Prestwood cb35e9fe65 auto-t: add 'Delay' property to hwsim python module 2020-06-12 15:04:40 -05:00
James Prestwood 248190b0ed network: delay connect if ANQP has not completed
Using the new station ANQP watch network can delay the connection
request until after ANQP has finished. Since station may be
autoconnecting we must also add a check in network_autoconnect
which prevents it from autoconnecting if we have a pending Connect
request.
2020-06-12 15:04:31 -05:00
James Prestwood 60e2c4647c station: add ANQP state watch API
This is to allow network to watch for ANQP activity in order to
fix the race condition between scanning finishing and ANQP finishing.
Without this it is possible for a DBus Connect() to come in before
ANQP has completed and causing the network to return NotConfigured,
when its actually in the process of obtaining all the network info.

The watch was made globally in station due to network not having
a station object until each individual network is created. Adding a
watch during network creation would result in many watchers as well
as a lot of removal/addition as networks are found and lost.
2020-06-12 14:58:56 -05:00
Tim Kourt ecd39dcf0d network: Don't crash when network_connect_new_hidden_network fails
Change signature of network_connect_new_hidden_network to take
reference to the caller's l_dbus_message struct. This allows to
set the caller's l_dbus_message struct to NULL after replying in
the case of a failure.

==201==    at 0x467C15: l_dbus_message_unref (dbus-message.c:412)
==201==    by 0x412A51: station_hidden_network_scan_results (station.c:2504)
==201==    by 0x41EAEA: scan_finished (scan.c:1505)
==201==    by 0x41EC10: get_scan_done (scan.c:1535)
==201==    by 0x462592: destroy_request (genl.c:673)
==201==    by 0x462987: process_unicast (genl.c:988)
==201==    by 0x462987: received_data (genl.c:1087)
==201==    by 0x45F5A2: io_callback (io.c:126)
==201==    by 0x45E8FD: l_main_iterate (main.c:474)
==201==    by 0x45E9BB: l_main_run (main.c:521)
==201==    by 0x45EBCA: l_main_run_with_signal (main.c:643)
==201==    by 0x403B15: main (main.c:512)
2020-06-09 21:59:36 -05:00
Tim Kourt 8be7aae079 auto-t: Validate Connect after ConnectHiddenNetwork 2020-06-09 21:58:52 -05:00
Tim Kourt 7ef7894218 auto-t: Add async API call for connect_hidden_network 2020-06-09 21:58:52 -05:00
Tim Kourt 61ee99f632 station: Use separate msg holder for hidden connections
Introduce hidden_pending to keep reference to the dbus message object
while we wait for the scan results to be returned while trying to
connect to a hidden network. This simplifies the logic by separating it
into two independent logical units: scanning, connecting and eliminates
a possibility of a memory leak in the case when Network.Connect being
initiated while Station.ConnectHiddenNetwork is in progress.
2020-06-09 21:58:52 -05:00
Denis Kenzior 532f6b154e station: Do not enter autoconnect_full erroneously
If a connection is initiated (via dbus) while a quick scan is in
progress, the quick scan will be aborted.  In this case,
station_quick_scan_results will always transition to the
AUTOCONNECT_FULL state regardless of whether it should or not.

Fix this by making sure that we only enter AUTOCONNECT_FULL if we're
still in the AUTOCONNECT_QUICK state.

Reported-by: Alvin Šipraga <alsi@bang-olufsen.dk>
2020-06-09 10:03:33 -05:00
James Prestwood 32a55fb75c hwsim: add new 'Delay' property to Rules
This allows a matching frame to be delayed by some number of
milliseconds.
2020-06-08 15:13:02 -05:00
James Prestwood 078c2d76c7 doc: document new 'Delay' property for hwsim Rules 2020-06-08 15:12:49 -05:00
Alvin Šipraga 8db4d9272a scan: refactor start_next_scan_request to not send duplicate requests
If start_scan_next_request() is called while a scan request
(NL80211_CMD_TRIGGER_SCAN) is still running, the same scan request will
be sent again. Add a check in the function to avoid sending a request if
one is already in progress. For consistency, check also that scan
results are not being requested (NL80211_CMD_GET_SCAN), before trying to
send the next scan request. Finally, remove similar checks at
start_next_scan_request() callsites to simplify the code.

This also fixes a crash that occurs if the following conditions are met:
  - the duplicated request is the only request in the scan request
    queue, and
  - both scan requests fail with an error not EBUSY.

In this case, the first callback to scan_request_triggered() will delete
the request from the scan request queue. The second callback will find
an empty queue and consequently pass a NULL scan_request pointer to
scan_request_failed(), causing a segmentation fault.
2020-06-08 15:10:30 -05:00
Denis Kenzior 5c7f064f26 AUTHORS: Mention Alvin's contributions 2020-06-04 13:18:41 -05:00
Alvin Šipraga cae6949ce1 scan: Do not start new requests while suspended
If scanning is suspended, have scan_common() queue its scan request
rather than issuing it immediately. This respects the assumption that
scans are not requested while sc->suspended is true.
2020-06-04 13:17:42 -05:00
James Prestwood 8b1161ec8e frame-xchg: fix bug when starting new xchg from callback
This bug is caused by the following behavior:

 1. Start a frame-xchg, wait for callback
 2. From callback start a new frame-xchg, same prefix.

The new frame-xchg request will detect that there is a duplicate watch,
which is correct behavior. It will then remove this duplicate from the
watchlist. The issue here is that we are in the watchlist notify loop
from the original xchg. This causes that loop to read from the now
freed watchlist item, causing an invalid read.

Instead of freeing the item immediately, check if the notify loop is in
progress and only set 'id' to zero and 'stale_items' to true. This will
allow the notify loop to finish, then the watchlist code will prune out
any stale items. If not in the notify loop the item can be freed as it
was before.
2020-06-04 09:36:42 -05:00
Andrew Zaborowski 1e10d13645 frame-xchg: Use frame_watch_group_match in frame_watch_group_get 2020-06-04 09:14:21 -05:00
Andrew Zaborowski d012a7f2ac frame-xchg: Fix frame_watch_remove_by_handler for group 0
Don't match the default group's (group_id 0) wdev_id against the
provided wdev_id because the default group can be used on all wdevs and
its wdev_id is 0.  Also match individual item's wdev_id in the group to
make up for this although it normally wouldn't matter.
2020-06-04 09:13:47 -05:00
Tim Kourt cc66050b90 auto-t: Test Agent ops 2020-05-13 05:50:45 -05:00
James Prestwood d38bd513c9 fils: include RSNE in authenticate
802.11ai mandates that the RSN element is included during authentication
for FILS. This previously was happening by chance since supplicant_ie
was being included with CMD_AUTHENTICATE. This included more than just
the RSNE so that was removed in an earlier commit. Now FILS builds the
RSNE itself and includes this with CMD_AUTHENTICATE.
2020-05-02 20:56:13 -05:00
James Prestwood c7a17e5987 netdev: unify ft/auth_proto authenticate builders
build_cmd_ft_authenticate and build_cmd_authenticate were virtually
identical. These have been unified into a single builder.

We were also incorrectly including ATTR_IE to every authenticate
command, which violates the spec for certain protocols, This was
removed and any auth protocols will now add any IEs that they require.
2020-05-02 20:55:42 -05:00
Tim Kourt cbfaef09d6 auto-t: Remove bogus logic
Device object has no property named 'connected'.
client_connect has no member dev2
2020-05-02 07:03:05 -05:00