From b25ea4742e6c8180b13c670cf90f6ffb452bd688 Mon Sep 17 00:00:00 2001 From: Georges Oates_Larsen Date: Wed, 23 Aug 2023 13:35:41 -0700 Subject: [PATCH] net: conn_mgr: Rename connectivity monitor The connectivity monitoring subfeature of conn_mgr is currently also named conn_mgr, which is confusing. This commit renames it to conn_mgr_monitor, or conn_mgr_mon for short, for clarity. Signed-off-by: Georges Oates_Larsen --- CODEOWNERS | 2 +- MAINTAINERS.yml | 2 +- .../net/{conn_mgr.h => conn_mgr_monitor.h} | 4 +- include/zephyr/shell/shell_mqtt.h | 2 +- samples/net/gsm_modem/src/main.c | 2 +- samples/net/mqtt_sn_publisher/src/main.c | 4 +- samples/net/mqtt_sn_publisher/src/udp.c | 2 +- .../sockets/dumb_http_server_mt/src/main.c | 4 +- .../echo_client/overlay-max-stacks.conf | 2 +- .../net/sockets/echo_client/src/echo-client.c | 4 +- .../echo_server/overlay-max-stacks.conf | 2 +- .../net/sockets/echo_server/src/echo-server.c | 6 +- samples/net/sockets/txtime/src/main.c | 6 +- samples/subsys/mgmt/updatehub/src/main.c | 4 +- subsys/mgmt/mcumgr/transport/src/smp_udp.c | 4 +- subsys/net/conn_mgr/CMakeLists.txt | 2 +- subsys/net/conn_mgr/Kconfig | 13 ++- subsys/net/conn_mgr/conn_mgr_connectivity.c | 2 +- .../{conn_mgr.c => conn_mgr_monitor.c} | 92 +++++++++---------- subsys/net/conn_mgr/conn_mgr_private.h | 4 +- subsys/net/conn_mgr/events_handler.c | 18 ++-- subsys/shell/backends/shell_mqtt.c | 2 +- tests/net/conn_mgr_conn/src/main.c | 2 +- .../CMakeLists.txt | 0 .../{conn_mgr => conn_mgr_monitor}/prj.conf | 0 .../{conn_mgr => conn_mgr_monitor}/src/main.c | 44 ++++----- .../src/test_ifaces.c | 0 .../src/test_ifaces.h | 0 .../testcase.yaml | 0 29 files changed, 114 insertions(+), 115 deletions(-) rename include/zephyr/net/{conn_mgr.h => conn_mgr_monitor.h} (96%) rename subsys/net/conn_mgr/{conn_mgr.c => conn_mgr_monitor.c} (76%) rename tests/net/{conn_mgr => conn_mgr_monitor}/CMakeLists.txt (100%) rename tests/net/{conn_mgr => conn_mgr_monitor}/prj.conf (100%) rename tests/net/{conn_mgr => conn_mgr_monitor}/src/main.c (96%) rename tests/net/{conn_mgr => conn_mgr_monitor}/src/test_ifaces.c (100%) rename tests/net/{conn_mgr => conn_mgr_monitor}/src/test_ifaces.h (100%) rename tests/net/{conn_mgr => conn_mgr_monitor}/testcase.yaml (100%) diff --git a/CODEOWNERS b/CODEOWNERS index e91fa6803fd..5cff9ede19c 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -927,7 +927,7 @@ scripts/build/gen_image_info.py @tejlmand /tests/lib/cmsis_dsp/ @stephanosio /tests/net/ @rlubos @tbursztyka @jukkar /tests/net/buf/ @jhedberg @tbursztyka @jukkar -/tests/net/conn_mgr/ @rlubos @glarsennordic @jukkar +/tests/net/conn_mgr_monitor/ @rlubos @glarsennordic @jukkar /tests/net/conn_mgr_conn/ @rlubos @glarsennordic @jukkar /tests/net/ieee802154/l2/ @rlubos @tbursztyka @jukkar @fgrandel /tests/net/lib/ @rlubos @tbursztyka @jukkar diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index 8a984cae45e..a16b8787122 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -1911,7 +1911,7 @@ Networking: files: - include/zephyr/net/conn_mgr*.h - subsys/net/conn_mgr/ - - tests/net/conn_mgr/ + - tests/net/conn_mgr_monitor/ - tests/net/conn_mgr_conn/ labels: - "area: Networking" diff --git a/include/zephyr/net/conn_mgr.h b/include/zephyr/net/conn_mgr_monitor.h similarity index 96% rename from include/zephyr/net/conn_mgr.h rename to include/zephyr/net/conn_mgr_monitor.h index 5a40ad25317..1bff698a86c 100644 --- a/include/zephyr/net/conn_mgr.h +++ b/include/zephyr/net/conn_mgr_monitor.h @@ -20,7 +20,7 @@ struct net_l2; * @brief Resend either NET_L4_CONNECTED or NET_L4_DISCONNECTED depending on whether connectivity * is currently available. */ -void conn_mgr_resend_status(void); +void conn_mgr_mon_resend_status(void); /** * @brief Mark an iface to be ignored by conn_mgr. @@ -77,7 +77,7 @@ void conn_mgr_watch_l2(const struct net_l2 *l2); #else -#define conn_mgr_resend_status(...) +#define conn_mgr_mon_resend_status(...) #define conn_mgr_ignore_iface(...) #define conn_mgr_watch_iface(...) #define conn_mgr_ignore_l2(...) diff --git a/include/zephyr/shell/shell_mqtt.h b/include/zephyr/shell/shell_mqtt.h index c1120527f5d..03cd64fbdcd 100644 --- a/include/zephyr/shell/shell_mqtt.h +++ b/include/zephyr/shell/shell_mqtt.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include diff --git a/samples/net/gsm_modem/src/main.c b/samples/net/gsm_modem/src/main.c index 8e9d0a7521a..522a8c66606 100644 --- a/samples/net/gsm_modem/src/main.c +++ b/samples/net/gsm_modem/src/main.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/samples/net/mqtt_sn_publisher/src/main.c b/samples/net/mqtt_sn_publisher/src/main.c index efacb696dd0..665919ef50a 100644 --- a/samples/net/mqtt_sn_publisher/src/main.c +++ b/samples/net/mqtt_sn_publisher/src/main.c @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -79,7 +79,7 @@ static void init_app(void) net_mgmt_init_event_callback(&mgmt_cb, net_event_handler, EVENT_MASK); net_mgmt_add_event_callback(&mgmt_cb); - conn_mgr_resend_status(); + conn_mgr_mon_resend_status(); } } diff --git a/samples/net/mqtt_sn_publisher/src/udp.c b/samples/net/mqtt_sn_publisher/src/udp.c index 126b3f02b4c..32a64fbccbd 100644 --- a/samples/net/mqtt_sn_publisher/src/udp.c +++ b/samples/net/mqtt_sn_publisher/src/udp.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/samples/net/sockets/dumb_http_server_mt/src/main.c b/samples/net/sockets/dumb_http_server_mt/src/main.c index 77b7a836f75..714bbc5a67b 100644 --- a/samples/net/sockets/dumb_http_server_mt/src/main.c +++ b/samples/net/sockets/dumb_http_server_mt/src/main.c @@ -16,7 +16,7 @@ LOG_MODULE_REGISTER(net_dumb_http_srv_mt_sample); #include #include -#include +#include #define MY_PORT 8080 @@ -426,7 +426,7 @@ int main(void) event_handler, EVENT_MASK); net_mgmt_add_event_callback(&mgmt_cb); - conn_mgr_resend_status(); + conn_mgr_mon_resend_status(); } if (!IS_ENABLED(CONFIG_NET_CONNECTION_MANAGER)) { diff --git a/samples/net/sockets/echo_client/overlay-max-stacks.conf b/samples/net/sockets/echo_client/overlay-max-stacks.conf index 89386a16efb..195b0e6e77e 100644 --- a/samples/net/sockets/echo_client/overlay-max-stacks.conf +++ b/samples/net/sockets/echo_client/overlay-max-stacks.conf @@ -7,5 +7,5 @@ CONFIG_MAIN_STACK_SIZE=65535 CONFIG_IDLE_STACK_SIZE=65535 CONFIG_ISR_STACK_SIZE=65535 CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=65535 -CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE=65535 +CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=65535 CONFIG_SHELL_STACK_SIZE=65535 diff --git a/samples/net/sockets/echo_client/src/echo-client.c b/samples/net/sockets/echo_client/src/echo-client.c index a8388604ba2..3738c758b15 100644 --- a/samples/net/sockets/echo_client/src/echo-client.c +++ b/samples/net/sockets/echo_client/src/echo-client.c @@ -29,7 +29,7 @@ LOG_MODULE_REGISTER(net_echo_client_sample, LOG_LEVEL_DBG); #include #include -#include +#include #if defined(CONFIG_USERSPACE) #include @@ -272,7 +272,7 @@ static void init_app(void) event_handler, EVENT_MASK); net_mgmt_add_event_callback(&mgmt_cb); - conn_mgr_resend_status(); + conn_mgr_mon_resend_status(); } init_vlan(); diff --git a/samples/net/sockets/echo_server/overlay-max-stacks.conf b/samples/net/sockets/echo_server/overlay-max-stacks.conf index 89386a16efb..195b0e6e77e 100644 --- a/samples/net/sockets/echo_server/overlay-max-stacks.conf +++ b/samples/net/sockets/echo_server/overlay-max-stacks.conf @@ -7,5 +7,5 @@ CONFIG_MAIN_STACK_SIZE=65535 CONFIG_IDLE_STACK_SIZE=65535 CONFIG_ISR_STACK_SIZE=65535 CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=65535 -CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE=65535 +CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=65535 CONFIG_SHELL_STACK_SIZE=65535 diff --git a/samples/net/sockets/echo_server/src/echo-server.c b/samples/net/sockets/echo_server/src/echo-server.c index 7343b1e8217..612567002f8 100644 --- a/samples/net/sockets/echo_server/src/echo-server.c +++ b/samples/net/sockets/echo_server/src/echo-server.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(net_echo_server_sample, LOG_LEVEL_DBG); #include #include -#include +#include #include "common.h" #include "certificate.h" @@ -191,7 +191,7 @@ static void init_app(void) event_handler, EVENT_MASK); net_mgmt_add_event_callback(&mgmt_cb); - conn_mgr_resend_status(); + conn_mgr_mon_resend_status(); } init_vlan(); @@ -205,7 +205,7 @@ static int cmd_sample_quit(const struct shell *sh, { want_to_quit = true; - conn_mgr_resend_status(); + conn_mgr_mon_resend_status(); quit(); diff --git a/samples/net/sockets/txtime/src/main.c b/samples/net/sockets/txtime/src/main.c index 5be28170168..a4a63732398 100644 --- a/samples/net/sockets/txtime/src/main.c +++ b/samples/net/sockets/txtime/src/main.c @@ -16,7 +16,7 @@ LOG_MODULE_REGISTER(net_txtime_sample, LOG_LEVEL_DBG); #include #include -#include +#include #include #include @@ -496,7 +496,7 @@ static int cmd_sample_quit(const struct shell *sh, quit(); - conn_mgr_resend_status(); + conn_mgr_mon_resend_status(); return 0; } @@ -534,7 +534,7 @@ int main(void) net_mgmt_add_event_callback(&dhcpv4_cb); } - conn_mgr_resend_status(); + conn_mgr_mon_resend_status(); } /* The VLAN in this example is created for demonstration purposes. diff --git a/samples/subsys/mgmt/updatehub/src/main.c b/samples/subsys/mgmt/updatehub/src/main.c index 022fbd4b2ae..5e23488f10f 100644 --- a/samples/subsys/mgmt/updatehub/src/main.c +++ b/samples/subsys/mgmt/updatehub/src/main.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #ifdef CONFIG_NET_L2_WIFI_MGMT #include @@ -153,6 +153,6 @@ int main(void) net_mgmt_init_event_callback(&mgmt_cb, event_handler, EVENT_MASK); net_mgmt_add_event_callback(&mgmt_cb); - conn_mgr_resend_status(); + conn_mgr_mon_resend_status(); return 0; } diff --git a/subsys/mgmt/mcumgr/transport/src/smp_udp.c b/subsys/mgmt/mcumgr/transport/src/smp_udp.c index 9f95f64ac30..2da48563672 100644 --- a/subsys/mgmt/mcumgr/transport/src/smp_udp.c +++ b/subsys/mgmt/mcumgr/transport/src/smp_udp.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -337,7 +337,7 @@ int smp_udp_open(void) if (started) { /* One or more threads were started, send interface notifications */ - conn_mgr_resend_status(); + conn_mgr_mon_resend_status(); } return 0; diff --git a/subsys/net/conn_mgr/CMakeLists.txt b/subsys/net/conn_mgr/CMakeLists.txt index 2f2d233196f..567bbf07d69 100644 --- a/subsys/net/conn_mgr/CMakeLists.txt +++ b/subsys/net/conn_mgr/CMakeLists.txt @@ -4,7 +4,7 @@ zephyr_include_directories(.) zephyr_library() zephyr_library_sources( - conn_mgr.c + conn_mgr_monitor.c events_handler.c conn_mgr_connectivity.c ) diff --git a/subsys/net/conn_mgr/Kconfig b/subsys/net/conn_mgr/Kconfig index b9567bf5eb8..e72e614d54c 100644 --- a/subsys/net/conn_mgr/Kconfig +++ b/subsys/net/conn_mgr/Kconfig @@ -22,19 +22,18 @@ module-str = Log level for connection manager module-help = Enables connection manager code to output debug messages. source "subsys/net/Kconfig.template.log_config.net" -config NET_CONNECTION_MANAGER_STACK_SIZE - int "Size of the stack allocated for the connection manager" +config NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE + int "Size of the stack allocated for the conn_mgr_monitor thread" default 512 help - Sets the stack size which will be used by the connection manager - thread. + Sets the stack size which will be used by the connection manager for connectivity monitoring. -config NET_CONNECTION_MANAGER_PRIORITY - int "Thread starting priority" +config NET_CONNECTION_MANAGER_MONITOR_PRIORITY + int "Monitoring thread starting priority" default 1 range 1 99 help - This sets the starting priority of the connection manager thread. + This sets the starting priority of the conn_mgr_monitor thread. config NET_CONNECTION_MANAGER_AUTO_IF_DOWN bool "Automatically call net_if_down on ifaces that have given up on connecting" diff --git a/subsys/net/conn_mgr/conn_mgr_connectivity.c b/subsys/net/conn_mgr/conn_mgr_connectivity.c index 9da2bb18c35..4bc9fea3471 100644 --- a/subsys/net/conn_mgr/conn_mgr_connectivity.c +++ b/subsys/net/conn_mgr/conn_mgr_connectivity.c @@ -9,7 +9,7 @@ LOG_MODULE_REGISTER(conn_mgr_conn, CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL); #include #include -#include +#include #include #include #include "conn_mgr_private.h" diff --git a/subsys/net/conn_mgr/conn_mgr.c b/subsys/net/conn_mgr/conn_mgr_monitor.c similarity index 76% rename from subsys/net/conn_mgr/conn_mgr.c rename to subsys/net/conn_mgr/conn_mgr_monitor.c index 3374a1acf60..7396b06dc54 100644 --- a/subsys/net/conn_mgr/conn_mgr.c +++ b/subsys/net/conn_mgr/conn_mgr_monitor.c @@ -23,13 +23,13 @@ LOG_MODULE_REGISTER(conn_mgr, CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL); #define THREAD_PRIORITY K_PRIO_PREEMPT(7) #endif -static K_THREAD_STACK_DEFINE(conn_mgr_thread_stack, - CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE); -static struct k_thread conn_mgr_thread; +static K_THREAD_STACK_DEFINE(conn_mgr_mon_stack, + CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE); +static struct k_thread conn_mgr_mon_thread; /* Internal state array tracking readiness, flags, and other state information for all available * ifaces. Note that indexing starts at 0, whereas Zephyr iface indices start at 1. - * conn_mgr_get_if_by_index and conn_mgr_get_index_for_if are used to go back and forth between + * conn_mgr_mon_get_if_by_index and conn_mgr_get_index_for_if are used to go back and forth between * iface_states indices and Zephyr iface pointers. */ uint16_t iface_states[CONN_MGR_IFACE_MAX]; @@ -42,10 +42,10 @@ static struct net_if *last_iface_down; static struct net_if *last_iface_up; /* Used to signal when modifications have been made that need to be responded to */ -K_SEM_DEFINE(conn_mgr_event_signal, 1, 1); +K_SEM_DEFINE(conn_mgr_mon_updated, 1, 1); -/* Used to protect conn_mgr state */ -K_MUTEX_DEFINE(conn_mgr_lock); +/* Used to protect conn_mgr_monitor state */ +K_MUTEX_DEFINE(conn_mgr_mon_lock); /** * @brief Retrieves pointer to an iface by the index that corresponds to it in iface_states @@ -53,7 +53,7 @@ K_MUTEX_DEFINE(conn_mgr_lock); * @param index - The index in iface_states to find the corresponding iface for. * @return net_if* - The corresponding iface. */ -static struct net_if *conn_mgr_get_if_by_index(int index) +static struct net_if *conn_mgr_mon_get_if_by_index(int index) { return net_if_get_by_index(index + 1); } @@ -75,7 +75,7 @@ static int conn_mgr_get_index_for_if(struct net_if *iface) * @param idx - index (in iface_states) of the iface to mark ready or unready * @param readiness - true if the iface should be considered ready, otherwise false */ -static void conn_mgr_set_ready(int idx, bool readiness) +static void conn_mgr_mon_set_ready(int idx, bool readiness) { /* Clear and then update the L4-readiness bit */ iface_states[idx] &= ~CONN_MGR_IF_READY; @@ -84,14 +84,14 @@ static void conn_mgr_set_ready(int idx, bool readiness) iface_states[idx] |= CONN_MGR_IF_READY; ready_count += 1; - last_iface_up = conn_mgr_get_if_by_index(idx); + last_iface_up = conn_mgr_mon_get_if_by_index(idx); } else { ready_count -= 1; - last_iface_down = conn_mgr_get_if_by_index(idx); + last_iface_down = conn_mgr_mon_get_if_by_index(idx); } } -static void conn_mgr_act_on_changes(void) +static void conn_mgr_mon_handle_update(void) { int idx; int original_ready_count; @@ -103,7 +103,7 @@ static void conn_mgr_act_on_changes(void) bool was_l4_ready; bool is_ignored; - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); original_ready_count = ready_count; for (idx = 0; idx < ARRAY_SIZE(iface_states); idx++) { @@ -132,7 +132,7 @@ static void conn_mgr_act_on_changes(void) /* Respond to changes to iface readiness */ if (was_l4_ready != is_l4_ready) { /* Track the iface readiness change */ - conn_mgr_set_ready(idx, is_l4_ready); + conn_mgr_mon_set_ready(idx, is_l4_ready); } } @@ -147,7 +147,7 @@ static void conn_mgr_act_on_changes(void) } } - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); } /** @@ -155,11 +155,11 @@ static void conn_mgr_act_on_changes(void) * * @param iface - iface to initialize from. */ -static void conn_mgr_initial_state(struct net_if *iface) +static void conn_mgr_mon_initial_state(struct net_if *iface) { int idx = net_if_get_by_iface(iface) - 1; - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); if (net_if_is_up(iface)) { NET_DBG("Iface %p UP", iface); @@ -183,42 +183,42 @@ static void conn_mgr_initial_state(struct net_if *iface) iface_states[idx] |= CONN_MGR_IF_CHANGED; - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); } -static void conn_mgr_init_cb(struct net_if *iface, void *user_data) +static void conn_mgr_mon_init_cb(struct net_if *iface, void *user_data) { ARG_UNUSED(user_data); - conn_mgr_initial_state(iface); + conn_mgr_mon_initial_state(iface); } -static void conn_mgr_handler(void) +static void conn_mgr_mon_thread_fn(void) { - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); conn_mgr_conn_init(); conn_mgr_init_events_handler(); - net_if_foreach(conn_mgr_init_cb, NULL); + net_if_foreach(conn_mgr_mon_init_cb, NULL); - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); NET_DBG("Connection Manager started"); while (true) { /* Wait for changes */ - k_sem_take(&conn_mgr_event_signal, K_FOREVER); + k_sem_take(&conn_mgr_mon_updated, K_FOREVER); /* Respond to changes */ - conn_mgr_act_on_changes(); + conn_mgr_mon_handle_update(); } } -void conn_mgr_resend_status(void) +void conn_mgr_mon_resend_status(void) { - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); if (ready_count == 0) { net_mgmt_event_notify(NET_EVENT_L4_DISCONNECTED, last_iface_down); @@ -226,39 +226,39 @@ void conn_mgr_resend_status(void) net_mgmt_event_notify(NET_EVENT_L4_CONNECTED, last_iface_up); } - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); } void conn_mgr_ignore_iface(struct net_if *iface) { int idx = conn_mgr_get_index_for_if(iface); - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); if (!(iface_states[idx] & CONN_MGR_IF_IGNORED)) { /* Set ignored flag and mark state as changed */ iface_states[idx] |= CONN_MGR_IF_IGNORED; iface_states[idx] |= CONN_MGR_IF_CHANGED; - k_sem_give(&conn_mgr_event_signal); + k_sem_give(&conn_mgr_mon_updated); } - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); } void conn_mgr_watch_iface(struct net_if *iface) { int idx = conn_mgr_get_index_for_if(iface); - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); if (iface_states[idx] & CONN_MGR_IF_IGNORED) { /* Clear ignored flag and mark state as changed */ iface_states[idx] &= ~CONN_MGR_IF_IGNORED; iface_states[idx] |= CONN_MGR_IF_CHANGED; - k_sem_give(&conn_mgr_event_signal); + k_sem_give(&conn_mgr_mon_updated); } - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); } bool conn_mgr_is_iface_ignored(struct net_if *iface) @@ -267,11 +267,11 @@ bool conn_mgr_is_iface_ignored(struct net_if *iface) bool ret = false; - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); ret = iface_states[idx] & CONN_MGR_IF_IGNORED; - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); return ret; } @@ -295,7 +295,7 @@ void conn_mgr_ignore_l2(const struct net_l2 *l2) /* conn_mgr_ignore_iface already locks the mutex, but we lock it here too * so that all matching ifaces are updated simultaneously. */ - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); STRUCT_SECTION_FOREACH(net_if, iface) { if (iface_uses_l2(iface, l2)) { @@ -303,7 +303,7 @@ void conn_mgr_ignore_l2(const struct net_l2 *l2) } } - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); } void conn_mgr_watch_l2(const struct net_l2 *l2) @@ -311,7 +311,7 @@ void conn_mgr_watch_l2(const struct net_l2 *l2) /* conn_mgr_watch_iface already locks the mutex, but we lock it here too * so that all matching ifaces are updated simultaneously. */ - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); STRUCT_SECTION_FOREACH(net_if, iface) { if (iface_uses_l2(iface, l2)) { @@ -319,10 +319,10 @@ void conn_mgr_watch_l2(const struct net_l2 *l2) } } - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); } -static int conn_mgr_init(void) +static int conn_mgr_mon_init(void) { int i; @@ -330,12 +330,12 @@ static int conn_mgr_init(void) iface_states[i] = 0; } - k_thread_create(&conn_mgr_thread, conn_mgr_thread_stack, - CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE, - (k_thread_entry_t)conn_mgr_handler, + k_thread_create(&conn_mgr_mon_thread, conn_mgr_mon_stack, + CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE, + (k_thread_entry_t)conn_mgr_mon_thread_fn, NULL, NULL, NULL, THREAD_PRIORITY, 0, K_NO_WAIT); return 0; } -SYS_INIT(conn_mgr_init, APPLICATION, CONFIG_NET_CONNECTION_MANAGER_PRIORITY); +SYS_INIT(conn_mgr_mon_init, APPLICATION, CONFIG_NET_CONNECTION_MANAGER_MONITOR_PRIORITY); diff --git a/subsys/net/conn_mgr/conn_mgr_private.h b/subsys/net/conn_mgr/conn_mgr_private.h index 449c03e6ac2..cf86e4ddc77 100644 --- a/subsys/net/conn_mgr/conn_mgr_private.h +++ b/subsys/net/conn_mgr/conn_mgr_private.h @@ -51,8 +51,8 @@ #define CONN_MGR_IPV4_EVENTS_MASK (NET_EVENT_IPV4_ADDR_ADD | \ NET_EVENT_IPV4_ADDR_DEL) -extern struct k_sem conn_mgr_event_signal; -extern struct k_mutex conn_mgr_lock; +extern struct k_sem conn_mgr_mon_updated; +extern struct k_mutex conn_mgr_mon_lock; void conn_mgr_init_events_handler(void); diff --git a/subsys/net/conn_mgr/events_handler.c b/subsys/net/conn_mgr/events_handler.c index 668bccda25e..c02787bf4fb 100644 --- a/subsys/net/conn_mgr/events_handler.c +++ b/subsys/net/conn_mgr/events_handler.c @@ -35,7 +35,7 @@ static void conn_mgr_iface_events_handler(struct net_mgmt_event_callback *cb, NET_DBG("Iface index %u", idx); - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); switch (NET_MGMT_GET_COMMAND(mgmt_event)) { case NET_EVENT_IF_CMD_DOWN: @@ -49,10 +49,10 @@ static void conn_mgr_iface_events_handler(struct net_mgmt_event_callback *cb, } iface_states[idx] |= CONN_MGR_IF_CHANGED; - k_sem_give(&conn_mgr_event_signal); + k_sem_give(&conn_mgr_mon_updated); done: - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); } #if defined(CONFIG_NET_IPV6) @@ -73,7 +73,7 @@ static void conn_mgr_ipv6_events_handler(struct net_mgmt_event_callback *cb, NET_DBG("Iface index %u", idx); - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); switch (NET_MGMT_GET_COMMAND(mgmt_event)) { case NET_EVENT_IPV6_CMD_DAD_SUCCEED: @@ -96,10 +96,10 @@ static void conn_mgr_ipv6_events_handler(struct net_mgmt_event_callback *cb, } iface_states[idx] |= CONN_MGR_IF_CHANGED; - k_sem_give(&conn_mgr_event_signal); + k_sem_give(&conn_mgr_mon_updated); done: - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); } #else static inline @@ -131,7 +131,7 @@ static void conn_mgr_ipv4_events_handler(struct net_mgmt_event_callback *cb, NET_DBG("Iface index %u", idx); - k_mutex_lock(&conn_mgr_lock, K_FOREVER); + k_mutex_lock(&conn_mgr_mon_lock, K_FOREVER); switch (NET_MGMT_GET_COMMAND(mgmt_event)) { case NET_EVENT_IPV4_CMD_ADDR_ADD: @@ -149,10 +149,10 @@ static void conn_mgr_ipv4_events_handler(struct net_mgmt_event_callback *cb, } iface_states[idx] |= CONN_MGR_IF_CHANGED; - k_sem_give(&conn_mgr_event_signal); + k_sem_give(&conn_mgr_mon_updated); done: - k_mutex_unlock(&conn_mgr_lock); + k_mutex_unlock(&conn_mgr_mon_lock); } #else static inline diff --git a/subsys/shell/backends/shell_mqtt.c b/subsys/shell/backends/shell_mqtt.c index a1f933c580d..bb25296f8e0 100644 --- a/subsys/shell/backends/shell_mqtt.c +++ b/subsys/shell/backends/shell_mqtt.c @@ -719,7 +719,7 @@ static int enable(const struct shell_transport *transport, bool blocking) /* Listen for network connection status */ net_mgmt_add_event_callback(&sh_mqtt->mgmt_cb); - conn_mgr_resend_status(); + conn_mgr_mon_resend_status(); return 0; } diff --git a/tests/net/conn_mgr_conn/src/main.c b/tests/net/conn_mgr_conn/src/main.c index 942750a2b50..79f19ee9712 100644 --- a/tests/net/conn_mgr_conn/src/main.c +++ b/tests/net/conn_mgr_conn/src/main.c @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include #include "test_conn_impl.h" diff --git a/tests/net/conn_mgr/CMakeLists.txt b/tests/net/conn_mgr_monitor/CMakeLists.txt similarity index 100% rename from tests/net/conn_mgr/CMakeLists.txt rename to tests/net/conn_mgr_monitor/CMakeLists.txt diff --git a/tests/net/conn_mgr/prj.conf b/tests/net/conn_mgr_monitor/prj.conf similarity index 100% rename from tests/net/conn_mgr/prj.conf rename to tests/net/conn_mgr_monitor/prj.conf diff --git a/tests/net/conn_mgr/src/main.c b/tests/net/conn_mgr_monitor/src/main.c similarity index 96% rename from tests/net/conn_mgr/src/main.c rename to tests/net/conn_mgr_monitor/src/main.c index aad905cdcfe..425533d8aa9 100644 --- a/tests/net/conn_mgr/src/main.c +++ b/tests/net/conn_mgr_monitor/src/main.c @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include "conn_mgr_private.h" #include "test_ifaces.h" @@ -63,13 +63,13 @@ static void reset_test_iface(struct net_if *iface) /* Thread-safe test statistics */ K_MUTEX_DEFINE(stats_mutex); static struct test_stats { - /** The number of times conn_mgr has raised a connect event */ + /** The number of times conn_mgr_monitor has raised a connect event */ int conn_count; - /** The number of times conn_mgr has raised a disconnect event */ + /** The number of times conn_mgr_monitor has raised a disconnect event */ int dconn_count; - /** The total number of connectivity events fired by conn_mgr */ + /** The total number of connectivity events fired by conn_mgr_monitor */ int event_count; /** The iface blamed for the last disconnect event */ @@ -377,7 +377,7 @@ enum ip_order { /** * @brief Cycles a single iface through all possible ready and pre-ready states, - * ensuring the correct events are observed and generated by conn_mgr. + * ensuring the correct events are observed and generated by conn_mgr_monitor. * * Ifaces can be in one of four states that are relevant to L4 readiness: * 00: oper-down, no IPs associated (unready state) @@ -623,7 +623,7 @@ static void cycle_iface_states(struct net_if *iface, enum ip_order ifa_ipm) /* Make sure all readiness transitions of a pair of connectivity-enabled ifaces results in all * expected events. */ -ZTEST(conn_mgr, test_cycle_ready_CC) +ZTEST(conn_mgr_monitor, test_cycle_ready_CC) { cycle_ready_ifaces(if_conn_a, if_conn_b); } @@ -631,7 +631,7 @@ ZTEST(conn_mgr, test_cycle_ready_CC) /* Make sure half of all readiness transitions of a connectivity-enabled iface and a simple * iface results in all expected events. */ -ZTEST(conn_mgr, test_cycle_ready_CNC) +ZTEST(conn_mgr_monitor, test_cycle_ready_CNC) { cycle_ready_ifaces(if_conn_a, if_simp_a); } @@ -639,14 +639,14 @@ ZTEST(conn_mgr, test_cycle_ready_CNC) /* Make sure the other half of all readiness transitions of a connectivity-enabled iface and a * simple iface results in all expected events. */ -ZTEST(conn_mgr, test_cycle_ready_NCC) +ZTEST(conn_mgr_monitor, test_cycle_ready_NCC) { cycle_ready_ifaces(if_simp_a, if_conn_a); } /* Make sure all readiness transitions of a pair of simple ifaces results in all expected events. */ -ZTEST(conn_mgr, test_cycle_ready_NCNC) +ZTEST(conn_mgr_monitor, test_cycle_ready_NCNC) { cycle_ready_ifaces(if_simp_a, if_simp_b); } @@ -654,7 +654,7 @@ ZTEST(conn_mgr, test_cycle_ready_NCNC) /* Make sure that a simple iface can be successfully ignored without interfering with the events * fired by another simple iface */ -ZTEST(conn_mgr, test_cycle_ready_NCINC) +ZTEST(conn_mgr_monitor, test_cycle_ready_NCINC) { cycle_ignored_iface(if_simp_a, if_simp_b); } @@ -662,7 +662,7 @@ ZTEST(conn_mgr, test_cycle_ready_NCINC) /* Make sure that a connectivity-enabled iface can be successfully ignored without interfering * with the events fired by another connectivity-enabled iface */ -ZTEST(conn_mgr, test_cycle_ready_CIC) +ZTEST(conn_mgr_monitor, test_cycle_ready_CIC) { cycle_ignored_iface(if_conn_a, if_conn_b); } @@ -670,7 +670,7 @@ ZTEST(conn_mgr, test_cycle_ready_CIC) /* Make sure that a connectivity-enabled iface can be successfully ignored without interfering * with the events fired by a simple iface */ -ZTEST(conn_mgr, test_cycle_ready_CINC) +ZTEST(conn_mgr_monitor, test_cycle_ready_CINC) { cycle_ignored_iface(if_conn_a, if_simp_a); } @@ -678,13 +678,13 @@ ZTEST(conn_mgr, test_cycle_ready_CINC) /* Make sure that a simple iface can be successfully ignored without interfering * with the events fired by a connectivity-enabled iface */ -ZTEST(conn_mgr, test_cycle_ready_NCIC) +ZTEST(conn_mgr_monitor, test_cycle_ready_NCIC) { cycle_ignored_iface(if_simp_a, if_conn_a); } -/* Make sure that DAD readiness is actually verified by conn_mgr */ -ZTEST(conn_mgr, test_DAD) +/* Make sure that DAD readiness is actually verified by conn_mgr_monitor */ +ZTEST(conn_mgr_monitor, test_DAD) { struct test_stats stats; @@ -711,7 +711,7 @@ ZTEST(conn_mgr, test_DAD) } /* Test whether ignoring and un-ignoring a ready iface fires the appropriate events */ -ZTEST(conn_mgr, test_ignore_while_ready) +ZTEST(conn_mgr_monitor, test_ignore_while_ready) { struct test_stats stats; @@ -763,7 +763,7 @@ ZTEST(conn_mgr, test_ignore_while_ready) } /* Test L2 and iface ignore API */ -ZTEST(conn_mgr, test_ignores) +ZTEST(conn_mgr_monitor, test_ignores) { /* Ignore if_simp_a, ensuring if_simp_b is unaffected */ conn_mgr_ignore_iface(if_simp_a); @@ -823,7 +823,7 @@ ZTEST(conn_mgr, test_ignores) /* Make sure all state transitions of a single connectivity-enabled iface result in all expected * events. Perform IPv4 changes before IPv6 changes. */ -ZTEST(conn_mgr, test_cycle_states_connected_ipv46) +ZTEST(conn_mgr_monitor, test_cycle_states_connected_ipv46) { cycle_iface_states(if_conn_a, IPV4_FIRST); } @@ -831,7 +831,7 @@ ZTEST(conn_mgr, test_cycle_states_connected_ipv46) /* Make sure all state transitions of a single connectivity-enabled iface result in all expected * events. Perform IPv6 changes before IPv4 changes. */ -ZTEST(conn_mgr, test_cycle_states_connected_ipv64) +ZTEST(conn_mgr_monitor, test_cycle_states_connected_ipv64) { cycle_iface_states(if_conn_a, IPV6_FIRST); } @@ -839,7 +839,7 @@ ZTEST(conn_mgr, test_cycle_states_connected_ipv64) /* Make sure all state transitions of a single simple iface result in all expected events. * Perform IPv4 changes before IPv6 changes. */ -ZTEST(conn_mgr, test_cycle_states_simple_ipv46) +ZTEST(conn_mgr_monitor, test_cycle_states_simple_ipv46) { cycle_iface_states(if_simp_a, IPV4_FIRST); } @@ -847,9 +847,9 @@ ZTEST(conn_mgr, test_cycle_states_simple_ipv46) /* Make sure all state transitions of a single simple iface result in all expected events. * Perform IPv6 changes before IPv4 changes. */ -ZTEST(conn_mgr, test_cycle_states_simple_ipv64) +ZTEST(conn_mgr_monitor, test_cycle_states_simple_ipv64) { cycle_iface_states(if_simp_a, IPV6_FIRST); } -ZTEST_SUITE(conn_mgr, NULL, conn_mgr_setup, conn_mgr_before, NULL, NULL); +ZTEST_SUITE(conn_mgr_monitor, NULL, conn_mgr_setup, conn_mgr_before, NULL, NULL); diff --git a/tests/net/conn_mgr/src/test_ifaces.c b/tests/net/conn_mgr_monitor/src/test_ifaces.c similarity index 100% rename from tests/net/conn_mgr/src/test_ifaces.c rename to tests/net/conn_mgr_monitor/src/test_ifaces.c diff --git a/tests/net/conn_mgr/src/test_ifaces.h b/tests/net/conn_mgr_monitor/src/test_ifaces.h similarity index 100% rename from tests/net/conn_mgr/src/test_ifaces.h rename to tests/net/conn_mgr_monitor/src/test_ifaces.h diff --git a/tests/net/conn_mgr/testcase.yaml b/tests/net/conn_mgr_monitor/testcase.yaml similarity index 100% rename from tests/net/conn_mgr/testcase.yaml rename to tests/net/conn_mgr_monitor/testcase.yaml