Commit graph

98 commits

Author SHA1 Message Date
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
Eneas U de Queiroz
1e34357bdc Verify compatibility before parsing config message
This adds a verion field to the ubus configuration message, to avoid
acting upon a message from an incompatible version of dawn.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00
Eneas U de Queiroz
a7a830950a List all neighbors with same score when kicking
The wnm_disassoc_imminent procedure takes a list of neighbor reports to
send to the client.

Instead of picking just one AP to be sent, send all that have the same
score.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00
Eneas U de Queiroz
3ba0fa4947 Change beacon request fields to appropriate values
This changes the op_class, channel, and SSID fields used to send a
beacon request.  Op_class and channel were set from the UCI config file,
but they are dependent on the band being used--they define the frequency
used.  The values can be taken from the AP's own neighbor report.

The SSID was set with a blank string, which would return beacons from
any SSID.  Since we only care about our own SSID, there's no need to
waste resorces with reports from other SSIDs.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00
Eneas U de Queiroz
009aab9ca4 Change mode config parameter from int to string
This renames "mode" to "rrm_mode", and its type from int to string.
This way, we can set the correct mode for a probe request from the STA
reported capabilities, along with the preferred order of modes, set by
the "rrm_mode" uci config.

rrm_mode is a string of possible mode letters:
'p' = passive report
'a' = active report
'b' or 't' = beacon table report.

Setting rrm_mode='pat', will try to send passive reports, if available;
if not, it will try an active report, using a beacon table if all else
fails.

If you don't include a letter, the corresponding report type will be
disabled.  An empty string will disable beacon reports.  Unrecognized
letters are ignored, as well as repeated modes.  If the configuration is
not present, a default value of 'pat' will be used.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-07-28 14:51:42 +02:00
Eneas U de Queiroz
276ca169a7 msghandler: fix rrm array parsing
dump_rrm_table was called from dump_client with the pointer to the table
data, not the table itself.

Since only the first byte is needed, it can be fetched right away
without looping through the table values, so we can just call
dump_rrm_data passing the table data pointer.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-07-27 15:36:53 +02:00
Eneas U de Queiroz
1e4871d70a datastorage: debug rrm capabilities
This adds a debugging line showing the RRM report capabilities bits.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-07-27 15:36:53 +02:00
Rosen Penev
ec9a3a96e8 fix GCC11 compilation 2021-07-11 13:57:24 +02:00
Eneas U de Queiroz
555268b91d ubus: filter neighbors by SSID when preparing nr
Only add neighbors with the same SSID to an interface's neighbor report.
While it is possible to offer roaming to a different SSID, it is often
not desired, while at least Apple devices limit the number of entries
they will use to 6.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-07-08 16:44:04 +02:00
Eneas U de Queiroz
3db9607b14 data storage: match SSID when searching ap entry
Currenty, ap_array_get_ap returns an entry by matching just the bssid,
without checking if the SSID matches.

ap_array_find_first_entry does a binary search through the ap set
without cheking the SSID, which is bad, as the list is sorted by SSID
then by bssid_mac.

As a side effect, if you have more than one ssid, the network ap list
grows unbounded over time.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-07-08 16:44:04 +02:00
Eneas U de Queiroz
a22f5a79d6 storage: ensure SSID strings are NULL-terminated
SSID_MAX_LEN is set at 32, which is the maximum allowed size of a SSID.
The strings holding SSIDs were set at that same size, which does not
allow for proper string termination.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-07-08 16:44:04 +02:00
Polynomialdivision
8ce09d64de CMakeList: fix compiling with glibc 2020-12-31 00:00:33 +01:00
Polynomialdivision
b639145ce9 ubus: fix rrm string callback function
The rrm_nr_get_own call returns an array. We need the 3rd value. We do
not need to call blobmsg_data before blobmsg_get_string to extract the
value. Additionally this causes strange behavior where an offset in the
string is accessed.
2020-09-03 03:45:25 +02:00
Polynomialdivision
c2c0009d61 datastorage: fix hearingmap not synced
The datastorage-refactoring changes an already existing entry instead
of inserting and deleting it. However, it was forgotten to adopt
some information from the new probe entry.

The ht_capabilities and vht_capabilities are now synced correctly.

RCPI and RSNI is now correctly synced.
2020-08-26 12:05:50 +02:00
Polynomialdivision
25a493c438 tcpsocket: add option to add server ip
A new config option allows to add a server ip
	option server_ip '10.0.0.2'

However, this server does not send anything back. Therefore it is not
possible to change the node configuration. This will probably be added
soon. The main goal of this commit is to allow monitoring of all nodes
in a network with DAWN, e.g. clients, channel utilization, ...

Also a network option (3) has been added which allows to use TCP but
not to announce your daemon in the broadcast domain. This allows you to
create a monitor-only node that holds only the local information and
forwards it to the central server.

A monitor-only node could be configured like
	option server_ip '10.0.0.1'
	option tcp_port '1026'
	option network_option '3'

Another possible config is
        option server_ip '10.0.0.1'
        option tcp_port '1026'
        option network_option '3'
Here, the node shares information with a central server, which can be
located outside the broadcast domain. Nevertheless, it also shares
information within its broadcast domain and can therefore perform
client steering.
2020-08-21 23:03:56 +02:00
Polynomialdivision
1da5ad5a96 dawn_uci: fix crashing when uci config is received
Before we can unload the config, we have to search the package again.
2020-08-21 18:31:23 +02:00
Ian Clowes
50d54a6253 tcpsocket: leave loop if we read 0 byte
It can happen that the callback is executed but there are 0 bytes to read. If this happens we leave the while-loop.

Ian Clowes:
- fix

Nick:
- commit message
2020-08-07 12:05:27 +02:00
Ian Clowes
dfbaa055a4 tcpsocket: fix read callback function and arbitrary memory allocations
If not all of the message was in the stream after the header was read,
the next bytes remain in the buffer and only the header is removed from
the stream. The next time the callback is called, something that is not
a header will be interpreted as a header, resulting in arbitrary memory
allocations.

Ian Clowes:
- code

Nick:
- commit message
- fix processing of messages
2020-08-06 23:57:06 +02:00
Ian Clowes
117a340b9d datastorage: fixes to linked list handling
general: fixed whitespace and typos
memory audit: on by default in build
memory audit: enhanced audit info
ubus: refactor denied_req expiry to assist datastorage testing
datastorage: fixed performance bug in handling of linked list entry expiry
datastorage: fixed SEGV in skip list handling
test_storage: added linked list memory allocation stress tests
2020-08-05 12:30:19 +02:00
Ian Clowes
34da5328f6 memory auditing: bug fixes to memory auditing and hearing map
memory auditing: refined auditing code and use in main code
hearing map: fixed bug causing it not be be built correctly
datastorage: fixed memory leak from linked list handling
2020-08-05 12:29:47 +02:00
Ian-Clowes
d56c5c4e15 general: add memory auditing
memory_utils: added to wrap memory alloc / free
general: adjusted stabdard and other memory allocs t be audited
2020-08-05 12:28:49 +02:00
Ian-Clowes
421324486f datastorage: fixed use of wrong client search 2020-08-05 12:27:51 +02:00
Ian Clowes
7262cf02d0 datastorage/test: improve scalability and performance
datastorage: convert to linked lists and optimise use of pointers
datastorage: AP, client, probe, auth entry and MAC list converted to
             linked list
datastorage: functions adjusted to take pointers as parameters
datastorage: optimised sort and search functions added
mac_utils: struct dawn_mac added and comparisons adjusted
general: adjust code to  call new datastorage functions
test_storage: large scale 100 AP, 3000 client, 70k probe added

[fix commit]
Signed-off-by: Nick Hainke <vincent@systemli.org>
2020-08-04 09:50:48 +02:00
Rosen Penev
2f585043c3 test_storage: fix compilation with musl 1.2.0
time_t is 64-bit, even under 32-bit OSes.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-07-21 10:06:33 +02:00
twy_2000
32640de378 dawn_uci: no need uci_alloc_context on each uci_set_network call 2020-07-12 13:58:47 +02:00
Ian Clowes
67c3ed0d0a test_storage: extend test harness; datastorage: two bug fixes
datastorage (bug fix): deleting expired array item would fail to test next item
test_storage: extended to cover all required datastorage entry points
test_storage: added ability to read script file
test_storage: added new and revised test scripts
TESTING.md: added to describe testing approach
general: added various TODO notes on things to come back to
general: revised #includes to make each "self-compiling"
general: revised #includes to minimise usage across source files
general: moved declarations and defintions to simplify and rationalise code
datastorage: refactor to support scalability testing
datastorage: made independent of time() calls to support testing
datastorage: fixed redundant use of both SORT_NUM and SORT_LENGTH defines
datastorage: fake kicking to test clients move between access points
msghandler: new module to reduce compile time interdependencies
mshhandler: (issue #100?) fixed SEGV memcpy() in dump_client() using strncpy()
ubus: merged uface into ubus
mac_utils: new module for MAC address utilites
test_header: added target to help #include rationalisation

Tested-by: Nick Hainke <vincent@systemli.org>
2020-07-12 13:47:23 +02:00
twy_2000
0f63e00c43 tcpsocket: free con after ustream write error and make list each safe list_each is not safe against removal of list entry 2020-06-18 22:16:42 +02:00