Communicate the final wiphy and interface configuration data after the
hostapd and iwd processes are started, to the test scripts as an
environment variable TEST_WIPHY_LIST. This way the test scripts can
know which interfaces are used by hostapd instances, which hostapd
config they're using, and which are used by iwd. The typical value will
be
rad0=wln0=hostapd,ctrl_interface=/var/run/hostapd,config=ssidOpen.conf
rad1=wln1=iwd
Handle NewLink events to detect interface mac address changes. In my
current testing I don't see nl80211 events on address change so it's
best to react to both types of events.
The phy creation logic was a bit complex, using a hashmap to map between
phy names in the config file (e.g. rad0, rad2, etc) and interface names
created for that phy.
We take advantage of the fact that hwsim can create a radio with a given
name to simply assign the radio name from the autotest config file
directly. Then we name any interfaces created in order of phy creation.
A few extra sanity checks are also added.
Actually run hwsim in the daemon mode to work as the wireless medium now
that hwsim supports it. The current test-runner code, which assumed a
different command line syntax, wasn't functional but it didn't affect
test-runner in any way.
Don't require the full length of a Management MPDU as a condition to
forward the frame, only require data up to the three addresses we need
to know where to forward the frame.
This check was failing with some frames during a deauthentication. We
could possibly forward shorter frames too if needed (send to all
possible recipients.)
Don't handle the hwsim netlink events we use to track radios and
interfaces if we're not in daemon mode. This quiets dbus errors when
using hwsim through the command line.
The name attribute in the NEW RADIO command needs at least 4 bytes for
the attribute header (struct nlattr), all the characters of the name
string and a NUL byte, and up to 3 bytes of alignment padding.
Otherwise, depending on the name length and whether the NO_VIF attribute
was the last, that attribute could end up being dropped and we were
ending up with too many interfaces inside test-runner.
Implement a hwsim wireless medium inside hwsim.c. This doesn't do
anything to the frames it moves around yet, only tries to implement
the same logic that the kernel medium contains.
In daemon mode start a basic passive DBus interface to expose the
information on radios attached to mac80211_hwsim. In this version
interfaces have objects of their own. It might be simpler to only
show them as an array property on the radio object (array of pairs of
string, one string for address, one for name).
Read wiphy addresses from sysfs and perform the wiphy name to wiphy idx
mapping using sysfs. Do this directly on a new radio notification and
stop using new wiphy notifications except for updating the radio names.
Having the wiphy index available synchronously when parsing a new radio
event we store the wiphy index in the radio_info_rec struct directly and
drop struct wiphy_info_rec as there was a 1:1 mapping. With this, and
knowing that all radio_info data is available when new interface
notifications are received, the tracking is simplified because dbus
objects can be created and destroyed within the notification handlers.
We also now store both the wiphy hardware address data and separately
the interface MAC addresses and can use them more appropriately in the
medium implementation.
The kernel expects the radio name attribute to include the string's zero
byte. Things may still work without this if there is padding after the
attribute.
This has been now patched and the zero byte will be optional when that
patch makes its way through different trees.
Add a daemon mode that is entered when no action was specified on the
command line. In this mode hwsim tracks information on radios through
the netlink events. The interface to make use of the information is
added in the next patch.
killall doesn't wait for the iwd process to clean up, so using it is not
enough when cleaning up between tests.
Using killall -w also doesn't work since iwd is launched by the script.
By the time killall is invoked, the script process is also cleaned up.
So when iwd is killed via killall, nobody is there to reap the zombie
process (test-runner is running as init, but doesn't do this)
The easiest solution is to make the test script itself clean up any iwd
processes it launches. This is what has been implemented in the
previous patch.
Some unit tests expect to be running from the top level iwd tree
directory to load certificates and such. Make sure that test-runner
chdirs to the appropriate directory prior to running the unit tests.
The argv buffer allocated by alloca is only large enough to hold the
original argument list. Additional arguments (such as --kernel) are
appended at the end, which results in the stack corruption. Make sure
to allocate space for additional arguments.
When KVM is available, use the -cpu host option. This is useful on
distributions that might use architecture specific optimizations, which
might not be available on the default machine being emulated by qemu.
For example, a Gentoo box compiled with "-march=core-avx2" would result
in several binaries not executing properly inside the qemu environment
due to instruction set mismatches.
Add a new option to the hwsim binary to fetch all or a given hwsim radio.
Print out radio information which is currently returned in the reply to
user space.
Add new hwsim attributes to the enum and tweak getopt to behave properly
with or without giving the radio id on the command line.
If the MAC80211_HWSIM netlink family disappears, exit hwsim. This can
happen already at startup, for example if MAC80211_HWSIM functionality is
not compiled in the kernel or respective module loaded.
Kernel sends HWSIM_CMD_NEW_RADIO and HWSIM_CMD_DEL_RADIO multicast
events when new radio have been created and when existing one has
been deleted. The events are sent to "config" netlink multicast group.
The hwsim catches these events and uses the information to monitor
what simulated radios are created and deleted in the system.
The new attribute causes the radio to be removed if the hwsim process
dies. This is the default behaviour. If user calls the binary with -k
option, then the radio is kept after hwsim quits.
This requires kernel support for HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE
attribute.
When a new radio is created, the kernel returns the new radio id
in the error code. If the error < 0, then that means a real error
and other values are used as a radio id.
When a radio is destroyed, the error code 0 means a success and
other values indicate an error.