Jouni Malinen [Tue, 5 Nov 2013 23:15:28 +0000 (01:15 +0200)]
hostapd: Fix DETACH command debug prints to avoid use of freed memory
In case a control interface socket is detached because of sendmsg()
failing for the socket, function call to detach the socket uses a
pointer to the socket information in the structure to be freed. Reorder
code to print socket info before freeing the data to avoid use of freed
memory in case debug prints are enabled.
Jouni Malinen [Tue, 5 Nov 2013 22:57:38 +0000 (00:57 +0200)]
Fix removal of a BSS that has not yet been fully initialized
If a secondary BSS is removed while it is waiting for the primary BSS to
complete channel setup (e.g., due to HT co-ex scan, ACS, or DFS), the
hostapd_data instance has not yet been initialized. Fix the BSS removal
code to take this special case into account and not try to deinitialize
the hostapd_data instance that has not yet been started.
Jouni Malinen [Tue, 5 Nov 2013 22:43:10 +0000 (00:43 +0200)]
Remove all BSSs on removal of the first one
The changes in commit 5592065850a40e235020dba79e5592b949b829b8 to allow
any BSS to be removed were a bit too early since there are still number
of areas that use the first BSS as a special case. Especially the
driver_ops API is going to require quite a bit of cleanup before removal
of the first BSS without the other BSSes of the same radio can be done
safely.
For now, force all BSSs to be removed in case the first one is removed.
Jouni Malinen [Tue, 5 Nov 2013 11:39:21 +0000 (13:39 +0200)]
hostapd: Do not terminate process on dynamic interface add failure
Limit the calls to eloop_terminate() to happen only for the
initialization failure from the interfaces that we specified on the
command line. This allows hostapd process to continue operating even if
a dynamically added interface fails to start up. This allows the upper
layer software to fix a configuration error and retry.
Jouni Malinen [Tue, 5 Nov 2013 11:21:58 +0000 (13:21 +0200)]
tests: Handle hostapd dying more gracefully
Catch exceptions from operations that try to remove hostapd interface
and rename the log file. If these operations fail due to socket
connection issues, hostapd has likely died or gotten stuck somewhere.
Report the test case as a failure and stop test run cleanly.
Jouni Malinen [Tue, 5 Nov 2013 09:07:51 +0000 (11:07 +0200)]
P2P: Add more debug prints for frequency selection
This prints out get_shared_radio_freqs() results and related information
from P2P operations to make debug logs more helpful for figuring out
issues related to multi-channel concurrency.
Ilan Peer [Sun, 3 Nov 2013 13:30:27 +0000 (15:30 +0200)]
wpa_supplicant: Fix bug in get_shared_radio_freqs
The idx variable was mistakenly set to 0 at the beginning of the
interface iteration. This could result in the operating channel of the
interface calling the function from being removed from the returned
frequency array if other interfaces were operating.
wpa_supplicant: Fix updating GO beacons on WFD subelements change
When WFD Subelements are set, the IE in the Beacon frames of already
existing groups are not updated. This patch fixes this issue by setting
beacon_update to be 1 on WFD IE update.
Signed-hostap: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Haim Dreyfuss [Sun, 3 Nov 2013 13:19:59 +0000 (15:19 +0200)]
bgscan: Add global bgscan configuration
This option can be used to globally configure bgscan parameters
for all the network blocks.
Note that this configuration will not override a network block
specific bgscan settings, but will only be used in case that
the network block does not have a valid bgscan configuration.
Jouni Malinen [Mon, 4 Nov 2013 09:51:56 +0000 (11:51 +0200)]
Allow AP mode configuration with VHT enabled on 2.4 GHz
hostapd_set_freq_param() rejected the 20 MHz channel case with
vht_enabled due to the existing validation step including only 5 GHz (to
be more exact, only >= 5000 MHz). While the behavior may not be fully
defined for 2.4 GHz, we can enable this based on driver capability
advertisement to fix automatic VHT selection for P2P use cases.
mac80211_hwsim advertises VHT for 2.4 GHz band and that resulted in
failures when trying to start GO on that band with vht=1 parameter.
Jouni Malinen [Sun, 3 Nov 2013 19:57:39 +0000 (21:57 +0200)]
tests: Add preliminary version of DFS test cases
These are still disabled by default since they require mac80211_hwsim
changes that are not yet in the upstream kernel and because the test
cases do not fully work yet. Anyway, they are quite convenient for
development use, so good to have them available in the main repository.
Jouni Malinen [Sun, 3 Nov 2013 19:50:48 +0000 (21:50 +0200)]
DFS: Do not use cf1 to override freq for 20 MHz channels
NL80211_ATTR_CENTER_FREQ1 is defined to be used for anything but 20 MHz
bandwidth, so it could be unset for 20 MHz channels. Do not use it to
override center frequency from NL80211_ATTR_WIPHY_FREQ (if available)
for 20 MHz channels to avoid clearing frequency.
Jouni Malinen [Sun, 3 Nov 2013 18:50:39 +0000 (20:50 +0200)]
tests: Add test cases for automatic channel selection
This extends the Hostapd class to support monitor interface events and
STATUS command similarly to the WpaSupplicant class so that internal
hostapd state can be verified in more detail.
Commit ebd79f07c47b02b71c0ac7744a6a94a2bae92fcf broke parsing of
configuration files that use the bss parameter to specify another BSS
entry. This resulted in crashing the process with NULL pointer
dereference since the new hostapd_config::bss design requires this
function to allocate a new hostapd_bss_config structure.
Jouni Malinen [Sun, 3 Nov 2013 16:20:28 +0000 (18:20 +0200)]
hostapd: Fill in phyname automatically
If per-BSS configuration enabling did not provide a phy name, iface->phy
was left empty. It can be helpful to set this up automatically, so fill
that when initializing the interface.
Jouni Malinen [Sun, 3 Nov 2013 15:43:40 +0000 (17:43 +0200)]
Optimize 40 MHz HT co-ex scan on AP
Only scan the affected channels instead of all enabled channels when
determining whether the primary and secondary channel for HT40 needs to
be swapped. This speed up HT40 setup considerably on 5 GHz band.
Jouni Malinen [Sun, 3 Nov 2013 14:33:11 +0000 (16:33 +0200)]
hostapd: Wait for channel list update after country code change
If hostapd is requested to set the country code and the previous country
code differs from the new one, the channel list information from the
driver may change. This change may not be instant, so wait for an
EVENT_CHANNEL_LIST_CHANGED event before continuing interface setup with
fetching of the channel list information. This fixes issues where the
selected channel is not available based on the previous regulatory data
and update through CRDA takes some time.
Jouni Malinen [Sun, 3 Nov 2013 13:47:01 +0000 (15:47 +0200)]
hostapd: Move ctrl_iface initialization to happen earlier
Channel determination may take considerable time when ACS or DFS is
used, so it is useful to be able to observe this process through the
control interface. Move the initialization of the control interfaces to
happen before channel determination so that this can be achieved.
Jouni Malinen [Sun, 3 Nov 2013 11:34:35 +0000 (13:34 +0200)]
hostapd: Remove hostapd_interface_init2()
This was an unnecessary wrapper functions for calling two functions from
a single place in the code. It is cleaner to just call those two
functions directly.
Jouni Malinen [Sun, 3 Nov 2013 11:28:17 +0000 (13:28 +0200)]
hostapd: Simplify interface initialization
Use hostapd_interface_init2() for all interfaces instead of the
previously used different paths for per-interface-config and
per-BSS-config cases. This moves the calls to hostapd_driver_init() and
hostapd_setup_interface() to happen after all configuration files have
been read.
Jouni Malinen [Sat, 2 Nov 2013 18:44:58 +0000 (20:44 +0200)]
hostapd: Add control interface test commands for radar detection
If hostapd is build with CONFIG_TESTING_OPTIONS=y, the RADAR control
interface command can be used to test hostapd behavior on arbitrary
driver radar events.
Jouni Malinen [Sat, 2 Nov 2013 18:39:57 +0000 (20:39 +0200)]
nl80211: Verify radar event attributes exist before using them
While these attributes may be expected to be present always, this needs
to be verified within driver_nl80211.c since we cannot depend on the
kernel/driver working correctly.
Jouni Malinen [Sat, 2 Nov 2013 18:38:40 +0000 (20:38 +0200)]
tests: Add run-tests.py --no-reset
This can be used to request the previously used default behavior where
the devices are not stopped at the end of a test case if a single test
case is run.
Jouni Malinen [Sat, 2 Nov 2013 17:49:01 +0000 (19:49 +0200)]
hostapd: Fix ENABLE failure to not remove interface
Previously, ENABLE command ended up freeing the hostapd_iface context on
initialization failures, but did not even remove the interface from the
list of available interfaces. This resulted in use of freed memory with
any following operation on the same interface. In addition, removing the
interface on initialization failure does not seem like the best
approach. Fix both of these issues by leaving the interface instance in
memory, but in disabled state so that the configuration can be fixed and
ENABLE used again to enable the interface or REMOVE used to remove the
interface.
Jouni Malinen [Sat, 2 Nov 2013 16:07:49 +0000 (18:07 +0200)]
SAE: Fix group selection
Number of regressions had shown up in wpa_supplicant implementation of
SAE group selection due to different integer array termination (-1 in
hostapd, 0 in wpa_supplicant) being used for SAE groups. The
default_groups list did not seem to use any explicit termination value.
In addition, the sae_group_index was not cleared back to 0 properly
whenever a new SAE session was started.
Jouni Malinen [Sat, 2 Nov 2013 10:20:59 +0000 (12:20 +0200)]
tests: Always write run-tests.py debug logs a file
Remove the -l command like option from run-tests.py and always enable
writing of debug level logs to files. The stdout debug verbosity is
controlled independently of the debug log files.
Jouni Malinen [Sat, 2 Nov 2013 09:27:16 +0000 (11:27 +0200)]
tests: Ignore old scan results in test_grpform_pbc
This is needed to avoid invalid PBC session overlap detection when
the previous test case used active PBC mode and the old BSS entry
in cfg80211 may still be valid when starting the next test case.
Jouni Malinen [Sat, 2 Nov 2013 09:22:16 +0000 (11:22 +0200)]
tests: Use single channel scans to speed up test cases
A full scan in these specific test cases does not add anything to the
coverage, so use a single channel scan for the station connection to
remove undesired extra time needed for a full scan.
Jouni Malinen [Sat, 2 Nov 2013 08:30:37 +0000 (10:30 +0200)]
tests: Add run-tests.py --shuffle-test
This optional argument can be used to randomize the order in which the
test cases are run. This can provide more coverage on testing
interactions of common use cases in various different sequences. Such
issues have already been found even with the fixed order of test cases,
but being able to reorder the tests makes this more efficient.
Johannes Berg [Thu, 31 Oct 2013 15:08:01 +0000 (16:08 +0100)]
hwsim tests: Add build script
This is easier than to copy/paste from the README. We may
want to extend it later to change the .config for some
common differences between systems (e.g., libnl/libbfd).
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Johannes Berg [Thu, 31 Oct 2013 15:05:11 +0000 (16:05 +0100)]
hwsim tests: Prefill database in VM tests
In some cases, e.g., with the VM tests if the VM crashes, it
can be useful to know which tests should have run but didn't
(or didn't finish). In order to catch these more easily, add
an option to prefill the database with all tests at the very
beginning of the testing (in a new NOTRUN state) and use the
option in the VM tests.
Signed-hostap: Johannes Berg <johannes.berg@intel.com>
Johannes Berg [Thu, 31 Oct 2013 14:36:44 +0000 (15:36 +0100)]
hwsim tests: Create results database in VM tests
Create a results.db in the output directory when running
the tests in a VM. To make that easier, create the tables
in the python script if they don't exist.
Signed-hostap: Johannes Berg <johannes.berg@intel.com>
Johannes Berg [Thu, 31 Oct 2013 14:02:50 +0000 (15:02 +0100)]
hwsim tests: Refactor test results reporting
Refactor the test reporting to treat the different results
(success/skip/failure) identically. This makes the timing
seem a bit longer, but cleans up the code which will allow
for adding more checks (e.g., on the captured data files)
later.
Signed-hostap: Johannes Berg <johannes.berg@intel.com>
Johannes Berg [Thu, 31 Oct 2013 13:22:20 +0000 (14:22 +0100)]
hwsim tests: Allow setting KERNEL and KVMARGS
Rather than just having KERNELDIR, allow setting KERNEL directly.
Also remove the -s option that prevents running multiple machines
at the same time, but add a KVMARGS= variable that can be used to
restore that if needed.
Signed-hostap: Johannes Berg <johannes.berg@intel.com>
Jouni Malinen [Fri, 1 Nov 2013 08:31:55 +0000 (10:31 +0200)]
P2P: Clear pending group formation data on group removal
It was possible for the wpa_s->show_group_started and wpa_s->go_params
to be left set when a P2P group was removed before group formation had
completed. In case a separate P2P group interface was not used, this
could rsult in all future scans using the hardcoded DIRECT-* SSID and as
such, not find the network they were trying to find. Fix this by
clearing these P2P parameters on group removal.
Jouni Malinen [Fri, 1 Nov 2013 08:30:50 +0000 (10:30 +0200)]
P2P: Debug print reason for specific SSID for scan
It can be useful to see whether the specific P2P SSID was used for scan
based on p2p_in_provisioning or show_group_started when debugging issues
where this case shows up unexpectedly.
Jouni Malinen [Thu, 31 Oct 2013 17:41:42 +0000 (19:41 +0200)]
Allow add-BSS operation to re-use existing netdev
When removing and re-adding the first wlan# netdev to hostapd
dynamically, the netdev is already present and should not be removed and
re-added to maintain its state as not-added-by-hostapd so that it does
not get removed automatically.
Jouni Malinen [Thu, 17 Oct 2013 15:56:30 +0000 (18:56 +0300)]
hostapd: Allow a single BSS to be removed from an interface
The global control interface command "REMOVE <ifname>" can now be used
to remove a single virtual interface (BSS) without affecting other
virtual interfaces on the same radio.
Kyeyoon Park [Wed, 30 Oct 2013 23:34:32 +0000 (16:34 -0700)]
hostapd: Allow the first BSS in a multi-BSS setup to be removed
This moves the vif added check from core hostapd to the driver wrapper
(only driver_nl80211.c uses this) and reorders operations a bit to allow
the first BSS (vif) to be removed from a multi-BSS setup.
Jouni Malinen [Thu, 31 Oct 2013 19:55:17 +0000 (21:55 +0200)]
nl80211: Fix monitor interface reference counting
The first user of monitor interface was not counted and that could
result in the monitor interface getting removed if the initial interface
was removed from a multi-BSS setup.
Michal Kazior [Thu, 31 Oct 2013 12:51:44 +0000 (14:51 +0200)]
DFS: Add support for multi-BSS
If radar was detected single BSS is notified about it. This caused only
that single BSS to be stopped and restarted. However, due to nl80211
interface combinations the BSS was not started on a new channel and
other BSSes remained operating on the old channel.
The downside is that hostapd_disable_iface() causes deauth frames to be
sent. This is undesired but on the other hand it doesn't make sense to
create workarounds that imitate CSA's 'block tx'. For proper Tx
quiescing CSA should be properly implemented.
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Jouni Malinen [Thu, 31 Oct 2013 10:46:42 +0000 (12:46 +0200)]
tests: Split run-tests.py logger info into per test case files
The run-tests.py -l argument does not take an argument value anymore.
Instead, debug output is directed to a separate file <test>.log for each
test case.
Jouni Malinen [Thu, 31 Oct 2013 09:26:52 +0000 (11:26 +0200)]
tests: Remove last-debug creation
This file was used for adding debug info into the buildbot logs. The new
sqlite database-based design will replace that, so there is no need to
create last-debug and getting rid of it will make it easier to split the
run log into per-test case files.
Jouni Malinen [Thu, 31 Oct 2013 08:43:02 +0000 (10:43 +0200)]
tests: Fix sqlite run column to be an integer
Commit 781b65cfbb444e2a479f2ea282879b5678235413 ended up accidentally
changing this from an integer to a string. Fix this by not converting
the variable into a string.