From patchwork Tue Nov 28 23:08:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13471921 Received: from mohas.pair.com (mohas.pair.com [209.68.5.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD4BB5C09B for ; Tue, 28 Nov 2023 23:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from mohas.pair.com (localhost [127.0.0.1]) by mohas.pair.com (Postfix) with ESMTP id 122FC73100 for ; Tue, 28 Nov 2023 18:08:49 -0500 (EST) Received: from localhost.localdomain (unknown [IPv6:2601:647:5a00:15c1:230d:b2c9:c388:f96b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mohas.pair.com (Postfix) with ESMTPSA id BB58C73154 for ; Tue, 28 Nov 2023 18:08:48 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 1/8] log: Refactor debugging preprocessor macros. Date: Tue, 28 Nov 2023 15:08:39 -0800 Message-ID: <20231128230847.1224497-2-gerickson@nuovations.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128230847.1224497-1-gerickson@nuovations.com> References: <20231128230847.1224497-1-gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: mailmunge 3.11 on 209.68.5.112 This refactors the debugging / debug log preprocessor-related macros. In particular, it: * Introduces CONNMAN_DEBUG_DESC_INSTANTIATE which declares and instantiates an instance of 'connmand_debug_desc'. * Replaces CONNMAN_DEBUG_DEFINE with CONNMAN_DEBUG_ALIAS which declares and instantiates an alias (that is, asserts the CONNMAN_DEBUG_FLAG_ALIAS flag) instance of 'connmand_debug_desc', using CONNMAN_DEBUG_DESC_INSTANTIATE. * Introduces CONNMAN_DEBUG which declares and instantiates an instance of 'connmand_debug_desc', again using CONNMAN_DEBUG_DESC_INSTANTIATE, for controlling an invocation of 'connman_debug' with it that includes both the file and function name the macro was invoked in or attributed to. - The key difference between this and 'DBG' is that this allows the caller to specify the function string rather than relying on '__FUNCTION__' (or __func__). * Redefines 'DBG' against 'CONNMAN_DEBUG' with '__func__' as the function parameter. --- include/log.h | 34 +++++++++++++++++++++------------- src/log.c | 2 +- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/include/log.h b/include/log.h index 8b00e9dc979c..fd47c8d53c9b 100644 --- a/include/log.h +++ b/include/log.h @@ -58,11 +58,27 @@ struct connman_debug_desc { unsigned int flags; } __attribute__((aligned(8))); -#define CONNMAN_DEBUG_DEFINE(name) \ - static struct connman_debug_desc __debug_alias_ ## name \ +#define CONNMAN_DEBUG_DESC_INSTANTIATE(symbol, _name, _file, _flags) \ + static struct connman_debug_desc symbol \ __attribute__((used, section("__debug"), aligned(8))) = { \ - #name, __FILE__, CONNMAN_DEBUG_FLAG_ALIAS \ - }; + .name = _name, .file = _file, .flags = _flags \ + } + +#define CONNMAN_DEBUG_ALIAS(suffix) \ + CONNMAN_DEBUG_DESC_INSTANTIATE(__debug_alias_##suffix, \ + #suffix, \ + __FILE__, \ + CONNMAN_DEBUG_FLAG_ALIAS) + +#define CONNMAN_DEBUG(function, fmt, args...) do { \ + CONNMAN_DEBUG_DESC_INSTANTIATE(__connman_debug_desc, \ + 0, \ + __FILE__, \ + CONNMAN_DEBUG_FLAG_DEFAULT); \ + if (__connman_debug_desc.flags & CONNMAN_DEBUG_FLAG_PRINT) \ + connman_debug("%s:%s() " fmt, \ + __FILE__, function, ##args); \ + } while (0) /** * DBG: @@ -72,15 +88,7 @@ struct connman_debug_desc { * Simple macro around connman_debug() which also include the function * name it is called in. */ -#define DBG(fmt, arg...) do { \ - static struct connman_debug_desc __connman_debug_desc \ - __attribute__((used, section("__debug"), aligned(8))) = { \ - .file = __FILE__, .flags = CONNMAN_DEBUG_FLAG_DEFAULT, \ - }; \ - if (__connman_debug_desc.flags & CONNMAN_DEBUG_FLAG_PRINT) \ - connman_debug("%s:%s() " fmt, \ - __FILE__, __FUNCTION__ , ## arg); \ -} while (0) +#define DBG(fmt, args...) CONNMAN_DEBUG(__func__, fmt, ##args) #ifdef __cplusplus } diff --git a/src/log.c b/src/log.c index 554b046b07fa..f7483194b230 100644 --- a/src/log.c +++ b/src/log.c @@ -38,7 +38,7 @@ static const char *program_exec; static const char *program_path; /* This makes sure we always have a __debug section. */ -CONNMAN_DEBUG_DEFINE(dummy); +CONNMAN_DEBUG_ALIAS(dummy); /** * connman_info: From patchwork Tue Nov 28 23:08:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13471924 Received: from mohas.pair.com (mohas.pair.com [209.68.5.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD41C5C095 for ; Tue, 28 Nov 2023 23:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from mohas.pair.com (localhost [127.0.0.1]) by mohas.pair.com (Postfix) with ESMTP id 7C59073147 for ; Tue, 28 Nov 2023 18:08:49 -0500 (EST) Received: from localhost.localdomain (unknown [IPv6:2601:647:5a00:15c1:230d:b2c9:c388:f96b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mohas.pair.com (Postfix) with ESMTPSA id 35F6273156 for ; Tue, 28 Nov 2023 18:08:49 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 2/8] log: Document debugging preprocessor macros. Date: Tue, 28 Nov 2023 15:08:40 -0800 Message-ID: <20231128230847.1224497-3-gerickson@nuovations.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128230847.1224497-1-gerickson@nuovations.com> References: <20231128230847.1224497-1-gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: mailmunge 3.11 on 209.68.5.112 This adds documentation to the following debugging- / debug logging-related data types and preprocessor macros: * connman_debug_desc * CONNMAN_DEBUG_DESC_INSTANTIATE * CONNMAN_DEBUG_ALIAS * CONNMAN_DEBUG and expands the existing documentation for the 'DBG' preprocessor macro. --- include/log.h | 107 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 102 insertions(+), 5 deletions(-) diff --git a/include/log.h b/include/log.h index fd47c8d53c9b..bff8a1634ab4 100644 --- a/include/log.h +++ b/include/log.h @@ -49,6 +49,10 @@ void connman_debug(const char *format, ...) } \ } while (0) +/** + * Debug-level logging descriptor that may be used to control debug + * output on a per-file or -symbol basis. + */ struct connman_debug_desc { const char *name; const char *file; @@ -58,18 +62,88 @@ struct connman_debug_desc { unsigned int flags; } __attribute__((aligned(8))); +/** + * @def CONNMAN_DEBUG_DESC_INSTANTIATE(symbol, _name, _file, _flags) + * + * @brief + * Convenience preprocessor macro for declaring and instantiating an + * instance of #connmand_debug_desc. + * + * @param[in] symbol The name of the #connman_debug_desc instance + * to instantiate. + * @param[in] _name An optional pointer to an immutable null- + * terminated C string containing the name of + * the #connman_debug_desc- controlled symbol. + * @param[in] _file A pointer to an immutable null-terminated C + * string containing the name of the + * #connman_debug_desc-controlled source file. + * @param[in] _flags Flags that control the interpretation and + * behavior of the instantiated + * #connman_debug_desc instance. + * + */ #define CONNMAN_DEBUG_DESC_INSTANTIATE(symbol, _name, _file, _flags) \ static struct connman_debug_desc symbol \ __attribute__((used, section("__debug"), aligned(8))) = { \ .name = _name, .file = _file, .flags = _flags \ } +/** + * @def CONNMAN_DEBUG_ALIAS(suffix) + * + * @brief + * Convenience preprocessor macro for declaring and instantiating + * an alias (see #CONNMAN_DEBUG_FLAG_ALIAS) instance of + * #connmand_debug_desc. + * + * @param[in] suffix The suffix to concatenate to the name of the + * #connman_debug_desc alias instance to + * instantiate. + * + */ #define CONNMAN_DEBUG_ALIAS(suffix) \ CONNMAN_DEBUG_DESC_INSTANTIATE(__debug_alias_##suffix, \ #suffix, \ __FILE__, \ CONNMAN_DEBUG_FLAG_ALIAS) +/** + * @def CONNMAN_DEBUG(function, fmt, args...) + * + * @brief + * Convenience preprocessor macro for declaring and instantiating + * an instance of #connmand_debug_desc for controlling an + * invocation of #connman_debug with it that includes both the + * file and function name the macro was invoked in or attributed + * to. + * + * This instantiates a scoped-instance of #connmand_debug_desc and + * then, if that instance has its #CONNMAN_DEBUG_FLAG_PRINT flag + * asserted, invokes a call to #connman_debug with the format: + * + * ":() ..." + * + * where is the preprocessor symbol __FILE__, is + * caller-specified, is from @a fmt, and '...' is from @a + * 'args...'. + * + * @param[in] function A pointer to an immutble null-terminated C + * string containing the name of the function + * in which the macro is being instantiated or + * to which the invocation of the macro should + * be attributed to. For example, __FUNCTION__. + * @param[in] fmt A pointer to an immutable null-terminated C + * string container the log message, consisting + * of a printf-style format string composed of + * zero or more output conversion directives. + * @param[in] args... A variadic argument list, where each + * argument corresponds with its peer output + * conversion directive in @a fmt. + * + * @sa CONNMAN_DEBUG_DESC_INSTANTIATE + * @sa connman_debug + * + */ #define CONNMAN_DEBUG(function, fmt, args...) do { \ CONNMAN_DEBUG_DESC_INSTANTIATE(__connman_debug_desc, \ 0, \ @@ -81,12 +155,35 @@ struct connman_debug_desc { } while (0) /** - * DBG: - * @fmt: format string - * @arg...: list of arguments + * @def DBG(fmt, args...) + * + * @brief + * Convenience preprocessor macro for declaring an instance of + * #connmand_debug_desc for controlling an invocation of + * #connman_debug with it that includes both the file and function + * name the macro was invoked in. + * + * This instantiates a scoped-instance of #connmand_debug_desc and + * then, if that instance has its #CONNMAN_DEBUG_FLAG_PRINT flag + * asserted, invokes a call to #connman_debug with the format: + * + * ":() ..." + * + * where is the preprocessor symbol __FILE__, is + * the preprocessor symbol __func__, is from @a fmt, and + * '...' is from @a 'args...'. + * + * @param[in] fmt A pointer to an immutable null-terminated C + * string container the log message, consisting + * of a printf-style format string composed of + * zero or more output conversion directives. + * @param[in] args... A variadic argument list, where each + * argument corresponds with its peer output + * conversion directive in @a fmt. + * + * @sa CONNMAN_DEBUG + * @sa connman_debug * - * Simple macro around connman_debug() which also include the function - * name it is called in. */ #define DBG(fmt, args...) CONNMAN_DEBUG(__func__, fmt, ##args) From patchwork Tue Nov 28 23:08:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13471923 Received: from mohas.pair.com (mohas.pair.com [209.68.5.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7ED15733D for ; Tue, 28 Nov 2023 23:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from mohas.pair.com (localhost [127.0.0.1]) by mohas.pair.com (Postfix) with ESMTP id ECDE57314E for ; Tue, 28 Nov 2023 18:08:49 -0500 (EST) Received: from localhost.localdomain (unknown [IPv6:2601:647:5a00:15c1:230d:b2c9:c388:f96b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mohas.pair.com (Postfix) with ESMTPSA id A3BBC7315A for ; Tue, 28 Nov 2023 18:08:49 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 3/8] connection: Introduce and leverage 'gateway_{config,data}_debug'. Date: Tue, 28 Nov 2023 15:08:41 -0800 Message-ID: <20231128230847.1224497-4-gerickson@nuovations.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128230847.1224497-1-gerickson@nuovations.com> References: <20231128230847.1224497-1-gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: mailmunge 3.11 on 209.68.5.112 This introduces and leverages two functions 'gateway_{config,data}_debug' to conditionally log gateway data and configuration at the debug level. --- src/connection.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 2 deletions(-) diff --git a/src/connection.c b/src/connection.c index 9d2c6961306d..cba1508da3b8 100644 --- a/src/connection.c +++ b/src/connection.c @@ -32,6 +32,12 @@ #include "connman.h" +#define GATEWAY_CONFIG_DBG(description, config) \ + gateway_config_debug(__func__, description, config) + +#define GATEWAY_DATA_DBG(description, data) \ + gateway_data_debug(__func__, description, data) + struct gateway_config { bool active; char *gateway; @@ -53,6 +59,79 @@ struct gateway_data { static GHashTable *gateway_hash = NULL; +static const char *maybe_null(const void *pointer) +{ + return pointer ? pointer : ""; +} + +static void gateway_config_debug(const char *function, + const char *description, + const struct gateway_config *config) +{ + g_autofree char *vpn_phy_interface = NULL; + + if (!function || !description) + return; + + if (!config) + CONNMAN_DEBUG(function, "%s %p", description, config); + else { + if (config->vpn_phy_index >= 0) + vpn_phy_interface = + connman_inet_ifname(config->vpn_phy_index); + + CONNMAN_DEBUG(function, + "%s %p: { active: %u, gateway: %p (%s), " + "vpn: %u, vpn_ip: %p (%s), vpn_phy_index: %d (%s), " + "vpn_phy_ip: %p (%s) }", + description, + config, + config->active, + config->gateway, maybe_null(config->gateway), + config->vpn, + config->vpn_ip, maybe_null(config->vpn_ip), + config->vpn_phy_index, maybe_null(vpn_phy_interface), + config->vpn_phy_ip, maybe_null(config->vpn_phy_ip)); + } +} + +static void gateway_data_debug(const char *function, + const char *description, + const struct gateway_data *data) +{ + g_autofree char *interface = NULL; + + if (!function || !description) + return; + + if (!data) + CONNMAN_DEBUG(function, "%s %p", description, data); + else { + interface = connman_inet_ifname(data->index); + + CONNMAN_DEBUG(function, + "%s %p: { index: %d (%s), service: %p (%s), " + "ipv4_gateway: %p, ipv6_gateway: %p, default_checked: %u }", + description, + data, + data->index, + maybe_null(interface), + data->service, + connman_service_get_identifier(data->service), + data->ipv4_gateway, + data->ipv6_gateway, + data->default_checked); + + if (data->ipv4_gateway) + gateway_config_debug(function, "ipv4_gateway", + data->ipv4_gateway); + + if (data->ipv6_gateway) + gateway_config_debug(function, "ipv6_gateway", + data->ipv6_gateway); + } +} + static struct gateway_config *find_gateway(int index, const char *gateway) { GHashTableIter iter; @@ -282,6 +361,8 @@ static int del_routes(struct gateway_data *data, int status4 = 0, status6 = 0; bool do_ipv4 = false, do_ipv6 = false; + GATEWAY_DATA_DBG("data", data); + if (type == CONNMAN_IPCONFIG_TYPE_IPV4) do_ipv4 = true; else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) @@ -334,6 +415,8 @@ static int disable_gateway(struct gateway_data *data, { bool active = false; + GATEWAY_DATA_DBG("data", data); + if (type == CONNMAN_IPCONFIG_TYPE_IPV4) { if (data->ipv4_gateway) active = data->ipv4_gateway->active; @@ -426,6 +509,8 @@ static void set_default_gateway(struct gateway_data *data, int status4 = 0, status6 = 0; bool do_ipv4 = false, do_ipv6 = false; + GATEWAY_DATA_DBG("data", data); + if (type == CONNMAN_IPCONFIG_TYPE_IPV4) do_ipv4 = true; else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) @@ -507,6 +592,8 @@ static void unset_default_gateway(struct gateway_data *data, int index; bool do_ipv4 = false, do_ipv6 = false; + GATEWAY_DATA_DBG("data", data); + if (type == CONNMAN_IPCONFIG_TYPE_IPV4) do_ipv4 = true; else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) @@ -586,6 +673,9 @@ static bool choose_default_gateway(struct gateway_data *data, { bool downgraded = false; + GATEWAY_DATA_DBG("data", data); + GATEWAY_DATA_DBG("candidate", candidate); + /* * If the current default is not active, then we mark * this one as default. If the other one is already active @@ -641,6 +731,8 @@ static void connection_newgateway(int index, const char *gateway) if (!config) return; + GATEWAY_CONFIG_DBG("config", config); + config->active = true; /* @@ -652,6 +744,8 @@ static void connection_newgateway(int index, const char *gateway) if (!data) return; + GATEWAY_DATA_DBG("data", data); + if (data->default_checked) return; @@ -690,6 +784,8 @@ static void remove_gateway(gpointer user_data) DBG("gateway ipv4 %p ipv6 %p", data->ipv4_gateway, data->ipv6_gateway); + GATEWAY_DATA_DBG("data", data); + if (data->ipv4_gateway) { g_free(data->ipv4_gateway->gateway); g_free(data->ipv4_gateway->vpn_ip); @@ -717,12 +813,18 @@ static void connection_delgateway(int index, const char *gateway) DBG("index %d gateway %s", index, gateway); config = find_gateway(index, gateway); - if (config) + if (config) { + GATEWAY_CONFIG_DBG("config", config); + config->active = false; + } data = find_default_gateway(); - if (data) + if (data) { + GATEWAY_DATA_DBG("data", data); + set_default_gateway(data, CONNMAN_IPCONFIG_TYPE_ALL); + } } static struct connman_rtnl connection_rtnl = { @@ -836,11 +938,15 @@ int __connman_connection_gateway_add(struct connman_service *service, if (!new_gateway) return -EINVAL; + GATEWAY_DATA_DBG("new_gateway", new_gateway); + active_gateway = find_active_gateway(); DBG("active %p index %d new %p", active_gateway, active_gateway ? active_gateway->index : -1, new_gateway); + GATEWAY_DATA_DBG("active_gateway", active_gateway); + if (type == CONNMAN_IPCONFIG_TYPE_IPV4 && new_gateway->ipv4_gateway) { add_host_route(AF_INET, index, gateway, service_type); @@ -931,6 +1037,8 @@ void __connman_connection_gateway_remove(struct connman_service *service, if (!data) return; + GATEWAY_DATA_DBG("service_data", data); + if (do_ipv4 && data->ipv4_gateway) set_default4 = data->ipv4_gateway->vpn; @@ -977,6 +1085,9 @@ void __connman_connection_gateway_remove(struct connman_service *service, */ if (set_default4 || set_default6 || err < 0) { data = find_default_gateway(); + + GATEWAY_DATA_DBG("default_data", data); + if (data) set_default_gateway(data, type); } @@ -996,6 +1107,8 @@ bool __connman_connection_update_gateway(void) DBG("default %p", default_gateway); + GATEWAY_DATA_DBG("default_gateway", default_gateway); + /* * There can be multiple active gateways so we need to * check them all. @@ -1005,6 +1118,8 @@ bool __connman_connection_update_gateway(void) while (g_hash_table_iter_next(&iter, &key, &value)) { struct gateway_data *active_gateway = value; + GATEWAY_DATA_DBG("active_gateway", active_gateway); + if (active_gateway == default_gateway) continue; From patchwork Tue Nov 28 23:08:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13471922 Received: from mohas.pair.com (mohas.pair.com [209.68.5.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7F125C066 for ; Tue, 28 Nov 2023 23:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from mohas.pair.com (localhost [127.0.0.1]) by mohas.pair.com (Postfix) with ESMTP id 668BF73154 for ; Tue, 28 Nov 2023 18:08:50 -0500 (EST) Received: from localhost.localdomain (unknown [IPv6:2601:647:5a00:15c1:230d:b2c9:c388:f96b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mohas.pair.com (Postfix) with ESMTPSA id 1F1F873180 for ; Tue, 28 Nov 2023 18:08:50 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 4/8] connection: Document 'gateway_{config,data}_debug'. Date: Tue, 28 Nov 2023 15:08:42 -0800 Message-ID: <20231128230847.1224497-5-gerickson@nuovations.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128230847.1224497-1-gerickson@nuovations.com> References: <20231128230847.1224497-1-gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: mailmunge 3.11 on 209.68.5.112 This adds documentation to the 'gateway_{config,data}_debug' functions. --- src/connection.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/connection.c b/src/connection.c index cba1508da3b8..1227c9cdea77 100644 --- a/src/connection.c +++ b/src/connection.c @@ -59,11 +59,45 @@ struct gateway_data { static GHashTable *gateway_hash = NULL; +/** + * @brief + * Return the specified pointer if non-null; otherwise, the + * immutable "" string. + * + * @param[in] pointer The pointer to be returned if non-null. + * + * @returns + * @a pointer if non-null; otherwise the "" immutable + * null-terminated C string. + * + */ static const char *maybe_null(const void *pointer) { return pointer ? pointer : ""; } +/** + * @brief + * Conditionally log the specified gateway configuration. + * + * This conditionally logs at the debug level the specified + * #gateway_config gateway configuration, @a config, with the + * provided description, @a description, attributed to the provided + * function name, @a function. + * + * @param[in] function A pointer to an immutable null-terminated + * C string containing the function name to + * which the call to this function should be + * attributed. + * @param[in] description A pointer to an immutable null-terminated + * C string briefly describing @a + * config. For example, "ipv4_config". + * @param[in] config A pointer to the immutable gateway + * configuration to conditionally log. + * + * @sa CONNMAN_DEBUG + * + */ static void gateway_config_debug(const char *function, const char *description, const struct gateway_config *config) @@ -95,6 +129,29 @@ static void gateway_config_debug(const char *function, } } +/** + * @brief + * Conditionally log the specified gateway data. + * + * This conditionally logs at the debug level the specified + * #gateway_data gateway data, @a data, with the provided + * description, @a description, attributed to the provided function + * name, @a function. + * + * @param[in] function A pointer to an immutable null-terminated + * C string containing the function name to + * which the call to this function should be + * attributed. + * @param[in] description A pointer to an immutable null-terminated + * C string briefly describing @a + * data. For example, "default_gateway". + * @param[in] data A pointer to the immutable gateway + * data to conditionally log. + * + * @sa CONNMAN_DEBUG + * @sa gateway_config_debug + * + */ static void gateway_data_debug(const char *function, const char *description, const struct gateway_data *data) From patchwork Tue Nov 28 23:08:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13471925 Received: from mohas.pair.com (mohas.pair.com [209.68.5.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C66558AB2 for ; Tue, 28 Nov 2023 23:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from mohas.pair.com (localhost [127.0.0.1]) by mohas.pair.com (Postfix) with ESMTP id D59FF7314B for ; Tue, 28 Nov 2023 18:08:50 -0500 (EST) Received: from localhost.localdomain (unknown [IPv6:2601:647:5a00:15c1:230d:b2c9:c388:f96b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mohas.pair.com (Postfix) with ESMTPSA id 8EE887315D for ; Tue, 28 Nov 2023 18:08:50 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 5/8] connection: Expand, Enhance, and Refactor 'DBG'. Date: Tue, 28 Nov 2023 15:08:43 -0800 Message-ID: <20231128230847.1224497-6-gerickson@nuovations.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128230847.1224497-1-gerickson@nuovations.com> References: <20231128230847.1224497-1-gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: mailmunge 3.11 on 209.68.5.112 This expands, exhances, and refactors 'DBG' statements throughout the module to improve symmetry in content, aid in debugging, and to reflect the newly-leveraged 'GATEWAY_CONFIG_DBG' and 'GATEWAY_DATA_DBG' macros. --- src/connection.c | 52 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/src/connection.c b/src/connection.c index 1227c9cdea77..90cc33106ca7 100644 --- a/src/connection.c +++ b/src/connection.c @@ -566,6 +566,9 @@ static void set_default_gateway(struct gateway_data *data, int status4 = 0, status6 = 0; bool do_ipv4 = false, do_ipv6 = false; + DBG("data %p type %d (%s)", data, + type, __connman_ipconfig_type2string(type)); + GATEWAY_DATA_DBG("data", data); if (type == CONNMAN_IPCONFIG_TYPE_IPV4) @@ -575,9 +578,6 @@ static void set_default_gateway(struct gateway_data *data, else do_ipv4 = do_ipv6 = true; - DBG("type %d gateway ipv4 %p ipv6 %p", type, data->ipv4_gateway, - data->ipv6_gateway); - if (do_ipv4 && data->ipv4_gateway && data->ipv4_gateway->vpn) { connman_inet_set_gateway_interface(data->index); @@ -649,6 +649,9 @@ static void unset_default_gateway(struct gateway_data *data, int index; bool do_ipv4 = false, do_ipv6 = false; + DBG("data %p type %d (%s)", data, + type, __connman_ipconfig_type2string(type)); + GATEWAY_DATA_DBG("data", data); if (type == CONNMAN_IPCONFIG_TYPE_IPV4) @@ -776,13 +779,17 @@ static bool choose_default_gateway(struct gateway_data *data, static void connection_newgateway(int index, const char *gateway) { + g_autofree char *interface = NULL; struct gateway_config *config; struct gateway_data *data; GHashTableIter iter; gpointer value, key; bool found = false; - DBG("index %d gateway %s", index, gateway); + interface = connman_inet_ifname(index); + + DBG("index %d (%s) gateway %s", index, maybe_null(interface), + gateway); config = find_gateway(index, gateway); if (!config) @@ -839,7 +846,7 @@ static void remove_gateway(gpointer user_data) { struct gateway_data *data = user_data; - DBG("gateway ipv4 %p ipv6 %p", data->ipv4_gateway, data->ipv6_gateway); + DBG("data %p", data); GATEWAY_DATA_DBG("data", data); @@ -864,10 +871,14 @@ static void remove_gateway(gpointer user_data) static void connection_delgateway(int index, const char *gateway) { + g_autofree char *interface = NULL; struct gateway_config *config; struct gateway_data *data; - DBG("index %d gateway %s", index, gateway); + interface = connman_inet_ifname(index); + + DBG("index %d (%s) gateway %s", index, maybe_null(interface), + gateway); config = find_gateway(index, gateway); if (config) { @@ -974,9 +985,20 @@ int __connman_connection_gateway_add(struct connman_service *service, enum connman_service_type service_type = connman_service_get_type(service); int index; + g_autofree char *interface = NULL; + + DBG("service %p (%s) gateway %p (%s) type %d (%s) peer %p (%s)", + service, maybe_null(connman_service_get_identifier(service)), + gateway, maybe_null(gateway), + type, __connman_ipconfig_type2string(type), + peer, maybe_null(peer)); index = __connman_service_get_index(service); + interface = connman_inet_ifname(index); + + DBG("index %d (%s)", index, maybe_null(interface)); + /* * If gateway is NULL, it's a point to point link and the default * gateway for ipv4 is 0.0.0.0 and for ipv6 is ::, meaning the @@ -1077,9 +1099,21 @@ void __connman_connection_gateway_remove(struct connman_service *service, struct gateway_data *data = NULL; bool set_default4 = false, set_default6 = false; bool do_ipv4 = false, do_ipv6 = false; + int index; + g_autofree char *interface = NULL; int err; - DBG("service %p type %d", service, type); + DBG("service %p (%s) type %d (%s)", + service, maybe_null(connman_service_get_identifier(service)), + type, __connman_ipconfig_type2string(type)); + + index = __connman_service_get_index(service); + if (index < 0) + return; + + interface = connman_inet_ifname(index); + + DBG("index %d (%s)", index, maybe_null(interface)); if (type == CONNMAN_IPCONFIG_TYPE_IPV4) do_ipv4 = true; @@ -1157,12 +1191,14 @@ bool __connman_connection_update_gateway(void) GHashTableIter iter; gpointer value, key; + DBG(""); + if (!gateway_hash) return updated; default_gateway = find_default_gateway(); - DBG("default %p", default_gateway); + DBG("default_gateway %p", default_gateway); GATEWAY_DATA_DBG("default_gateway", default_gateway); From patchwork Tue Nov 28 23:08:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13471926 Received: from mohas.pair.com (mohas.pair.com [209.68.5.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BA365733E for ; Tue, 28 Nov 2023 23:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from mohas.pair.com (localhost [127.0.0.1]) by mohas.pair.com (Postfix) with ESMTP id 5073773159 for ; Tue, 28 Nov 2023 18:08:51 -0500 (EST) Received: from localhost.localdomain (unknown [IPv6:2601:647:5a00:15c1:230d:b2c9:c388:f96b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mohas.pair.com (Postfix) with ESMTPSA id 08AA673174 for ; Tue, 28 Nov 2023 18:08:50 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 6/8] connection: Document 'connection_{add,del}gateway'. Date: Tue, 28 Nov 2023 15:08:44 -0800 Message-ID: <20231128230847.1224497-7-gerickson@nuovations.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128230847.1224497-1-gerickson@nuovations.com> References: <20231128230847.1224497-1-gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: mailmunge 3.11 on 209.68.5.112 This adds documentation to the 'connection_{add,del}gateway' functions. --- src/connection.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/connection.c b/src/connection.c index 90cc33106ca7..db7212d44af4 100644 --- a/src/connection.c +++ b/src/connection.c @@ -777,6 +777,29 @@ static bool choose_default_gateway(struct gateway_data *data, return downgraded; } +/** + * @brief + * Handler for gateway, or default route, -specific routes newly + * added to the Linux kernel routing tables. + * + * This is the Linux Routing Netlink (rtnl) handler for gateway, or + * default route, -specific routes newly-added to the Linux kernel + * routing tables. Its primary role and goal is to serve as a + * round-trip acknowledgement that gateway-, or default route, + * related routes added or set to the kernel are now active and in + * use. + * + * @param[in] index The network interface index associated with + * the newly-added gateway, or default router. + * @param[in] gateway An pointer to an immutable null-terminated + * C string containing the text- + * formatted address of the gateway, or default + * router, that was added. + * + * @sa set_default_gateway + * @sa connection_delgateway + * + */ static void connection_newgateway(int index, const char *gateway) { g_autofree char *interface = NULL; @@ -791,12 +814,23 @@ static void connection_newgateway(int index, const char *gateway) DBG("index %d (%s) gateway %s", index, maybe_null(interface), gateway); + /* + * If there is no gateway configuration, then this is not a + * gateway, or default router, route we added or + * set. Consequently, ignore it and return. + */ config = find_gateway(index, gateway); if (!config) return; GATEWAY_CONFIG_DBG("config", config); + /* + * Otherwise, this is a gateway, or default router, route we added + * or set and it is now acknowledged by the kernel. Consequently, + * prospectively mark it as active; however, this may be + * subsequently modified as default route determinations are made. + */ config->active = true; /* @@ -869,6 +903,29 @@ static void remove_gateway(gpointer user_data) g_free(data); } +/** + * @brief + * Handler for gateway, or default route, -specific routes newly + * removed from the Linux kernel routing tables. + * + * This is the Linux Routing Netlink (rtnl) handler for gateway, or + * default route, -specific routes newly-removed from the Linux + * kernel routing tables. Its primary role and goal is to serve as + * a round-trip acknowledgement that gateway-, or default route, + * related routes removed or cleared from the kernel are now inactive + * and are no longer in use. + * + * @param[in] index The network interface index associated with + * the newly-removed gateway, or default router. + * @param[in] gateway An pointer to an immutable null-terminated + * C string containing the text- + * formatted address of the gateway, or default + * router, that was removed. + * + * @sa connection_newgateway + * @sa set_default_gateway + * + */ static void connection_delgateway(int index, const char *gateway) { g_autofree char *interface = NULL; @@ -880,6 +937,10 @@ static void connection_delgateway(int index, const char *gateway) DBG("index %d (%s) gateway %s", index, maybe_null(interface), gateway); + /* + * This ends the lifecycle of the gateway associated with the + * newly-removed route; mark it as no longer active. + */ config = find_gateway(index, gateway); if (config) { GATEWAY_CONFIG_DBG("config", config); @@ -887,6 +948,12 @@ static void connection_delgateway(int index, const char *gateway) config->active = false; } + /* + * Due to the newly-removed gateway route, there may have been a + * concomitant change in service order that has resulted in a new, + * default service, if any. If so, ensure that service acquires + * the high priority default route. + */ data = find_default_gateway(); if (data) { GATEWAY_DATA_DBG("data", data); From patchwork Tue Nov 28 23:08:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13471928 Received: from mohas.pair.com (mohas.pair.com [209.68.5.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05D865C3C0 for ; Tue, 28 Nov 2023 23:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from mohas.pair.com (localhost [127.0.0.1]) by mohas.pair.com (Postfix) with ESMTP id BEFB8731BE for ; Tue, 28 Nov 2023 18:08:51 -0500 (EST) Received: from localhost.localdomain (unknown [IPv6:2601:647:5a00:15c1:230d:b2c9:c388:f96b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mohas.pair.com (Postfix) with ESMTPSA id 77C12731FC for ; Tue, 28 Nov 2023 18:08:51 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 7/8] connection: Document '__connman_connection_gateway_{add,remove}'. Date: Tue, 28 Nov 2023 15:08:45 -0800 Message-ID: <20231128230847.1224497-8-gerickson@nuovations.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128230847.1224497-1-gerickson@nuovations.com> References: <20231128230847.1224497-1-gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: mailmunge 3.11 on 209.68.5.112 This adds documentation to the '__connman_connection_gateway_{add,remove}' functions. --- src/connection.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/src/connection.c b/src/connection.c index db7212d44af4..8208671d6986 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1040,6 +1040,41 @@ static void add_host_route(int family, int index, const char *gateway, } } +/** + * @brief + * Add, or set, the gateway, or default router, for a network + * service. + * + * This attempts to add, or set, the gateway, or default router, for + * a network service using the specified IP configuration gateway + * address and network interface index as the lookup key for the + * network service. + * + * @param[in,out] service A pointer to the mutable network service + * for which to add a gateway, or default + * router. + * @param[in] gateway An optional pointer to an immutable null- + * terminated C string containing the + * text-formatted address of the gateway, or + * default router, to add to or associate + * with @a service. + * @param[in] type The IP configuration type for which + * gateway, or default router, is to be + * added. + * @param[in] peer An optional pointer to an immutable null- + * terminated C string containing the + * text-formatted address of the network + * peer, for point-to-point links, + * associated with the gateway. + * + * @retval 0 If successful. + * @retval -EINVAL If service is null or if network interface + * index associated with @a service is invalid. + * + * @sa __connman_connection_gateway_remove + * @sa __connman_connection_update_gateway + * + */ int __connman_connection_gateway_add(struct connman_service *service, const char *gateway, enum connman_ipconfig_type type, @@ -1160,6 +1195,30 @@ done: return 0; } +/** + * @brief + * Remove, or clear, the gateway, or default router, for a network + * service. + * + * This attempts to remove, or clear, the gateway, or default router, + * for a network service using the specified network service and IP + * configuration type. + * + * @param[in,out] service A pointer to the mutable network service + * for which to remove, or clear, a gateway, + * or default router. + * @param[in] type The IP configuration type for which + * gateway, or default router, is to be + * removed. + * + * @retval 0 If successful. + * @retval -EINVAL If service is null or if network interface + * index associated with @a service is invalid. + * + * @sa __connman_connection_gateway_add + * @sa __connman_connection_update_gateway + * + */ void __connman_connection_gateway_remove(struct connman_service *service, enum connman_ipconfig_type type) { @@ -1189,8 +1248,14 @@ void __connman_connection_gateway_remove(struct connman_service *service, else do_ipv4 = do_ipv6 = true; + /* Delete any routes associated with this service's nameservers. */ + __connman_service_nameserver_del_routes(service, type); + /* + * If there is no hash table / map entry for this service, then + * there are no gateways associated with it; simply return. + */ data = g_hash_table_lookup(gateway_hash, service); if (!data) return; @@ -1208,6 +1273,8 @@ void __connman_connection_gateway_remove(struct connman_service *service, data->ipv6_gateway ? data->ipv6_gateway->gateway : "", set_default4, set_default6); + /* If necessary, delete any VPN-related host routes. */ + if (do_ipv4 && data->ipv4_gateway && data->ipv4_gateway->vpn && data->index >= 0) connman_inet_del_host_route(data->ipv4_gateway->vpn_phy_index, @@ -1219,11 +1286,13 @@ void __connman_connection_gateway_remove(struct connman_service *service, data->ipv6_gateway->vpn_phy_index, data->ipv6_gateway->gateway); + /* Remove all active routes associated with this gateway data. */ + err = disable_gateway(data, type); /* - * We remove the service from the hash only if all the gateway - * settings are to be removed. + * We remove the service from the service/gateway map only if ALL + * of the gateway settings are to be removed. */ if (do_ipv4 == do_ipv6 || (data->ipv4_gateway && !data->ipv6_gateway From patchwork Tue Nov 28 23:08:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13471927 Received: from mohas.pair.com (mohas.pair.com [209.68.5.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05D2A5C09B for ; Tue, 28 Nov 2023 23:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from mohas.pair.com (localhost [127.0.0.1]) by mohas.pair.com (Postfix) with ESMTP id 3A86E731A8 for ; Tue, 28 Nov 2023 18:08:52 -0500 (EST) Received: from localhost.localdomain (unknown [IPv6:2601:647:5a00:15c1:230d:b2c9:c388:f96b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mohas.pair.com (Postfix) with ESMTPSA id E63E5731F7 for ; Tue, 28 Nov 2023 18:08:51 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 8/8] connection: Document '__connman_connection_update_gateway'. Date: Tue, 28 Nov 2023 15:08:46 -0800 Message-ID: <20231128230847.1224497-9-gerickson@nuovations.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128230847.1224497-1-gerickson@nuovations.com> References: <20231128230847.1224497-1-gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: mailmunge 3.11 on 209.68.5.112 This adds documentation to the '__connman_connection_update_gateway' function. --- src/connection.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/connection.c b/src/connection.c index 8208671d6986..75591a741ad4 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1320,6 +1320,24 @@ void __connman_connection_gateway_remove(struct connman_service *service, } } +/** + * @brief + * Handle a potential change in gateways. + * + * This may be invoked by other modules in the event of service and + * technology changes to reexamine and, if necessary, update active + * network interface gateways and their associated routing table + * entries. + * + * @returns + * True if an active gateway was updated; otherwise, false. + * + * @sa __connman_connection_gateway_add + * @sa __connman_connection_gateway_remove + * @sa set_default_gateway + * @sa unset_default_gateway + * + */ bool __connman_connection_update_gateway(void) { struct gateway_data *default_gateway; @@ -1329,6 +1347,10 @@ bool __connman_connection_update_gateway(void) DBG(""); + /* + * If there is no service-to-gateway data hash, then there is + * nothing to update and do; simply return. + */ if (!gateway_hash) return updated;