Compare commits

...

3 Commits

Author SHA1 Message Date
Marek Kwaczynski
c0c358cb50 cloud_discovery: add blacklist for discovery methods
Introduce a blacklist 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>
2025-09-22 15:22:38 +02:00
Marek Kwaczynski
f3036317b4 cloud_discovery: Skip rewriting discovery.state.json when no discovery metho
d is set

In cases where gateway.json exists, the discovery method may be unset.
Writing an empty value to discovery.state.json is not useful, so
avoid updating the file in this case.

Signed-off-by: Marek Kwaczynski <marek@shasta.cloud>
2025-09-22 15:19:38 +02:00
Marek Kwaczynski
2ae3092959 cloud_discovery: run est_client enroll before discovery process
Always obtain EST certificates before starting the discovery process.
This ensures certificates are already available from the EST server, since
the FQDN may be provided via DHCP discovery or another discovery method,
and requires valid certificates to proceed.

Fixes: WIFI-15123

Signed-off-by: Marek Kwaczynski <marek@shasta.cloud>
2025-09-22 15:17:30 +02:00

View File

@@ -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;
@@ -102,6 +103,9 @@ function gateway_load() {
}
function discovery_state_write() {
if (length(discovery_method) == 0)
return;
let discovery_state = {
"type": discovery_method,
"updated": time()
@@ -155,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:
@@ -163,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;
@@ -231,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) {
@@ -260,19 +273,21 @@ function interval_handler() {
if (!time_is_valid())
return;
discovery_method = DISCOVER_DHCP;
if (discover_dhcp())
return;
if (system('/usr/bin/est_client enroll'))
return;
discovery_method = 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: