mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-28 17:12:22 +00:00
cloud_discovery: add blocklist for discovery methods
Introduce a blocklist mechanism to avoid retrying failed discovery methods within the same discovery cycle. Each time a method fails validation, it is added to the blacklist. The blacklist is cleared once the device transitions to ONLINE or after all discovery methods have been attempted. This prevents repeated attempts of failing methods and ensures the discovery process progresses more reliably. Signed-off-by: Marek Kwaczynski <marek@shasta.cloud>
This commit is contained in:
committed by
John Crispin
parent
ed57759824
commit
460180f42e
@@ -23,6 +23,7 @@ let ubus = libubus.connect();
|
||||
let uci = libuci.cursor();
|
||||
let state = DISCOVER;
|
||||
let discovery_method = "";
|
||||
let discovery_block_list = [];
|
||||
let validate_time;
|
||||
let offline_time;
|
||||
let orphan_time;
|
||||
@@ -158,6 +159,7 @@ function set_state(set) {
|
||||
ulog(LOG_INFO, 'Wait for validation\n');
|
||||
validate_time = time();
|
||||
state = VALIDATING;
|
||||
push(discovery_block_list, discovery_method);
|
||||
break;
|
||||
|
||||
case ONLINE:
|
||||
@@ -166,6 +168,7 @@ function set_state(set) {
|
||||
ulog(LOG_INFO, 'Setting cloud controller to validated\n');
|
||||
gateway_write({ valid: true });
|
||||
discovery_state_write();
|
||||
discovery_block_list = [];
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -234,6 +237,13 @@ function time_is_valid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
function is_discover_method_blacked() {
|
||||
if (discovery_method in discovery_block_list)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function interval_handler() {
|
||||
printf(`State ${state}\n`);
|
||||
switch(state) {
|
||||
@@ -267,15 +277,17 @@ function interval_handler() {
|
||||
return;
|
||||
|
||||
discovery_method = DISCOVER_DHCP;
|
||||
if (discover_dhcp())
|
||||
if (!is_discover_method_blacked() && discover_dhcp())
|
||||
return;
|
||||
|
||||
discovery_method = DISCOVER_FLASH;
|
||||
if (!discover_flash())
|
||||
if (!is_discover_method_blacked() && !discover_flash())
|
||||
return;
|
||||
|
||||
discovery_method = DISCOVER_LOOKUP;
|
||||
redirector_lookup();
|
||||
|
||||
discovery_block_list = [];
|
||||
break;
|
||||
|
||||
case VALIDATING:
|
||||
|
||||
Reference in New Issue
Block a user