Skip to content
This repository was archived by the owner on Sep 7, 2020. It is now read-only.

Commit de689cf

Browse files
agent: backhaul_manager: wait for dev_set_config in certification
https://jira.prplfoundation.org/browse/PPM-143 In certification mode the state machine of backhaul manager should stop before entering MASTER_DISCOVERY state until dev_set_config (wired backhaul) or start_wps_registration (wireless backhaul) is received. No code change needed for wireless flow. In case of wired flow the exception is made for the agent running on the same machine as controller. In that case UCC listener is present only on the controller, so there is no easy way to send dev_set_config to the agent. Signed-off-by: Vitalii Komisarenko <vitalii.komisarenko@gmail.com>
1 parent fb61391 commit de689cf

3 files changed

Lines changed: 46 additions & 3 deletions

File tree

agent/src/beerocks/slave/agent_ucc_listener.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ std::string agent_ucc_listener::fill_version_reply_string()
6161
*/
6262
void agent_ucc_listener::clear_configuration()
6363
{
64-
m_in_reset = true;
65-
m_reset_completed = false;
64+
m_in_reset = true;
65+
m_reset_completed = false;
66+
m_received_dev_set_config = false;
6667

6768
auto timeout =
6869
std::chrono::steady_clock::now() + std::chrono::seconds(UCC_REPLY_COMPLETE_TIMEOUT_SEC);
@@ -232,6 +233,8 @@ bool agent_ucc_listener::handle_dev_set_config(std::unordered_map<std::string, s
232233

233234
// Signal to backhaul that it can continue onboarding.
234235
m_in_reset = false;
236+
237+
m_received_dev_set_config = true;
235238
return true;
236239
}
237240

agent/src/beerocks/slave/agent_ucc_listener.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ class agent_ucc_listener : public beerocks_ucc_listener {
5252
* again. This function allows the backhaul to signal that it has reached that state.
5353
*/
5454
void reset_completed() { m_reset_completed = true; }
55+
56+
/**
57+
* @brief check if `dev_set_config` has been received
58+
*
59+
* In certification mode the state machine of backhaul manager should stop
60+
* before entering MASTER_DISCOVERY state until dev_set_config (wired backhaul)
61+
* or start_wps_registration (wireless backhaul) is received.
62+
* No code change needed for wireless flow, but for wired one
63+
* we need to remember if `dev_set_config` has been received.
64+
*/
65+
bool has_received_dev_set_config() { return m_received_dev_set_config; }
66+
5567
std::string get_selected_backhaul();
5668
void update_vaps_list(std::string ruid, beerocks_message::sVapsList &vaps);
5769

@@ -75,6 +87,17 @@ class agent_ucc_listener : public beerocks_ucc_listener {
7587

7688
bool m_in_reset = false;
7789
bool m_reset_completed = false;
90+
91+
/**
92+
* @brief flag telling whether `dev_set_config` has been received
93+
*
94+
* In certification mode the state machine of backhaul manager should stop
95+
* before entering MASTER_DISCOVERY state until dev_set_config (wired backhaul)
96+
* or start_wps_registration (wireless backhaul) is received.
97+
* No code change needed for wireless flow, but for wired one
98+
* we need to remember if `dev_set_config` has been received.
99+
*/
100+
bool m_received_dev_set_config = false;
78101
std::string m_selected_backhaul; // "ETH" or "<RUID of the selected radio>"
79102

80103
std::mutex mutex;

agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,25 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select)
792792
break;
793793
}
794794
case EState::MASTER_DISCOVERY: {
795-
796795
auto db = AgentDB::get();
796+
797+
bool wired_backhaul =
798+
db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wired;
799+
800+
// In certification mode we want to wait till dev_set_config is received (wired backhaul)
801+
// or start_wps_registration (wireless backhaul).
802+
if (db->device_conf.certification_mode && wired_backhaul &&
803+
!db->device_conf.local_controller) {
804+
if (!m_agent_ucc_listener) {
805+
LOG(ERROR) << "m_agent_ucc_listener == nullptr";
806+
return false;
807+
}
808+
809+
if (!m_agent_ucc_listener->has_received_dev_set_config()) {
810+
break;
811+
}
812+
}
813+
797814
if (network_utils::get_iface_info(bridge_info, db->bridge.iface_name) != 0) {
798815
LOG(ERROR) << "Failed reading addresses from the bridge!";
799816
platform_notify_error(bpl::eErrorCode::BH_READING_DATA_FROM_THE_BRIDGE, "");

0 commit comments

Comments
 (0)