[agent]: Refactor handlers for AP_METRICS_RESPONSE_MES…#1412
[agent]: Refactor handlers for AP_METRICS_RESPONSE_MES…#1412VladyslavTupikin wants to merge 4 commits intomasterfrom
Conversation
…SAGE Create new structure sExpectedApMetricsResponse for saving mid, bssid vector, cmdutx message. Update current implementation of handle_ap_metrics_query: clear bssid vector, cmdutx message, save mid, change sending message to the son_slave on simple forwarding. Add new structure and member of structure, update handle_ap_metrics_query method. Signed-off-by: Vladyslav Tupikin <v.tupikin@inango-systems.com>
255dd94 to
6465bd4
Compare
According to the issue #1328 need to do refactoring for the send_slave_ap_metric_query_message method. This method should create 1 AP_METRICS_QUERY_MESSAGE with list of bssids instead 1 message per 1 bssid. Refactored send_slave_ap_metric_query_message, replaced UINT16_MAX to 0, removed useless commentary. Signed-off-by: Vladyslav Tupikin <v.tupikin@inango-systems.com>
6465bd4 to
e19508c
Compare
According to the refactor issue, need to change the logic for preparing and sending AP_METRICS_RESPONSE_MESSAGE to the controller when it was triggered by query. Need add tlv payload to the response object from sExpectedApMetricsResponse structure, then after processing all expected_bssids send response to the controler. Update handle_slave_ap_metrics_response according to the logic described above. Signed-off-by: Vladyslav Tupikin <v.tupikin@inango-systems.com>
f57cc52 to
afc162d
Compare
After refactoring need to remove next: Structures: sStaTrafficStats sStaLinkMetrics sApMetricsQuery sApMetrics sApMetricsResponse Objects: m_ap_metric_query m_ap_metric_response Also erase all places where that objects was used. MAP-4.7.4_ETH_FH24G:netgear-rax40 MAP-4.7.4_ETH_FH5GL:netgear-rax40 MAP-4.7.4_ETH_FH5GH:netgear-rax40 MAP-4.7.5_ETH_FH24G:netgear-rax40 MAP-4.7.5_ETH_FH5GL:netgear-rax40 MAP-4.7.5_ETH_FH5GH:netgear-rax40 MAP-4.7.6_ETH_FH24G:netgear-rax40 MAP-4.7.6_ETH_FH5GL:netgear-rax40 MAP-4.7.6_ETH_FH5GH:netgear-rax40 Signed-off-by: Vladyslav Tupikin <v.tupikin@inango-systems.com>
afc162d to
8d3ebde
Compare
mariomaz
left a comment
There was a problem hiding this comment.
I don't fully agree with adopted design. Also some of the tests are failing. I'll want to re-review when they pass.
| uint16_t length = message_com::get_uds_header(cmdu_rx)->length; | ||
| cmdu_rx.swap(); // swap back before forwarding | ||
| for (const auto &soc : slaves_sockets) { | ||
| if (!message_com::forward_cmdu_to_uds(soc->slave, cmdu_rx, length)) { |
There was a problem hiding this comment.
If CMDU fails to be forwarded to one slave, backhaul manager will never get the expected response from that slave.
It's pointless forwarding the CMDU to the rest of the slaves, therefore loop should break.
| for (const auto &soc : slaves_sockets) { | ||
| if (!message_com::forward_cmdu_to_uds(soc->slave, cmdu_rx, length)) { | ||
| LOG(ERROR) << "Failed forwarding AP_METRICS_QUERY_MESSAGE message to slave: " | ||
| << tlvf::mac_to_string(soc->radio_mac); |
There was a problem hiding this comment.
| << tlvf::mac_to_string(soc->radio_mac); | |
| << soc->radio_mac; |
There's no need to convert MAC to string
| const sLinkNeighbor &link_neighbor, const sLinkMetrics &link_metrics, | ||
| ieee1905_1::eLinkMetricsType link_metrics_type); | ||
|
|
||
| struct sExpectedApMetricsResponse { |
There was a problem hiding this comment.
| struct sExpectedApMetricsResponse { | |
| struct sApMetricsResponse { |
I think we should reconsider the name for this struct, though I'm not happy with this name either. Suggestions are welcome.
| ieee1905_1::CmduMessageTx response = {response_buffer, sizeof(response_buffer)}; | ||
| }; | ||
|
|
||
| sExpectedApMetricsResponse m_expected_ap_metrics_response; |
There was a problem hiding this comment.
| sExpectedApMetricsResponse m_expected_ap_metrics_response; | |
| sApMetricsResponse m_ap_metrics_response_under_construction; |
The same goes for the variable.
| if (!message_com::send_cmdu(socket->slave, cmdu_tx)) { | ||
| LOG(ERROR) << "Failed forwarding AP_METRICS_QUERY_MESSAGE message to son_slave"; | ||
| ret = false; | ||
| continue; |
| } | ||
|
|
||
| auto ret = false; | ||
| for (auto socket : slaves_sockets) { |
There was a problem hiding this comment.
| for (auto socket : slaves_sockets) { | |
| for (const auto &socket : slaves_sockets) { |
| cmdu_rx.swap(); //swap back before forwarding | ||
| return send_cmdu_to_bus(cmdu_rx, controller_bridge_mac, bridge_info.mac, length); | ||
| if (mid != m_expected_ap_metrics_response.mid) { | ||
| LOG(ERROR) << "Received AP_METRICS_RESPONSE_MESSAGE with bad mid=" << std::hex << int(mid); |
There was a problem hiding this comment.
Please log expected mid and actual mid
There was a problem hiding this comment.
It's not a "bad" MID.
More importantly: if it's MID 0, it should be forwarded as is, because then it's a channel utlilization treshold crossing (4.7.6). And in fact, I would always forward it if the MID is not the expected MID - it gives us duplicates if we had two parallel events, but as I mentioned dozens of times: that's fine.
| if (mid == 0) { | ||
| LOG(DEBUG) << "Forward AP_METRICS_RESPONSE_MESSAGE to controller, mid=" << std::hex | ||
| << int(mid); | ||
| return send_cmdu_to_bus(cmdu_rx, controller_bridge_mac, bridge_info.mac, |
There was a problem hiding this comment.
Now if mid is equal to 0, it can be either because channel utilization threshold is crossed or because of we are in the middle of a periodic reporting. At this point you don't know it.
However processing of the response should be different in each case: forward as is vs. save response and wait till all slaves have replied.
|
I haven't looked at the code, but the current implementation clearly doesn't do the right thing. E.g. the 4.7.5 tests fail because there are still 2 responses being sent (one of which is empty), as can be seen in the pcap file. There should be only one response. test_flows should verify this. We currently don't have any test flow for 4.7.5 or 4.7.6, so that really should be added. |
| return false; | ||
| } | ||
| bssid.push_back(std::get<1>(bssid_tuple)); | ||
| auto mac = std::get<1>(bssid_tuple); |
There was a problem hiding this comment.
(nitpick) please use bssid for a bssid.
| int i = 0; | ||
| for (const auto &mac : bssid_list) { | ||
| auto list = query->bssid_list(i); | ||
| std::get<0>(list) = true; |
There was a problem hiding this comment.
This is wrong - you have to check the first element of the tuple, not set it.
| } | ||
| // Save mid and clear previous query | ||
| m_expected_ap_metrics_response.mid = mid; | ||
| m_expected_ap_metrics_response.expected_bssids.clear(); |
There was a problem hiding this comment.
It is cleared here, but never set... This should be
| m_expected_ap_metrics_response.expected_bssids.clear(); | |
| m_expected_ap_metrics_response.expected_bssids = bssid_list; |
| auto ret = false; | ||
| for (auto socket : slaves_sockets) { | ||
| if (!message_com::send_cmdu(socket->slave, cmdu_tx)) { | ||
| LOG(ERROR) << "Failed forwarding AP_METRICS_QUERY_MESSAGE message to son_slave"; |
There was a problem hiding this comment.
Nitpick: it's not forwarding, just sending.
| cmdu_rx.swap(); //swap back before forwarding | ||
| return send_cmdu_to_bus(cmdu_rx, controller_bridge_mac, bridge_info.mac, length); | ||
| if (mid != m_expected_ap_metrics_response.mid) { | ||
| LOG(ERROR) << "Received AP_METRICS_RESPONSE_MESSAGE with bad mid=" << std::hex << int(mid); |
There was a problem hiding this comment.
It's not a "bad" MID.
More importantly: if it's MID 0, it should be forwarded as is, because then it's a channel utlilization treshold crossing (4.7.6). And in fact, I would always forward it if the MID is not the expected MID - it gives us duplicates if we had two parallel events, but as I mentioned dozens of times: that's fine.
| if (mid == 0) { | ||
| LOG(DEBUG) << "Forward AP_METRICS_RESPONSE_MESSAGE to controller, mid=" << std::hex | ||
| << int(mid); | ||
| return send_cmdu_to_bus(cmdu_rx, controller_bridge_mac, bridge_info.mac, | ||
| cmdu_rx.getMessageLength()); | ||
| } |
There was a problem hiding this comment.
This entire condition should be removed.
|
#1467 replaces this PR. |
Create new structure sExpectedApMetricsResponse for
saving mid, bssid vector, cmdutx message. Update
current implementation of handle_ap_metrics_query:
clear bssid vector, cmdutx message, save mid, change
sending message to the son_slave on simple forwarding.
Add new structure and member of structure, update
handle_ap_metrics_query method.