Commit Graph

4885 Commits

Author SHA1 Message Date
James Prestwood cf3ea5d4df auto-t: fix testWPA2 to wait for device object 2020-09-10 17:59:49 -05:00
James Prestwood 8b41413170 auto-t: harden testHotspot
This test occationally failed, and it uses the old style of waiting
for connected on the network object instead of the device object.

The hwsim rule was also moved ahead of the IWD() initializer which
ensures that IWD doesn't scan before the rule can be set/processed.
2020-09-10 17:59:49 -05:00
James Prestwood e81b1b77c8 auto-t: fix testAPRoam
This test occationally fails due to no hwsim rules. Basically we
were just expecting iwd to connect to one of 3 access points but
the ranking was equal, so it chose the first in the scan list.

Now a signal strength is assigned to each AP to steer IWD into
connecting to the expected AP.
2020-09-10 17:59:49 -05:00
James Prestwood b437bfaced auto-t: fix testAP
As with other tests, wait on device state instead of the network
object. The connectivity test was also changed to not check for
group traffic since AP does not negotiate the IGTK at this time.
2020-09-10 17:59:49 -05:00
James Prestwood 7b933db78a auto-t: fix testBSSBlacklist
There were a number of fixes here. The waits were changed to wait
on the device state instead of the network state and hwsim rules
were removed after the test as to not interfere with future tests.
One of the rules was setting the signal to -10000 wich was causing
the ranking to be zero.
2020-09-10 17:59:49 -05:00
James Prestwood b9cb6134d6 auto-t: update testAgent to use TestContext
This hides iwctl output unless verbose is specified
2020-09-10 17:59:49 -05:00
James Prestwood 03ff410dff auto-t: update testClientNonInteractive to use TestContext
This makes any iwctl output hidden unless enabled via the verbose
option.
2020-09-10 17:59:49 -05:00
James Prestwood 4c6173ee89 auto-t: fix SAE FT test and update
Updated testFT-SAE-roam to use the TestContext APIs as well as
fixed the failure which was introduced after requiring stricter
AKM logic for SAE networks. The new failure was due to the hostapd
config not including the standard SAE AKM which is actually
required by the spec.
2020-09-10 17:59:49 -05:00
James Prestwood 6e2aba3907 auto-t: Increase all test timeouts
Slower systems may not be able to make some timeouts that tests
mandated. All timeouts were increased significantly to allow tests
to pass on slow systems.
2020-09-10 17:59:49 -05:00
James Prestwood 0036cb976f auto-t: hwsim: wait for method return
It is not safe to assume that the python dbus implementation will
wait for a method to return. The documentation says this with
respect to reply_handler/error_handler:

"If both are None, the implementation may request that no reply is sent"

To stay on the safe side we should always include the error/reply
handlers and wait for the operation to complete.
2020-09-10 17:59:49 -05:00
James Prestwood 199b7837d4 doc: update test runner docs 2020-09-10 17:59:49 -05:00
James Prestwood 17955fcf5a tools: post test-runner rewrite cleanup
Removed test-runner.c, and renamed py_runner to test-runner. Removed
tools/test-runner from .gitignore.

This was done as a separate commit to avoid a nasty diff between the
existing test runner, and the new python version
2020-09-10 17:59:49 -05:00
James Prestwood 9bb5ecf27a auto-t: remove device.wait_for_connected
I had added this without realizing wait_for_object_condition
can do this already using the device object.
2020-09-10 17:59:49 -05:00
James Prestwood 2e3ad0f6b3 auto-t: replace hard-coded interfaces
test-runner now supports interface name replacement inside hostapd
config files. Since a given test configuration doesn't know what
interface names there will be $ifaceN can be specified instead e.g.

rsn_preauth_interfaces=$iface0 $iface1

The $ifaceN values will be replace with actual interface names when
the test is started.

This patch also removes ctrl_interface inside the hostapd config
files as this is no longer required.
2020-09-10 17:59:49 -05:00
James Prestwood 0d5409eb04 auto-t: skip ofono tests if ofonod isn't running 2020-09-10 17:59:49 -05:00
James Prestwood 1f404e32a6 auto-t: fix testSAE autoconnect_test.py
This test was unreliable since it was assuming a periodic scan would
happen at just the right time. Instead since we are expecting autoconnect
we can just wait for DeviceState.connected then after we are connected
verify the network was correct.
2020-09-10 17:59:49 -05:00
James Prestwood 2bd2462968 auto-t: fix hidden network test
This test was never 100% reliable, and after the test-runner re-write
it became extremely unreliable. The issue came down to the very common
block of code thats present in many tests where we wait for obj.scanning
then not obj.scanning. This is fine when a dbus scan() is explicitly
done before, otherwise it could lead to problems. Without a dbus scan
explicitly called we are assuming a periodic scan will happen. If it
already happen the initial wait for obj.scanning will never return and
time out.

This probably needs to be changed in several tests, but for this specific
case we can remove the waits completely. Since
check_autoconnect_hidden_network has a 30 second wait on
DeviceState.connected this will ultimately time out if anything goes
wrong. There isn't any great reason to wait for scanning (for this test
specifically).

A minor style change was also made when initializing IWD. The values
passed in this test are now the default, so no arguments need to be
passed.
2020-09-10 17:59:49 -05:00
James Prestwood 3ec3855de9 auto-t: remove wiphy.py
This is no longer needed
2020-09-10 17:59:49 -05:00
James Prestwood 91adbcb7f4 auto-t: iwd.py: update to work with test-runner rewrite
iwd.py was updated to use the TestContext APIs to start/stop
IWD. This makes the process managment consistent between starting
IWD from test-runner or from the IWD() constructor.

The psk agent is now tracked, and destroyed upon __del__. This is
to fix issues where a test throws an exception and never
unregisters the agent, causing future tests to fail.

The configuration directory was also chaged to /tmp by
default. This was done since all tests which used this used /tmp
anyways.

The GLib mainloop was removed, and instead put into test-runner
itself. Now any mainloop operations can use ctx.mainloop instead
2020-09-10 17:59:49 -05:00
James Prestwood ad97dbee08 auto-t: ofono.py: fix timeout cleanup and wait for service
Ofono.py was not cleaning up the timeout, nor waiting for the ofono.org
service to come up before continuing.
2020-09-10 17:59:49 -05:00
James Prestwood 85259bb519 auto-t: testutil.py: update to work with test-runner rewrite
Similar to the others, testutil.py was converted to use the global
test context to lookup radios/interfaces rather than the wiphy_map
2020-09-10 17:59:49 -05:00
James Prestwood edac41b1b3 auto-t: hostapd.py: update to work with test-runner rewrite
Before hostapd was initialized using the wiphy_map which has now
gone away. Instead we have a global config module which contains
a single 'ctx'. This is the centeral store for all test information.

This patch converts hostapd.py to lookup instances by already
initialized Hostapd object. The interface parameter was removed
since all tests have been converted to use config= instead.

In addition HostapdCLI was changed to allow no parameters if there
is only a single hostapd instance.
2020-09-10 17:59:49 -05:00
James Prestwood 0772d4b61a auto-t: introduce pure python test-runner re-write
This patch completely re-writes test-runner in Python. This was done
because the existing C test-runner had some clunky work arounds and
maintaining or adding new features was starting to become a huge pain.

There were a few aspects of test-runner which continually had to
be dealt with when adding any new functionality:

 * Argument parsing: Adding new arguments to test-runner wasn't so
   bad, but if you wanted those arguments passed into the VM it
   became a huge pain. Arguments needed to be parsed, then re-formatted
   into the qemu command line, then re-parsed in a special order
   (backwards) once in the VM. The burden for adding new arguments was
   quite high so it was avoided (at least by me) at all costs.
 * The separation between C and Python: The tests are all written in
   python, but the executables, radios, and interfaces were all created
   from C. The way we solved this was by encoding the require info as
   environment variables, then parsing those from Python. It worked,
   but it was, again, a huge pain.
 * Process management: It started with all processes being launched
   from C, but eventually tests required the ability to start IWD, or
   kill hostapd ungracefully in order to test certain functionality.
   Since the processes were tracked in C, Python had no way of
   signalling that it killed a process and when it started one C had
   no idea. This was mitigated (basically by killall), but it was
   no where close to an elegant solution.

Re-writing test-runner in python solves all these problems and will
be much easier to maintain.

 * Argument parsing: Now all arguments are forwarded automatically
   to the VM. The ArgParse library takes care of parsing and each
   argument is stored in a dictionary.
 * Separation between C and Python: No more C, so no more separation.
 * Process management: Python will now manage all processes. This
   allows a test to kill, restart, or start a new process and not
   have to remember the PID or to kill it after the test.

There are a few more important aspects of the python implementation
that should now be considered when writing new tests:

 * The IWD constructor now has different default arugments. IWD
   will always be started unless specified and the configuration
   directory will always be /tmp
 * Any non *.py file in the test directory will be copied to /tmp.
   This avoids the need for 'tmpfs_extra_stuff' completely.
 * ctrl_interface will automatically be appended to every hostapd
   config. There is no need to include this in a config file from
   now on.
 * Test cleanup is extremely important. All tests get run in the
   same interpreter now and the tests themselves are actually loaded
   as python modules. This means e.g. if you somehow kept a reference
   to IWD() any subsequent tests would not start since IWD is still
   running.
 * For debugging, the test context can be printed which shows running
   processes, radios, and interfaces.

Three non-native python modules were used: PrettyTable, colored, and
pyroute2

$ pip3 install prettytable
$ pip3 install termcolor
$ pip3 install pyroute2
2020-09-10 17:59:49 -05:00
James Prestwood 9594b03a35 auto-t: prepare autotests for test-runner re-write
The tests basically remained the same with a few minor changes.
The wiphy_map and in turn hostapd_map are no longer used. This
was already partially converted a long time ago when the 'config'
parameter was added to HostapdCLI. This patch fully converts all
autotests to use 'config' rather than looking up by interface.

Some test scripts were named 'test.py' which was fine before but
the new rewrite actually loads each python test as a module. The
name 'test' is too ambiguous and causes issues due to a native
python module with the same name. All of these files were
renamed to 'connection_test.py'.
2020-09-10 17:59:49 -05:00
Andrew Zaborowski c7b072ff21 ap: Accept P2P wildcard SSIDs in probe requests
Add the special case "DIRECT-" SSID, called the P2P Wildcard SSID, in
ap_probe_req_cb so as not to reject those Probe Requests on the basis of
ssid mismatch.  I'd have preferred to keep all the P2P-specific bits in
p2p.c but in this case there's little point in adding a generic
config setting for SSID-matching quirks.
2020-09-09 14:52:44 -05:00
Andrew Zaborowski 0d2d34c353 p2p: Consistently use the conn_ prefix for variables
Prefix all the struct p2p_device members that are part of the connection
state with the "conn_" string for consistency.  If we needed to support
multiple client connections, these members are the ones that would
probably land in a separate structure, without that prefix.
2020-09-09 13:05:36 -05:00
Andrew Zaborowski d511b4b782 p2p: Free parsed frame data in p2p_go_negotiation_resp_cb 2020-09-09 13:05:07 -05:00
Andrew Zaborowski 6bba989913 p2p: Use WSC_RF_BAND_2_4_GHZ constant instead of 0x01 2020-09-09 13:05:01 -05:00
Andrew Zaborowski 0fc97d2674 p2p: Move p2p_device_discovery_stop calls to connect_failed
Move a few the calls to p2p_device_discovery_stop() done right after
p2p_connect_failed() directly to that function to reduce duplication.
2020-09-09 13:04:22 -05:00
Andrew Zaborowski 0fad5fef71 p2p: Do provisioning scan from the Interface Address
For WSC we should have been sending our probe requests from the same
address we're going to be doing EAP-WSC with the GO.  Somehow I was able
to connect to most devices without that but other implementations seem
to use the Interface Address (the P2P-Client's MAC), not the Device
Address (P2P-Device's MAC).  We could switch the order to first create
the new interface and scan from it is simpler to use the scan_context we
already have created on the device interface and set a different mac.
2020-09-09 13:04:18 -05:00
Andrew Zaborowski 9335680cd8 scan: Add optional source_mac scan parameter
This is similar to randomize_mac_addr_hint but it sets a specific source
MAC address for our probe frames.
2020-09-09 13:02:02 -05:00
Marcel Holtmann aa3dc1b953 Release 1.9 2020-09-04 01:06:21 +02:00
Marcel Holtmann 3ab2542f5f build: Require at least version 0.33 when building with external ELL 2020-09-04 00:51:27 +02:00
Andrew Zaborowski 4bc20a0979 ap: Start EAP-WSC authentication with WSC enrollees
After association and sending the SET_STATION commands, set up the
handshake_state and eapol_sm for EAP-WSC and start the handshake.
2020-08-28 10:50:59 -05:00
Andrew Zaborowski 7a7c580ffc ap: Parse WSC PBC association request and build response
Check the conditions for PBC enrollee registration when we receive the
Association Request with WSC IE and indicate to the enrollee whether we
accept the association using a WSC IE in the Association Response.
After this, a NULL sta->assoc_rsne indicates that the station is not
establishing the RSNA and is a WSC enrollee.
2020-08-28 10:49:16 -05:00
Andrew Zaborowski 99112c9317 ap: WSC Probe Request processing logic
Implement the caching of WSC probe requests -- when an Enrollee later
associates to start registration we need to have its Probe Request on
file.  Also use this cache for PBC "Session Overlap" detection.
2020-08-28 10:35:58 -05:00
Andrew Zaborowski 43c101ab14 ap: Push Button mode API and beacon changes
This adds the API for putting the AP in Push Button mode, which we'll
need to P2P GO side but may be useful on its own too.  A WSC IE is added
to our beacons and probe responses indicating whether the PBC mode is
active.
2020-08-28 10:32:58 -05:00
Andrew Zaborowski 1f89311798 ap: Stop ongoing handshake on reassociation
On a new association or re-association, in addition to forgetting a
complete RSN Association, also stop the EAPoL SM to stop any ongoing
handshake.

Do this in a new function ap_stop_handshake that is now used in a few
places that had copies of the same few lines.  I'll be adding some more
lines to this function for WSC support.
2020-08-28 10:32:01 -05:00
Andrew Zaborowski 2231179b97 eapol: Handle the use_eapol_start flag on authenticator
Reuse this flag on the authenticator side with a slightly different
meaning: when it's true we're forced to wait for the EAPoL-Start before
sending the first EAPoL-EAP frame to the supplicant, such as is required
in a WSC enrollee registration when the Association Request didn't have
a v2.0 WSC IE.
2020-08-28 10:29:36 -05:00
Andrew Zaborowski 66e9d4fca9 wscutil: Add wsc_build_beacon
For consistency also update wsc_build_probe_response to use the same
__builtin_popcount based rf_bands check.
2020-08-28 10:29:06 -05:00
Andrew Zaborowski 8c1bf5385e wscutil: Use a utility for building authorized_macs
Add the wfa_build_authorized_macs function (wfa_ prefix following the
wfa_extract_ naming) and use it in wsc_build_probe_response.  The logic
is changed slightly to treat the first 6-zeros address in the array as
the end of the array.
2020-08-28 10:28:15 -05:00
Andrew Zaborowski 1449b8fbc4 ap: Fix incoming Probe Request BSSID check
Setting 'match' false wouldn't do anything because it was already false.
If the frame is addressed to some other non-broadcast address ignore it
directly and exit ap_probe_req_cb.
2020-08-27 14:04:02 -05:00
Andrew Zaborowski 137309c998 ap: Drop unused variable 2020-08-27 14:02:03 -05:00
Andrew Zaborowski d55e00b31d ap: Move AP parameters to a struct
To limit the number of ap_start parameters, group basic AP config
parameters in the ap_config struct that is passed as a pointer and owned
by the ap_state.
2020-08-27 14:00:28 -05:00
Andrew Zaborowski 7713e00992 eap-wsc: In WSC-R read UUID-E from settings
The intent was to read the UUID-E from the settings rather than generate
it from the enrollee's MAC because it needs to match the UUID-E from
enrolee's Probe Requests, fix this.  The UUID-E supplied in the unit
test was being ignored but the test still passed because the supplied
UUID-E was generated the same way we generated it in eap-wsc.c.
2020-08-27 13:53:46 -05:00
Andrew Zaborowski e4b1d4202f eap: Re-send Identity Request on EAPoL-Start
It looks like clients sometimes miss our unsolicited Identity Request
and need a resend.
2020-08-27 13:53:12 -05:00
Andrew Zaborowski a4fa91a695 p2p: Build our Probe Response using connection data
When we're sending our probe response to the same peer that we're
currently connected or connecting to, use current WSC Configuration
Methods, UUID-E and WFD IE selected for this connection attempt, not the
ones we'd use when discovering peers or being discovered by peers.
In the case of the WFD IE, the "Available for WFD Session" flag is going
to differ between the two cases -- we may be unavailable for other peers
but we're still available for the peer we're trying to start the WFD
session with.
2020-08-25 16:52:41 -05:00
Andrew Zaborowski 619a5ed43b p2p: Fix the WSC Config Methods in GO Negotiation Response
When we send our GO Negotiation Response, send the Configuration Method
selected for the current connection rather than the accepted methods mask
that we hold in dev->device_info.
2020-08-25 16:52:29 -05:00
Andrew Zaborowski 19ab25f1d6 p2p: Send the right UUID-E in probe request WSC IEs
When building the scan IEs for our provisioning scans, use the UUID-E
based on the Interface Address, not the Device Address, as that is what
wsc.c will be using to in the registration protocol.

Eventually we may have to base the UUID-E on the Device Address or
something else that is persistent, and pass the actual UUID-E to wsc.c,
as the Interface Address is randomly generated on every connect attempt.
IIRC the UUID-E is supposed to be persistent.
2020-08-25 16:51:51 -05:00
Andrew Zaborowski 7a91f6dba4 unit: Add a WSC-R PBC test with Open auth_type 2020-08-25 16:49:02 -05:00