3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-05 11:39:24 +01:00
Commit Graph

75 Commits

Author SHA1 Message Date
James Prestwood
5567caf64a hwsim: add iftype/cipher disabling through DBus
Update the Dbus API to allow disabling iftypes and ciphers
just as you can with the command line.
2020-12-17 20:11:25 -06:00
James Prestwood
6a1853b01a hwsim: change radio Create() to take a dictionary
The Create() API was limited to only taking a Name and boolean
(for p2p enabling). The actual hwsim nl80211 API can take more
attributes than this (which are actually utilized when creating
from the command line). To get the DBus API up to the same
functionality the two arguments in Create were replaced with
a single dictionary. This allows for extending later if more
arguments are needed.
2020-12-17 20:10:33 -06:00
James Prestwood
799ab03f59 hwsim: check pending_create_msg before replying
In the NEW_RADIO callback hwsim was assuming that DBus had no
yet replied to the Create() method. In some cases the NEW_RADIO
event fires before the actual callback which will respond to
DBus. This causes a crash in the create callback.
2020-12-17 20:08:54 -06:00
James Prestwood
554a78fbf0 hwsim: add --no-register option
Starts hwsim but does not register to mac80211_hwsim. This is to
allow autotests to disable hwsim, while still having the ability
to create/destroy radios over DBus.
2020-12-17 20:08:49 -06:00
Alvin Šipraga
bfd8cead95 treewide: guard compare functions against signed integer overflow
Besides being undefined behaviour, signed integer overflow can cause
unexpected comparison results. In the case of network_rank_compare(),
a connected network with rank INT_MAX would cause newly inserted
networks with negative rank to be inserted earlier in the ordered
network list. This is reflected in the GetOrderedMethods() DBus method
as can be seen in the following iwctl output:

  [iwd]# station wlan0 get-networks
    Network name                    Security  Signal
  ----------------------------------------------------
    BEOLAN                          8021x     **** }
    BeoBlue                         psk       ***  } all unknown,
    UI_Test_Network                 psk       ***  } hence assigned
    deneb_2G                        psk       ***  } negative rank
    BEOGUEST                        open      **** }
  > titan                           psk       ****
    Linksys05274_5GHz_dmt           psk       ****
    Lyngby-4G-4 5GHz                psk       ****
2020-08-14 10:55:30 -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
7641782924 tools: delay hwsim sending frame
Using mac80211_hwsim can sometimes result in out of order messages
coming from the kernel. Since mac80211_hwsim immediately sends out
frames and the kernel keeps command responses in a separate queue,
bad scheduling can result in these messages being out of order.
In some cases we receive Auth/Assoc frames before the response to
our original CMD_CONNECT. This causes autotests to fail randomly,
some more often than others.

To fix this we can introduce a small delay into hwsim. Just a 1ms
delay makes the random failures disappear in the tests. This delay
is also makes hwsim more realistic since actual hardware will always
introduce some kind of delay when sending or receiving frames.
2020-05-01 20:38:15 -05:00
Denis Kenzior
0508879e2a hwsim: Use L_DBUS_PROPERTY_FLAG_AUTO_EMIT 2020-01-29 10:51:40 -06:00
Torstein Husebø
759dbdd37f treewide: fix typos 2020-01-21 16:03:28 -06:00
Denis Kenzior
fb76ca1f1c hwsim: Update to the new ell API 2019-10-28 15:02:30 -05:00
Marcel Holtmann
152b56a12a treewide: Move the Intel copyright forward to 2019 2019-10-25 00:43:08 +02:00
Tim Kourt
25b3cb77e1 hwsim: Fix potential memory leak
If msg has multiple RADIO NAME attributes, memory leak occurs.

Note that this doesn't happen in practice.
2019-10-23 17:58:51 -05:00
Denis Kenzior
b6554ee41c hwsim: Invoke l_queue_remove prior to object deletion
While the current code is quite safe, the new ordering makes more
logical sense and doesn't confuse static analysis tools.
2019-10-17 13:03:08 -05:00
Denis Kenzior
dea23bede7 tools: Update hwsim to the new genl api 2019-05-17 17:10:13 -05:00
James Prestwood
0e31b33631 hwsim: allow specific radio iftypes/ciphers
mac80211_hwsim now allows setting supported iftypes/ciphers. This patch
enables this support in hwsim. Specific iftypes/ciphers can now be
disabled via the command line when creating a radio:

Disable iftypes:
--iftype-disable station,ap,adhoc,p2p_client,p2p_go,mesh_point

Disable cipher types:
--cipher-disable ccmp,tkip,wep
2019-05-13 16:38:23 -05:00
Denis Kenzior
a4512f3cd6 hwsim: Use l_genl_family_set_unicast_handler 2018-11-02 15:52:56 -05:00
Marcel Holtmann
554e4f55db build: Fix includes for using with -std=c99 compiler option 2018-11-01 22:37:11 +01:00
Marcel Holtmann
72a64fa7fb build: Adjust to the latest ELL signal API changes 2018-11-01 22:09:19 +01:00
Marcel Holtmann
36f5056810 hwsim: Use l_main_run_with_signal instead of open coding it 2018-11-01 19:58:34 +01:00
James Prestwood
a2df686d97 hwsim: limit "Unknown attribute type:" print
Since we don't catch all hwsim attribute types in unicast_handler
you see tons of "Unknown attribute type: X" prints. Since this is
not an error, we should only print if the attribute does not exist
in the attribute list.
2018-10-24 16:23:12 -05:00
James Prestwood
ceca5c42ba hwsim: update hwsim attrs to latest mac80211_hwsim 2018-10-24 16:23:12 -05:00
Marcel Holtmann
ea20559599 tools: Change net.connman.iwd.hwsim to net.connman.hwsim 2018-09-14 15:27:57 +02:00
Marcel Holtmann
b88388b172 hwsim: Fix missing handling of help option -h 2018-09-14 15:17:14 +02:00
Andrew Zaborowski
465488878e hwsim: Look up radio address in radio_info
In mac80211_hwsim each radio is assigned two addresses, the second (addr
1) being used over nl80211.  In SendFrame we'd hardcode the mapping of
address 0 to address 1 even though we track all the addresses in radio_info,
so instead use that data to find the radio that has given address 0.  Also
if no address 0 matches what was supplied over DBus try to find a matching
address 1.

There are ways userspace can request different addresses when managing
mac80211_hwsim radios and the hardcoded mapping would become wrong.
2018-05-22 11:35:57 -05:00
Andrew Zaborowski
676a1f48c3 hwsim: Don't crash if source radio not found
We already print an error when this happens, no need to crash.
2018-05-22 11:35:05 -05:00
Denis Kenzior
17f55f3b4a hwsim: Fix leak of send_frame_info->user_data
In case the genl object is cleaned up prior to the callback being
called, the DBus message might get leaked.  Can only happen in bizarre
cases.
2018-01-30 23:03:07 -06:00
James Prestwood
f22ec55efb hwsim: add spoofing frame support
Added a new method SendFrame() under the radios .Interface
interface. This method takes two byte arrays as parameters,
first is the station address to send the frame to, and the
second is the raw frame data.
2018-01-30 22:59:32 -06:00
Andrew Zaborowski
a7ee2c428a hwsim: Use util_is_broadcast_address
Replace is_multicast_addr with util_is_broadcast_address usage.
is_multicast_addr seems to have been wrong, first because we're not
interested in just any multicast address (defined to be same as "group
address"), but rather specifically the broadcast address, as we don't
know of any specific address groups other than broadcast.  And also
wrong because the "Individual/Group bit" is the LSB of byte 0, not the
MSB of byte 0 apparently.
2017-09-22 10:09:01 -05:00
Andrew Zaborowski
c8854d9a4c hwsim: Use new mpdu.h structs 2017-08-31 15:13:09 -05:00
Andrew Zaborowski
bf86081eba hwsim: Add Rule.Drop property
Add a way to have matching packets dropped by the hwsim medium.
2017-08-23 13:26:58 -05:00
Andrew Zaborowski
1338c446b0 hwsim: Watch RTNL NewLink events
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.
2017-03-28 15:26:02 -05:00
Andrew Zaborowski
dff92b9c76 hwsim: Fix the Interface.Addresses property type 2017-03-26 11:04:42 -05:00
Andrew Zaborowski
2411d24c87 hwsim: Don't require full mpdu_mgmt_header in frames
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.)
2017-03-14 10:26:17 -05:00
Andrew Zaborowski
0e2a7c479f hwsim: Drop the -k/--keep switch, always keep radios
It didn't make any sense for hwsim to be called in the create mode to
have it create a radio to be destroyed immediately afterwards as hwsim
exited.
2017-03-14 10:25:44 -05:00
Andrew Zaborowski
48b90febf1 hwsim: Don't handle netlink events in command mode
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.
2017-03-14 10:24:51 -05:00
Andrew Zaborowski
10d96e5c19 hwsim: Add terminating 0 byte to attribute
Similar to 21a9b064d3 also include the NUL
byte in the name attribute when creating a radio through DBus call.
2017-03-14 10:24:08 -05:00
Andrew Zaborowski
ea9edc1f99 hwsim: Fix netlink attribute size calculation
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.
2017-03-14 10:23:28 -05:00
Denis Kenzior
b2642d42bf hwsim: Clean up some trivial style issues
The code had too many empty lines in places where it would be logical to
just group the statements together.
2017-03-10 10:22:44 -06:00
Andrew Zaborowski
cde6401485 hwsim: Add Rule and RuleManager dbus interfaces 2017-03-10 10:13:23 -06:00
Andrew Zaborowski
3b9785dffe hwsim: Add user-defined rules for frames passed by medium
Define rule structure, add the list of current rules and code to match
frames against rules and apply RSSI changes.
2017-03-10 10:11:09 -06:00
Andrew Zaborowski
7460b6e1a7 hwsim: Add wmedium implementation
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.
2017-03-10 10:09:05 -06:00
Andrew Zaborowski
6280a6c72d hwsim: Use an array of addresses for radio_info_rec.addrs
Make accessing the addrs field easier by converting it from a flat
buffer concatenation of the 2 addresses to an array of 2 arrays of
6 bytes.
2017-03-10 10:03:01 -06:00
Andrew Zaborowski
c537953f11 hwsim: Fix property name typo in notification 2017-03-10 10:02:29 -06:00
Andrew Zaborowski
257aa441a1 hwsim: DBus methods for creating and destroying radios 2017-03-10 10:01:04 -06:00
Andrew Zaborowski
315269fd23 hwsim: Basic DBus interface to radio information
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).
2017-03-09 11:21:21 -06:00
Andrew Zaborowski
43a882e934 hwsim: Replace isspace usage with l_ascii_isspace 2017-03-08 09:43:13 -06:00
Andrew Zaborowski
d03eeb398c hwsim: Refactor radio, wiphy and interface tracking
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.
2017-03-03 11:56:50 -06:00
Andrew Zaborowski
21a9b064d3 hwsim: Include terminating 0 byte in radio name attribute
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.
2017-03-03 11:50:11 -06:00
Andrew Zaborowski
335ee0c31e hwsim: Add daemon mode with radio information tracking
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.
2017-02-23 11:21:18 -06:00
Andrew Zaborowski
dfee120333 hwsim: Fix radio_name_attr length calculation 2017-02-23 11:06:45 -06:00