In order to send passive beacon-requests, channel and op-class of nodes
are required. Obtain this information per local-node from hostapd.
Signed-off-by: David Bauer <mail@david-bauer.net>
Currently the min_snr option will result in kicking clients the first
time their SNR dips below.
This might not be desirable, as drivers (notably ath10k) sometimes
report a much lower RSSI for a short timeframe after returning to
sensible values. Also, a device might be in the process of roaming just
to be kicked before.
Add the min_snr_kick_delay option. A client will be kicked after this
timeframe when it's SNR is below the min_snr threshold value over the
complete timeframe.
Signed-off-by: David Bauer <mail@david-bauer.net>
Make usteer handle incoming BSS-transition requests. Update with the
most active roaming neighbors like we already do for imminent
disassociations.
Create a new ubus method which calls hostapds bss_transition_request
method. This does not set the disassoc imminent bit, thus will not
automatically disassoc the requesting STA.
Signed-off-by: David Bauer <mail@david-bauer.net>
Don't determine a finished client scan based on whether the current node
has seen a beacon or not.
This works surprisingly bad on 5 GHz nodes, as clients may refuse to
perform active scanning on this frequency band. In case the clients does
refuse to scan the 5 GHz band but scans the 2.4 GHz band actively, we
might have a good indication about a better node on this band at least.
However, as the roam state-machine requires to have seen a probe request
from the client to direct him to a better node, thi process will not
continue, which either ends the node in being kicked due to exceeding
the number of max tries or the scan cooldown to kick in.
The solution to this is fairly simple: Don't track the roam_scan_done
state but instead just determine a better candidate after the scan
interval finished.
To ensure the indicated signal levels are as recent as 2 *
scan-interval, add a max_age parameter to find_better_candidate.
Signed-off-by: David Bauer <mail@david-bauer.net>
The logic guarding entering of the SCAN state of the roam state-machine
was incorrect in case the scan-timeout was not enabled.
Signed-off-by: David Bauer <mail@david-bauer.net>
Add an optional timeout when a better roaming candidate is not found
after the scan-retry limit. The roam state-machine will not retry
scanning before this timeout has expired.
If the timeout is set to 0, the client is kicked instead, which
resembles the behavior prior this commit.
This is added, as without this patch, if a forced disconnect
is not desired before roam_scan_trigger is exceeded the client will
repeatedly be asked to return active beacon-reports. For battery powered
clients this can result in a noticeable battery drain.
Signed-off-by: David Bauer <mail@david-bauer.net>
Don't select a node as a better candidate where a STA has insufficient
signal to. This is the case when the roam_trigger_snr is greater than
the projected signal of the client.
This stops clients from being selected to roam to a node where the
signal is not sufficient to maintain the connection. A selection might
otherwise happen e.g. due to better channel load on the remote node.
Signed-off-by: David Bauer <mail@david-bauer.net>
Export snr_to_signal to other source files. This will be necessary to
determine reported signal strengths from beacon-report throughout the
code base.
Signed-off-by: David Bauer <mail@david-bauer.net>
This reduces the return traffic from clients by only responding with
beacon reports for the current SSID.
Signed-off-by: David Bauer <mail@david-bauer.net>
The logic for customizing the remote_node_timeout config option was
missing. The default value of 10 could not be altered by a user.
Add the required logic and a short explanation of the config-option to
the default configuration.
Signed-off-by: David Bauer <mail@david-bauer.net>
When kicking clients due to high channel load, explicitly only select
new candidates in case their channel load is an improvement over the
current node.
Signed-off-by: David Bauer <mail@david-bauer.net>
Logic for handling STA transition to disconnected state is
present multiple times. Create a new method to remove
duplicate code.
Signed-off-by: David Bauer <mail@david-bauer.net>
Move the sta frequency-seen logic to usteer_sta_info_update.
This method is called on every occurence the seen frequency
is set now, thus removing the duplicate code.
Signed-off-by: David Bauer <mail@david-bauer.net>
It is not necessary to check if the candidate is not considered
reverse-better, as this is already done inside is_better_candidate for
all relevant criteria.
Signed-off-by: David Bauer <mail@david-bauer.net>
A unset bitmask leads to the candidate selection always return no
candidate, even if there is one.
To select a better candidate regardless of it's classification, provide
a bitmask containing all selection criteria.
Signed-off-by: David Bauer <mail@david-bauer.net>
Move the roam event counters to a dedicated struct.
Update the ubus output to represent this new organization.
Signed-off-by: David Bauer <mail@david-bauer.net>
Some clients seem to ignore scan requests with unreasonably high
measurement durations. This was observed with a Google Pixel 4A as well
as a Xiaomi Mi 10T.
Advertise a scan duration which closely matches the roam scan-interval.
This triggers scans more reliably with the aformentioned devices.
Signed-off-by: David Bauer <mail@david-bauer.net>
When determining a new node within the roam state machine, require the
destination node to have a better reported signal from the client.
Otherwise, the roam state machine might trigger a roam action for a
unsuitable destination node.
Signed-off-by: David Bauer <mail@david-bauer.net>
Don't request measurements from STAs which do not support the specific
measurement mode. Otherwise, hostapd complains in the syslog about
unsupported measurement modes.
Signed-off-by: David Bauer <mail@david-bauer.net>
Save the RRM capabilities of STAs when updating clients from hostapd.
This is required to determine which measurement modes a STA supports.
Signed-off-by: David Bauer <mail@david-bauer.net>
Currently, the neighbor report list is sorted based on the total amount
of roam actions to and from the specific foreign nodes.
This does not take into account that nodes might not be created at the
same time. When a popular neighbor node reboots, it's roam actions are
reset and it's ranking might not recover for a long amount of time
depending on how long the local node is already running.
Change this shotcoming to take into account the timestamp at which a
node was created. This way, the ranking depends on the amount of roam
actions relative to the nodes uptime / seen-time.
Signed-off-by: David Bauer <mail@david-bauer.net>
Save the timestamp of the node creation. This is required to optimize
the selection of most-roamed to neighbors relative to their creation
time.
Signed-off-by: David Bauer <mail@david-bauer.net>
Apply the same logic for selecting the most relevant neighbors also when
sending transition requests to STAs.
Signed-off-by: David Bauer <mail@david-bauer.net>
Prioritize neighbor candidates installed to hostapd. Add a new config
option to set a limit for neighbor reports installed to hostapd. This is
due to the fact, most devices will only evaluate a certain amount of
neighbor reports. Furthermore, the number of neighbor reports possible
is limited by the maximum frame size.
Signed-off-by: David Bauer <mail@david-bauer.net>
Keep track of STA journeys between multiple nodes. When a new STA is
reported from a foreign node, check whether this STA was previously
associated with a local node.
Vice versa, check upon association whether or not the STA was previously
associated with a foreign node.
Keep track of these roaming transactions using two new (local) fields of
the node struct.
Signed-off-by: David Bauer <mail@david-bauer.net>
Add a last_connected field to the sta_info struct. This field can be
used to determine, if and when a client was last connected to a given
node. This way, other nodes can determine where a client roamed to or
from.
Signed-off-by: David Bauer <mail@david-bauer.net>
This commit fixes updates not triggering due to a race-condition in
usteer.
When usteer does not yet have local-nodes when loading config, the
scheduled remote-update is not re-scheduled, leading to usteer only
exchanging node-messages on STA-events, leading to expiring remotes on
other remote nodes in low-event scenarios.
Signed-off-by: David Bauer <mail@david-bauer.net>
The codes looks to have a race-condition, where disconnected sta_infos
are created without scheduling a timeout.
As sta_infos are not connected by default, schedule the timeout upon
sta_info creation.
Fixes spurious spamming of "Refuse to add an already expired station
entry" on remote nodes.
Signed-off-by: David Bauer <mail@david-bauer.net>
The IEEE802.11-2016 specification says:
[...] a Channel Number field value of 255 indicates a request
to make iterative measurements for all supported channels in the
current operating class listed in the latest AP Channel Report
received from the serving AP.
The problem with this is, no AP Channel report is sent to the STA with
the measurement request.
To scan the whole Operating class, a channel number of 0 is desired:
[...] Channel Number field value of 0 indicates a request to make
iterative measurements for all supported channels in the operating
class [...]
Signed-off-by: David Bauer <mail@david-bauer.net>
When checking whether a client is allowed to associate to a node, the
lower ceiling for kicking clients was not taken into account when
assoc-steering is disabled.
The problem behind this is, that a configured lower barrier for
disassociating clients (kicking) would kick the client immediatly after
association. In the worst scenario the client immediatly associates
again to the station and ends up in a kick loop.
Don't allow associating when a min_snr is configured and the client
signal is below this value.
Signed-off-by: David Bauer <mail@david-bauer.net>
Make the connection state of a sta-info more readable by introducing an
enum for the STA connection state.
Also switch come comparison cases to use the explicit enum values to
make the code more readable.
Signed-off-by: David Bauer <mail@david-bauer.net>
Add the node BSSID to messages exchanged between usteer hosts. This way,
a foreign node can determine the node reported by a STA using beacon
reports.
Signed-off-by: David Bauer <mail@david-bauer.net>
Add the node BSSID to the usteer_node struct. This will be helpful in
the future when evaluating beacon reports from STAs.
Signed-off-by: David Bauer <mail@david-bauer.net>
The host address is allocated on the heap, hence it has to be freed when
freeing the containing struct.
Signed-off-by: David Bauer <mail@david-bauer.net>
When checking if the hostaddresses match up, the result returned from
strcmp was incorrectly evaluated. strcmp returns 0 in case both strings
match.
Signed-off-by: David Bauer <mail@david-bauer.net>
Add a build dependency for libpcap, as it is required for the monitor
utility but not usteer itself. Use a build-dependency, as the monitor
utility executable is not packaged.
Signed-off-by: David Bauer <mail@david-bauer.net>
The name pointer provided by ubus get's cleared after the first call to
ubus_register_subscriber in usteer_get_node. The leads to an incorrect
ifindex returned by if_nametoindex due to the 0 characters long string.
Work around this issue by reusing the interface name already stored in
the local node struct.
Fixes querying the wrong interface with netlink, resulting in incorrect
SSIDs used for the nodes.
Signed-off-by: David Bauer <mail@david-bauer.net>
This adds optional support for message exchange using IPv6 multicast
messaging. This has the ability for routers and switches between nodes
to route traffic between usteer nodes multicast-aware.
By default, IPv4 is used. IPv6 can be enabled by configuring the ipv6
option to 1.
Signed-off-by: Jan Braun <keksgesicht23@gmail.com>
[squash commits - adapt usock usage]
Signed-off-by: David Bauer <mail@david-bauer.net>