-
Notifications
You must be signed in to change notification settings - Fork 32
[DCS Patch 1/5] port dynamic channel selection from rdkb bwl #637
[DCS Patch 1/5] port dynamic channel selection from rdkb bwl #637
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second, third and fourth commits don't have a description and Signed off by.
20089eb
to
a6bcd85
Compare
@@ -59,7 +59,7 @@ if(BWL_TYPE STREQUAL "DWPAL") | |||
) | |||
|
|||
find_package(dwpal REQUIRED) | |||
list(APPEND BWL_LIBS dwpal) | |||
list(APPEND BWL_LIBS dwpal nl-3 nl-genl-3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it's better to create a FindNL cmake file and use the standard cmake find_package()
.
Here's an example: https://github.com/nasa/channel-emulator/blob/master/cmake/Modules/FindLibNL.cmake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example: https://github.com/nasa/channel-emulator/blob/master/cmake/Modules/FindLibNL.cmake
Careful with that! The project is GPL-2.0 so presumably that file is GPL-2.0 as well. As such it's OK if we include GPL-2.0 files that are used during the build (it just means that if you distribute the source code, you need to give the recipient the right to redistribute that particular file further). But it's making our license more complicated. If you do take over that file, it should get a copyright header including authorship information of the original (which is difficult to retrieve since they probably also copied it from somewhere else).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was just an example. We should write our own cmake find file for libnl..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As agreed, and since its already exists for other libraries, lets do this in a separate PR as part #665.
Keeping the comment open for that.
// Success | ||
LOG(DEBUG) | ||
<< "Open and attach an event interface to wpa_supplicant/hostapd - SUCCESS!"; | ||
|
||
// Get the nl event interface file descriptor | ||
if (!m_dwpal_nl_ctx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dwpal netlink context is created in the Init
state. On failure, we transition the FSM to the Detach
state.
In what scenario do we get to the Attach
state without a valid context?
I think this if
statement is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure it this test is mandatory.
I added it since we do the same with the VAPs .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, this should be removed as part of #665
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is a live example why it should stay.
netgear-rax40-1_logs:
DEBUG 17:21:12:420 <1991208208>
base_wlan_hal_dwpal.cpp[148] --> dwpal_driver_nl_attach() success for radio =wlan0
...
DEBUG 17:21:13:264 <1991208208>
base_wlan_hal_dwpal.cpp[394] --> DWPAL FSM wlan0 Attach State: Attach
INFO 17:21:13:264 <1991208208>
ap_manager_thread.cpp[343] --> waiting to attach to wlan0
DEBUG 17:21:13:665 <1991208208>
base_wlan_hal_dwpal.cpp[306] --> Open and attach an event interface to wpa_supplicant/hostapd - SUCCESS!
ERROR 17:21:13:665 <1991208208>
base_wlan_hal_dwpal.cpp[322] --> Can't get event fd since dwpal ctx is NULL!
INFO 17:21:13:666 <1991208208>
beerocks_state_machine.h[53] --> 'Attach': Overriding destination for 'Attach' from 'Operational' to 'Detach'
DEBUG 17:21:13:666 <1991208208>
base_wlan_hal_dwpal.cpp[348] --> dwpal_fsm_state::Detach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. Remember that RAX40 has a much older driver version at the moment so the attach will fail
We mustn't fail the FSM on that! Just log an warning and proceed without NL. Similar to what we do when we lack permissions to open raw socket - we simply don't open it.
bool mon_wlan_hal_dwpal::channel_scan_trigger(int dwell_time_msec, | ||
const std::vector<unsigned int> &channel_pool) | ||
{ | ||
LOG(DEBUG) << __func__ << " received on interface=" << m_radio_info.iface_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since its the only print for triggering scan i prefer to leave it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so just remove the __func__
and improve the log message.
For example: "Channel scan trigger received on interface: ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0c86c8e
to
954a758
Compare
bool base_wlan_hal_dwpal::dwpal_nl_cmd_set(const std::string &ifname, unsigned int nl_cmd, | ||
unsigned char *vendor_data, size_t vendor_data_size) | ||
{ | ||
if (vendor_data == nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!vendor_data) { ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsigned char *vendor_data, size_t vendor_data_size) | ||
{ | ||
if (vendor_data == nullptr) { | ||
LOG(ERROR) << __func__ << "vendor_data is NULL ==> Abort!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove __func__
and __FUNCTION__
from all log messages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsigned char *out_buffer, | ||
const size_t max_buffer_size) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wasn't this removed? Please remove before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
size_t data_size = 0; | ||
|
||
if (out_buffer == nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!out_buffer) { ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return true; | ||
} | ||
|
||
size_t base_wlan_hal_dwpal::dwpal_nl_cmd_get(const std::string &ifname, unsigned int nl_cmd, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function should return ssize_t
(signed size_t).
Error value should be <= 0
and any positive value is the length of the received message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_dwpal_nl_ctx, DWPAL_NL_SOLICITED_EVENT, (char *)ifname.c_str(), NL80211_CMD_VENDOR, | ||
DWPAL_NETDEV_ID, (enum ltq_nl80211_vendor_subcmds)nl_cmd, NULL, 0) == DWPAL_FAILURE) { | ||
LOG(ERROR) << __FUNCTION__ << "ERROR for cmd = " << nl_cmd; | ||
return data_size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either initialize data_size
to -1
, or simply return -1
here to indicate a failure.
Same goes to all failures...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool mon_wlan_hal_dwpal::channel_scan_trigger(int dwell_time_msec, | ||
const std::vector<unsigned int> &channel_pool) | ||
{ | ||
LOG(DEBUG) << __func__ << " received on interface=" << m_radio_info.iface_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so just remove the __func__
and improve the log message.
For example: "Channel scan trigger received on interface: ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seccond commit message description is missing - saying "Preperative commit" without context is not enough.
Third commit description is also missing - you need to explain what netlink is basically, why it is needed for DCS, and that you add it for now with stubs to make the review simpler.
954a758 is problematic since it assumes slibc is available where AFAIK it is only available in RDKB.
@@ -59,7 +59,7 @@ if(BWL_TYPE STREQUAL "DWPAL") | |||
) | |||
|
|||
find_package(dwpal REQUIRED) | |||
list(APPEND BWL_LIBS dwpal) | |||
list(APPEND BWL_LIBS dwpal nl-3 nl-genl-3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As agreed, and since its already exists for other libraries, lets do this in a separate PR as part #665.
Keeping the comment open for that.
@@ -20,6 +20,15 @@ extern "C" { | |||
#include <chrono> | |||
#include <memory> | |||
|
|||
#ifdef USE_LIBSAFEC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you moved it to a header file, how about deleting this from the implementation files?
#665
@@ -279,6 +279,12 @@ bool base_wlan_hal_dummy::dummy_send_cmd(const std::string &cmd) { return false; | |||
|
|||
bool base_wlan_hal_dummy::dummy_send_cmd(const std::string &cmd, char **reply) { return false; } | |||
|
|||
bool base_wlan_hal_dummy::process_nl_events() | |||
{ | |||
LOG(ERROR) << __func__ << "not implemented"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we agree to remove the __func__
from all logs?
#665
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first time i hear about it. why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is redundant - see @vitalybu 's comments
// Success | ||
LOG(DEBUG) | ||
<< "Open and attach an event interface to wpa_supplicant/hostapd - SUCCESS!"; | ||
|
||
// Get the nl event interface file descriptor | ||
if (!m_dwpal_nl_ctx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, this should be removed as part of #665
bool base_wlan_hal_dwpal::dwpal_nl_cmd_set(const std::string &ifname, unsigned int nl_cmd, | ||
unsigned char *vendor_data, size_t vendor_data_size) | ||
{ | ||
if (vendor_data == nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
bool base_wlan_hal_dwpal::dwpal_nl_cmd_scan_dump() | ||
{ | ||
// Passing a lambda with capture is not supported for standard C function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
switch (cmd) { | ||
case NL80211_CMD_TRIGGER_SCAN: | ||
return mon_wlan_hal::Event::Channel_Scan_Triggered; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool mon_wlan_hal_dwpal::channel_scan_trigger(int dwell_time_msec, | ||
const std::vector<unsigned int> &channel_pool) | ||
{ | ||
LOG(DEBUG) << __func__ << " received on interface=" << m_radio_info.iface_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a930e23
to
de46e3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving since most comments are fixed, the rest will be fixed as part of #665
de46e3d
to
4384aed
Compare
return false; | ||
} | ||
|
||
if (memcpy_s(¶ms, sizeof(params), &m_nl_buffer[NL_ATTR_HDR], sizeof(params)) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This triggers a build failure: https://gitlab.com/prpl-foundation/prplMesh/-/jobs/401484296
mmemcpy_s
was not declared in this scope
If you're going to use safelibc functions in the header file, you have to include the header (which still requires the ifdeffery to support both rdkb and ugw/openwrt).
However, I'd suggest moving it to the .cpp file.
And while you're at it, use std::copy maybe?
However, there's definitely something wrong here. You check that the return value of dwpal_nl_cmd_get (which is the length of the returned buffer) is equal to sizeof(params), and then you copy out sizeof(params) with an offset of 4 (NL_ATTR_HEADER). So you're guaranteeing an out of bounds access. So either you need to add NL_ATTR_HDR to the check above, or you have to copy without offset.
If the offset is needed, it is going to be needed for all calls of dwpal_nl_cmd_get. So you'd better skip the header inside the dwpal_nl_cmd_get function then. But then, the copy is again redundant, you can just pass params and sizeof(params) as arguments to dwpal_nl_cmd_get.
In conclusion, I don't think this copy will be needed.
BTW I have the feeling I've already made this comment in the original #619.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thing we have gitlab CI!
Just one feedback about this - CI tee's the build log into 'build.log' and saves it in the artifacts zip file. It took me some time to figure this out without knowing what the error is. Why can't we log the build both to file and stdout? It will make our lives much easier analyzing build failures.
@arnout @rmerlot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently building the image and running it is done in a single step. Building the image is really verbose (and we want to keep this verbosity to debug failing builds) and would flood the CI logs completely.
Once #621 is done, we can probably output everything when running the image only (i.e. when building prplmesh itself).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This triggers a build failure: https://gitlab.com/prpl-foundation/prplMesh/-/jobs/401484296
mmemcpy_s
was not declared in this scopeIf you're going to use safelibc functions in the header file, you have to include the header (which still requires the ifdeffery to support both rdkb and ugw/openwrt).
However, I'd suggest moving it to the .cpp file.
And while you're at it, use std::copy maybe?
However, there's definitely something wrong here. You check that the return value of dwpal_nl_cmd_get (which is the length of the returned buffer) is equal to sizeof(params), and then you copy out sizeof(params) with an offset of 4 (NL_ATTR_HEADER). So you're guaranteeing an out of bounds access. So either you need to add NL_ATTR_HDR to the check above, or you have to copy without offset.
If the offset is needed, it is going to be needed for all calls of dwpal_nl_cmd_get. So you'd better skip the header inside the dwpal_nl_cmd_get function then. But then, the copy is again redundant, you can just pass params and sizeof(params) as arguments to dwpal_nl_cmd_get.
In conclusion, I don't think this copy will be needed.
BTW I have the feeling I've already made this comment in the original #619.
This triggers a build failure: https://gitlab.com/prpl-foundation/prplMesh/-/jobs/401484296
mmemcpy_s
was not declared in this scopeIf you're going to use safelibc functions in the header file, you have to include the header (which still requires the ifdeffery to support both rdkb and ugw/openwrt).
However, I'd suggest moving it to the .cpp file.
And while you're at it, use std::copy maybe?
However, there's definitely something wrong here. You check that the return value of dwpal_nl_cmd_get (which is the length of the returned buffer) is equal to sizeof(params), and then you copy out sizeof(params) with an offset of 4 (NL_ATTR_HEADER). So you're guaranteeing an out of bounds access. So either you need to add NL_ATTR_HDR to the check above, or you have to copy without offset.
If the offset is needed, it is going to be needed for all calls of dwpal_nl_cmd_get. So you'd better skip the header inside the dwpal_nl_cmd_get function then. But then, the copy is again redundant, you can just pass params and sizeof(params) as arguments to dwpal_nl_cmd_get.
In conclusion, I don't think this copy will be needed.
BTW I have the feeling I've already made this comment in the original #619.
changed to std::copy and removed the safelibc commit (no need for it now).
fixed the offset issue.
In general i prefer to leave dwpal_nl_cmd_get raw as possible and not to remove the offset there just so i could pass the params instead of the buffer.
9490735
to
0cf65cb
Compare
prperative commit. In order to use nl libraries in dwpal linker needs to know their location. Signed-off-by: alex kanter <[email protected]> Signed-off-by: itay elenzweig <[email protected]>
Add netlink common support for bwl libs. Added with stubs to make the review simpler. Netlink (NL) is direct communication with kernel. We use NL for channel scan triggering and results. Signed-off-by: alex kanter <[email protected]> Signed-off-by: itay elenzweig <[email protected]>
Open nl socket at dwpal init state for each interface. proccess nl events after select. Add stubs and structures for monitor hal. Signed-off-by: alex kanter <[email protected]> Signed-off-by: itay elenzweig <[email protected]>
Implement channel scan events processing. Implement scan triggering and dump results requests. Signed-off-by: alex kanter <[email protected]> Signed-off-by: itay elenzweig <[email protected]>
0cf65cb
to
a8912bd
Compare
The Dynamic Channel Selection feature is divided into several pull request, this is the first out of 5
Low Level Support (DWPAL): Full NL support in BWL:
Changes in this PR include the following: