From 32fed79117cd816dab78c30047e659358d9ec251 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 17 Mar 2022 10:00:12 +0100 Subject: [PATCH] add local_mode config option This prevents communication with other usteer nodes and allows it to be used for purely local band steering / load balancing Signed-off-by: Felix Fietkau --- openwrt/usteer/files/etc/config/usteer | 3 +++ openwrt/usteer/files/etc/init.d/usteer | 1 + remote.c | 8 ++++++-- ubus.c | 1 + usteer.h | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/openwrt/usteer/files/etc/config/usteer b/openwrt/usteer/files/etc/config/usteer index 534031d..38c0e77 100644 --- a/openwrt/usteer/files/etc/config/usteer +++ b/openwrt/usteer/files/etc/config/usteer @@ -5,6 +5,9 @@ config usteer # Log messages to syslog (0/1) option 'syslog' '1' + # Disable network communication (0/1) + option local_mode '0' + # Use IPv6 for remote exchange option 'ipv6' '0' diff --git a/openwrt/usteer/files/etc/init.d/usteer b/openwrt/usteer/files/etc/init.d/usteer index 29a43a2..22273ef 100755 --- a/openwrt/usteer/files/etc/init.d/usteer +++ b/openwrt/usteer/files/etc/init.d/usteer @@ -66,6 +66,7 @@ uci_usteer() { uci_option_to_json_bool "$cfg" syslog uci_option_to_json_bool "$cfg" ipv6 + uci_option_to_json_bool "$cfg" local_mode uci_option_to_json_bool "$cfg" load_kick_enabled uci_option_to_json_bool "$cfg" assoc_steering uci_option_to_json_string "$cfg" node_up_script diff --git a/remote.c b/remote.c index f000e68..9b753e6 100644 --- a/remote.c +++ b/remote.c @@ -315,6 +315,9 @@ interface_recv_msg(struct interface *iface, char *addr_str, void *buf, int len) struct blob_attr *cur; int rem; + if (config.local_mode) + return; + if (blob_pad_len(data) != len) { MSG(DEBUG, "Invalid message length (header: %d, real: %d)\n", blob_pad_len(data), len); return; @@ -606,7 +609,7 @@ usteer_check_timeout(void) int timeout = config.remote_node_timeout; list_for_each_entry_safe(node, tmp, &remote_nodes, list) { - if (node->check++ > timeout) + if (config.local_mode || node->check++ > timeout) remote_node_free(node); } } @@ -653,7 +656,8 @@ usteer_send_update_timer(struct uloop_timeout *t) usteer_update_time(); uloop_timeout_set(t, config.remote_update_interval); - if (!avl_is_empty(&local_nodes) || host_info_blob) { + if (!config.local_mode && + (!avl_is_empty(&local_nodes) || host_info_blob)) { c = usteer_update_init(); for_each_local_node(node) usteer_send_node(node, NULL); diff --git a/ubus.c b/ubus.c index 27b363f..7e764ff 100644 --- a/ubus.c +++ b/ubus.c @@ -149,6 +149,7 @@ struct cfg_item { _cfg(BOOL, syslog), \ _cfg(U32, debug_level), \ _cfg(BOOL, ipv6), \ + _cfg(BOOL, local_mode), \ _cfg(U32, sta_block_timeout), \ _cfg(U32, local_sta_timeout), \ _cfg(U32, local_sta_update), \ diff --git a/usteer.h b/usteer.h index 095a76e..e0c2891 100644 --- a/usteer.h +++ b/usteer.h @@ -149,6 +149,7 @@ struct usteer_config { uint32_t debug_level; bool ipv6; + bool local_mode; uint32_t sta_block_timeout; uint32_t local_sta_timeout; -- 2.30.2