Skip to contentSkip to conversation

gateway: Fix lost default gateway demotions

PATCH New Grant Erickson 1 participant 1 message Nov 12

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gateway: Fix lost default gateway demotions

__connman_gateway_update demotes the default route of every active gateway other than that of the default service and then, if any demotion succeeded, promotes the default service's gateway. However, each demotion overwrote rather than accumulated the outcome:

    updated4 = status == 0;

Since low-priority default routes were introduced, every connected service's gateway is active. Demoting a gateway that is already low-priority fails with -EALREADY, so whichever gateway the hash iteration visits last decides. With three or more connected services, a failed demotion of a junior service erases the successful demotion of the former default before it. The new default's gateway, still active at low priority, is then not promoted, there is no high-priority default route, and, since only a promotion calls __connman_service_indicate_default, the new default service is never signaled as such and is not online checked.

This is how a service that meets the continuous online check failures threshold, for example Ethernet behind a failed upstream, is sorted below the Wi-Fi and cellular services but remains the only service with a default route, while the Wi-Fi service, now first, stays "ready" indefinitely.

Accumulate the outcomes, as before low-priority default routes, so that any successful demotion promotes the default service's gateway.

---
 src/gateway.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
src/gateway.c +4 -2
index b2c211e2dc8d..2314ddb126bf 100644
@@ -3957,7 +3957,8 @@ bool __connman_gateway_update(void)
 			status = DEMOTE_DEFAULT_GATEWAY(current_gateway,
 						type);
 
-			updated4 = status == 0;
+			if (status == 0)
+				updated4 = true;
 		}
 
 		type = CONNMAN_IPCONFIG_TYPE_IPV6;
@@ -3969,7 +3970,8 @@ bool __connman_gateway_update(void)
 			status = DEMOTE_DEFAULT_GATEWAY(current_gateway,
 						type);
 
-			updated6 = status == 0;
+			if (status == 0)
+				updated6 = true;
 		}
 	}
 
Signature · 1 line
2.52.0