Skip to contentSkip to conversation

gateway: Promote a low-priority default service gateway

PATCH New Grant Erickson 1 participant 1 message Nov 13

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gateway: Promote a low-priority default service gateway

__connman_gateway_update gives the default service's gateway the high-priority default route only if demoting another gateway succeeded, or if the default service's gateway is not yet active.

Since low-priority default routes were introduced 5083062922e5 ("connection: Add support for low-priority default routes."), every connected service's gateway is active. When the default service's gateway is removed rather than demoted (for example, when its DHCP lease expires with no server to renew it), nothing is demoted. The service that is default once the list is re-sorted then keeps its low-priority default route, active, and is never promoted. No default route has metric 0, and, since only a promotion calls __connman_service_indicate_default, the new default service may not be signaled as such or online checked.

Also promote the default service's gateway when it is active but only as a low-priority default gateway.

---
 src/gateway.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
src/gateway.c +10 -4
index b2c211e2dc8d..86221be5ead9 100644
@@ -3976,8 +3976,10 @@ bool __connman_gateway_update(void)
 	DBG("updated4 %u updated6 %u", updated4, updated6);
 
 	/*
-	 * Set default gateway if it has been updated or if it has not been
-	 * set as active yet.
+	 * Set default gateway if it has been updated, if it has not been
+	 * set as active yet, or if it is active but only as a
+	 * low-priority default gateway, for example after the gateway of
+	 * the former default service was removed rather than demoted.
 	 */
 	if (default_gateway) {
 		const struct gateway_config *default_config;
@@ -3987,7 +3989,9 @@ bool __connman_gateway_update(void)
 
 		if (default_config &&
 			(updated4 ||
-			!is_gateway_config_state_active(default_config)))
+			!is_gateway_config_state_active(default_config) ||
+			is_gateway_config_type(default_config,
+				CONNMAN_GATEWAY_CONFIG_TYPE_LOW_PRIORITY_DEFAULT)))
 			PROMOTE_DEFAULT_GATEWAY(default_gateway, type);
 
 		type = CONNMAN_IPCONFIG_TYPE_IPV6;
@@ -3995,7 +3999,9 @@ bool __connman_gateway_update(void)
 
 		if (default_config &&
 			(updated6 ||
-			!is_gateway_config_state_active(default_config)))
+			!is_gateway_config_state_active(default_config) ||
+			is_gateway_config_type(default_config,
+				CONNMAN_GATEWAY_CONFIG_TYPE_LOW_PRIORITY_DEFAULT)))
 			PROMOTE_DEFAULT_GATEWAY(default_gateway, type);
 	}
 
Signature · 1 line
2.52.0