diff options
author | Grant Erickson <gerickson@nuovations.com> | 2023-12-19 21:56:12 -0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2023-12-23 13:14:31 +0100 |
commit | e4bf3db0aa426a876afda47572fd66fe9f2d3489 (patch) | |
tree | 05c55337cf36ec490ce4906ffcc42a22a89e2aac | |
parent | 264fec5edb28dfe64f533b55d338840f938db1fe (diff) | |
download | connman-e4bf3db0aa426a876afda47572fd66fe9f2d3489.tar.gz |
gateway: Add and leveage 'gateway_config_set_{,in}active'.
This encapsulates and makes symmetric the actions at the "terminal
ends" of the gateway configuration lifecycle / state machine by adding
and leveraging 'gateway_config_set_{,in}active' to set the gateway
configuration state and type appropriately.
-rw-r--r-- | src/gateway.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/gateway.c b/src/gateway.c index b5a1e2ddb..42a8da726 100644 --- a/src/gateway.c +++ b/src/gateway.c @@ -787,6 +787,20 @@ static bool is_gateway_config_type(const struct gateway_config *config, return config->type == type; } +static void gateway_config_set_active(struct gateway_config *config) +{ + gateway_config_state_set(config, CONNMAN_GATEWAY_CONFIG_STATE_ACTIVE); +} + +static void gateway_config_set_inactive(struct gateway_config *config) +{ + gateway_config_state_set(config, + CONNMAN_GATEWAY_CONFIG_STATE_INACTIVE); + + gateway_config_type_set(config, + CONNMAN_GATEWAY_CONFIG_TYPE_NONE); +} + /** * @brief * Conditionally log the specified gateway configuration. @@ -3366,8 +3380,7 @@ static void gateway_rtnl_new(int index, const char *gateway) * and it is now acknowledged by the kernel. Consequently, mark it * as active. */ - gateway_config_state_set(config, - CONNMAN_GATEWAY_CONFIG_STATE_ACTIVE); + gateway_config_set_active(config); /* * It is possible that we have two default routes atm @@ -3471,13 +3484,9 @@ static void gateway_rtnl_del(int index, const char *gateway) if (config) { GATEWAY_CONFIG_DBG("config", config); - if (is_gateway_config_state_removed(config)) { - gateway_config_state_set(config, - CONNMAN_GATEWAY_CONFIG_STATE_INACTIVE); - - gateway_config_type_set(config, - CONNMAN_GATEWAY_CONFIG_TYPE_NONE); - } else { + if (is_gateway_config_state_removed(config)) + gateway_config_set_inactive(config); + else { DBG("ignoring gateway stale removed activation; " "probably added before removed activation completed"); |