Commit graph

124 commits

Author SHA1 Message Date
Chen Minqiang
47e98efed6 network: ping pong keepalive for tcp connections
To make the tcp connections keepalive and better handle the timeout
of connections

con_timeout indicate the connection timeout and it is configurable

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
2022-07-21 16:56:59 +02:00
Nick Hainke
eba03547a5 network: add timeout for client connections
Somtimes client connetions will not close therfore add a timeout. Add a
new timer that checks every 5s if we did not receive anything from a
client for (default) 60s. Can be configured via client_timeout.

Code is based on the work of ptpt52.

Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-07-21 16:56:59 +02:00
Eneas U de Queiroz
e596ff1317 ubus.c: only add nr entries matching our own SSID
The preferred neighbors list may have BSSIDs with different SSIDs.  Add
only those that match the interface's SSID.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2022-07-18 17:50:50 +02:00
Nick Hainke
181549f7bb ubus: add missing lock for ubus hearing_map
In the build_hearing_map_sort_client there was a dawn_mutex_require
without having locked the mutex resulting in warnings:

  daemon.warn dawn: MUTEX require = 4226B8@ubus.c:2003[2012069248l] - appears to be UNLOCKED!
  daemon.warn dawn: MUTEX require = 4226B8@datastorage.c:694[2012069248l] - appears to be UNLOCKED!

I guess it was a typo, because before entering the
client_array_get_client function the mutex client_array_mutex needs to
be locked and not required.

Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-07-16 19:31:48 +02:00
Alexander Georgievskiy
4b7db09166 CONFIGURE.md: fix typo
[Nick: rephrase commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-07-07 08:04:40 +02:00
Nick Hainke
b3f61d4703 CONFIGURE.md: adjust documentation about log levels
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-07-04 14:43:00 +02:00
Nick Hainke
58861a1adb memory_utils: fix reallocation
Fixes errors in the form of:
  dawn: mem-audit: Releasing memory we hadn't registered (tcpsocket.c:142)...
  dawn: mem-audit: attempted to register memory already registered (M@tcpsocket.c:114)...

Fixes: 850a75c182 ("fix compilation with GCC12")

Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-13 22:51:28 +02:00
Ian Clowes
5d8df44a3a treewide: code and documentation cleanup
Tidy up a few bits of code - nothing very significant.
Documentation fixes and updates

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
8290138179 datastorage: Minor chnages to kicking algorithm to tidy up some handling.
[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
c212c5469f treewide: improve beacon/probe logging
Modifications to BEACON and PROBE handling to improve understanding of
RSSI and RCPI / RSNI values. Also address bugs in frequency / band handling.

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
92eac61d30 treewide: improve beacon request handling
Updated approach to sending BEACON REQUEST. Each AP asks every 802.11k
enabled client for the BEACON REPORT of a single other AP in the network
at N second intervals, where N is the refresh period / num-APs. N seconds
later the request is sent for the next AP.

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
359dd085aa datastorage/ubus: Add "soft" kicking algorithm
In addition to scored "hard" kick for all clients (inc. legacy), add a "soft"
kick for 802.11v aware clients by always asking them to  move if below
threshold RSSI, but with no mandatory disassociation.

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
d37a768766 treewide: RSSI / RCPI handling updates
Adjust how RSSI levels are shared and stored to help visibility of activity

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
c54cd95abe documentation: Parameter defaults and documentation
- Updated documentation files to describe parameters
- "Self-documenting" parameters added to code
- Parameter defaults revised
- Sample configuration file of defaults added

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
ba305bb2c2 treewide: cleanup code
- Remove some unused data fields
- Fix a few typos in comments, etc

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
8064e56899 scoring: improve scoring algorithm
- Simplify how score is tracked
- Streamline some code paths for scoring evaluation to reduce data searches, etc
- Allow more entries to be considered for AP NR

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
b7e3d6f34d treewide: cleanup code
- Revise some messages so meaning is clearer
- Fix some whitespace, etc
- Simplify a coiuple of small functions

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
829fa0faed kicking: improve kicking algorithm
- Tweak disassociate / kick NR code to reduce build overhead
- Add set_hostapd_nrdynamic == 2 to build of AP local station NR from what current clients hear elsewhere
- Tighten up hex string length usage for strncpy(), etc

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
60ea5b4daf treewide: improve mutex handling
- Add dawn_mutex_require() to indicate when code is accessing resources
- Use pthread_mutex_trylock() to actively test required mutex are locked

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
32d6d6d57d test: cleanup tests and add some test scripts
- Tighten up a bit of test path coding
- Add some test scripts (not fully revised for current code)

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
5b1eddc6f4 treewide: fix bugs from Coverity Scan
- Fix a couple of bugs in hardly ever (never?) used code paths that Coverity spotted
- Add comments for things that look a bit odd, but not sure if they are bugs

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
4a88222722 utils/storage: improve descriptions
Add messages that help users understand what PROBE and BEACON messages
are being used.
Remove a few things that are no longer needed: #includes, etc

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
39d7e838ae ubus: Simplify loops and scans in generating hearing map
[clean commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
be49c35686 treewide: rework mutex
Wrap mutex calls with traceable messages to help debugging resource locks.

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
0a962bea1f network: cleanup and improve network handling
- Merge encoded / plain messge handling to ensure fixes land in both
- Fix some potential resource leaks spotted by Coverity

[cleanup commit message]
[fix merge conflicts]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
0eca0fae0b utils: cleanup
- Simplify linked list search - code was unnecessarily complex for no benefit
- Refactored parse / kick logic to simplify functions

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
5d7f99dded utils/storage: cleanup
- New skipping linked list structure - possible bug in previous version
- Adjust some function names to better reflect what actually happens
- Remove redundant configurable sort elements
- Remove probe structure SSID field which is not set via BEACON, so is unreliable
- Adjust way the different fields from BEACON and PROBE reports are handled / merged
- Made client / BSSID paramater order consistent for probe / beacon functions to help avoid cut/ paste bugs
- Add RRM capability, RCPI and RSNI to client in hearing map (which is a summary of probe / beacon entries)

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
6bf3cd7754 ubus/datastorage/msghandler: cleanup
- Simplify linked list search - code was unnecessarily complex for no benefit
- AP record is uniquely identified by BSSID, so remove unnecessary search on SSID as well
- Change some data handling to simplify passing of records, pointers, etc
- Assure sort order to simplify generating network map
- Removed unused fields for collision domain and bandwidth

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
6e03e37ce8 datastorage: improve linked list
- Simplify linked list search - code was unnecessarily complex for no benefit
- Adjust some MAC address handling to simplify code

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
160ccf8917 ubus/datastorage: cleanup
- Remove the linked list of rejected auth / assoc as it was not used for any decision making
- Rename auth_req to client_req as it is also used by association requests

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
8bae43c811 utils: cleanup
Move some RRM utility functions around to simplify code structure / #includes.

[fix commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 20:27:20 +02:00
Ian Clowes
0e4fc507cb documentation: Heavily revised Markdown documentation files:
- README.md: Top level intro
- INSTALL.md: Typical user installation
- CONFIGURE.md: Detailed description of how parameters work together, and how to set each one
- DEVELOPER.md: How to build a local version, some notes on dev time "helpers", etc

[fix commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-11 19:36:31 +02:00
Rosen Penev
850a75c182 fix compilation with GCC12
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2022-06-09 07:59:49 +02:00
Nick Hainke
2ac7b9d408 workflow: fix workflow
Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-06-09 07:57:27 +02:00
Stijn Tintel
2bfd7397e1 ubus: use bss_transition_request
OpenWrt's hostapd now supports the more generic "bss_transition_request"
method that allows initiating a BSS transition request with the
Disassociation Imminent bit not set. Use this new method instead of
"wnm_disassoc_imminent" so that the old method can be removed.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2022-05-09 15:53:04 +02:00
Ian Clowes
7a72674063 datastorage/ubus: rework kicking algorithm
Refresh of kicking algorithm to minimise messages and streamline some code.
Removed decide_function() which made some logic hard to follow.
Removed kick_client() function to streamline code.
Revised kicking algorithm code to give better user messages.

Signed-off-by: Ian Clowes <clowes_ian@hotmail.com>
2022-01-17 10:10:47 +01:00
Ian Clowes
877e2dc22f iwinfo: fix get_bandwidth_iwinfo
Bug that was preventing kicking working due to mishandling of bandwidth
discovery. Fixed bug in use of get_bandwidth_iwinfo() in AP kicking.
Fix rounding of transmission rate calculations in
get_bandwidth_iwinfo().
Restructure of get_bandwidth...() while finding bug.

Signed-off-by: Ian Clowes <clowes_ian@hotmail.com>
2022-01-17 10:10:47 +01:00
Ian Clowes
9ce01ecce5 datastorage: fix multi-SSID
Bug that could proably cause ineffciency or confusion in multi-SSID
environments.
Adjusted erroneus match test in ap_array_insert().

Signed-off-by: Ian Clowes <clowes_ian@hotmail.com>
2022-01-17 10:10:47 +01:00
Ian Clowes
9187665f8e treewide: improve maintaince
General revisions to maintain code (no functional changes intended).
Removed unnecessary linked-list length checks.
Fixed some typos on function names / comments.
Changed how test_storage forces SEGV due to new compiler warnings.

Signed-off-by: Ian Clowes <clowes_ian@hotmail.com>
2022-01-17 10:10:47 +01:00
Ian Clowes
6bf9b6df9a memory: Tighten up some memory handling to help spot errors
Set pointers to NULL after free() to help force out memory handling errors.
Add some extra memory / resource tracking to try and chase out latent
bugs / leaks Fixed a couple of memory traces that were misreporting.

Signed-off-by: Ian Clowes <clowes_ian@hotmail.com>
2022-01-17 10:10:47 +01:00
Ian Clowes
4df0c986f1 treewide: improve logging
Provide multi-priority syslog() based logging to improve user and
developer experience. Add dawnlog_* functions and macros to convert
printf() family and perror() logging to syslog() family. Removed
unnecessary sprintf() for building log strings (embed format directly).
Add local config settings for log level. Add command line parameters for
log level and destination. Set default log level to suppress a lot of
previously noisy messages. Restore some previously removed noisy
messages as DEBUG level in case they help in future. Eliminate DAWN_NO_OUTPUT static code checks which are no longer used.

Signed-off-by: Ian Clowes <clowes_ian@hotmail.com>
2022-01-17 10:10:47 +01:00
Eneas U de Queiroz
ddc007e32c ubus: avoid use after free in handle_probe_req()
Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-10-26 00:22:13 +02:00
Nick Hainke
e1275713c0 github: fix workflow
The current sdk changed from gcc 8 to gcc 11.2.0.

Signed-off-by: Nick Hainke <vincent@systemli.org>
2021-10-25 21:30:19 +02:00
Nick Hainke
7f1cb85432 ubus: use local blub_buffer definitions and free
Remove all global buffers and define them locally instead. Further,
use ctx_local as new name to be sure referencing the correct ctx
context. Further, free buffer after using it.
2021-10-13 11:06:22 +02:00
Eneas U de Queiroz
c9f6684021 Remove some debugging messages
Remove some of the debugging messages, so that, hopefully, only the
relevant ones are shown.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00
Eneas U de Queiroz
c70773a171 datastorage: use signal strength as a metric
This adds a few options to use the signal strength as a metric, band
dependent:

 - rssi_weight: every db of signal increases the score by this much.
 - rssi_center: if the signal is stronger than this, the score becomes
                positive; below this, it is negative.
 - initial_score:  since we are capping negative scores, it may be
   beneficial to have a positive base score to offset a possible
   negative signal value.  This is replacing the 'freq' metric.

To avoid a single-digit RSSI increase resulting in a kick, we add a
global threshold value to act as a buffer:

 - kicking_threshold: a candidate AP must have a score larger than that
                      of the current AP plus the value here.

The kicking_threshold also applies when assembling the list of roaming
neighbors we send with the "wnm_disassoc_imminent" command.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00
Eneas U de Queiroz
14e0f8386c Don't display debugging output with DAWN_NO_OUTPUT
This adds #infndef DAWN_NO_OUTPUT to messages printed to stdout that are
not warnings or errors.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00
Eneas U de Queiroz
97e5de157f uci: add neighbor list priority options
This adds config options to define MACSs of neighbors to be on top of
each band's neighbor list.  This is important, because some clients will
limit the number of entries they use.  iOS devices, for exmample, use
only the top 6 APs.

The neighbors_11g and neighbors_11a take a list or space-separated
string of AP BSSIDs to keep at the top of each band's neighbor report.

The list is used when the neighbor report is being assembled.  Any
listed AP that is not online will not be included in that report.  When
the next report is assembled, if the AP is back online, then they are
restored to the indicated order.

There's only one list for each band.  In case of multiple SSIDs, you can
include BSSIDs for all of them, and they will be filtered by SSID when
assembling the reports.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00
Eneas U de Queiroz
2b1a53cddc dawn_uci: set default values
This sets the default metric values to the ones currently used in the
openwrt package config file.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00
Eneas U de Queiroz
6eb747b4d4 Use separate configs for 802.11g & 802.11a bands
This changes the metrics variables that invove scores to arrays.  At the
momemnt, there are two bands implemented, 802_11a and 802_11g.
Internally, they are chosen based on the frequency of the channel being
used.  Anything < 2500 MHz is 802_11g, and everything else is 802_11a.
Dawn will issue a warning if it finds a frequency greater or equal to
5925 MHz.  The upper limit of the 802.11a band, and the start of the
next band vary by country, so this will have to be reviewed.

The UCI configuration changes.  Instead of a single metric config, there
will be a global metric config, and one for each band.  The
non-band-specific configuration will only work in the global config.
Any per-band configuration present at the global config will be applied
to all bands.  Any configuration present at the specific band will
override any global values.

The following configuration options are split into bands:
 - ap_weight
 - ht_support
 - vht_support
 - no_ht_support
 - no_vht_support
 - rssi
 - rssi_val
 - low_rssi
 - low_rssi_val
 - freq
 - chan_util
 - max_chan_util
 - chan_util_val
 - max_chan_util_val

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00