Commit 45b5defc authored by Jussi Laakkonen's avatar Jussi Laakkonen

connection: Check for active flag when updating default gateway

Set default gateway if it has been updated or if it has not been set as
active yet.

The check for active interface is required in cases that are induced by
a race condition caused by a change of interfaces that are either too
fast or too slow to go down, or to get up. In such case the interface
that should be used as default gateway may end up with no default route
set in routing table.

This is because the change happens in a situation where the old default
service A going down is still online, when the new service B that is
becoming the new default, is still in ready state. The new default
service B is not detected as default gateway because of the service list
order. The new service B has been added to gateway_hash and the routes
other than the default route have been set into routing table.

After this the routes of the old default service A are removed but
because of the old default service A still being the default service
according to service list, the removal of routes of the old default
service A does not get the new default gateway B to be selected as the
default gateway. After this the old default service A is properly
disconnected and set to idle setting the new default service B as the
default service.

The next call to this update gateway function results in a situation where
updated flag is not set, hence new default service B is the only one in
the gateway_hash. By checking also the active flag of the gateway the
new default gateway B in the scenario above will have a default route
set also in routing table.

[connman] Check active flag when updating gateway. Contributes to JB#42017
parent 6c365d45
......@@ -1051,12 +1051,18 @@ bool __connman_connection_update_gateway(void)
}
}
if (updated && default_gateway) {
if (default_gateway->ipv4_gateway)
/*
* Set default gateway if it has been updated or if it has not been
* set as active yet.
*/
if (default_gateway) {
if (default_gateway->ipv4_gateway &&
(updated || !default_gateway->ipv4_gateway->active))
set_default_gateway(default_gateway,
CONNMAN_IPCONFIG_TYPE_IPV4);
if (default_gateway->ipv6_gateway)
if (default_gateway->ipv6_gateway &&
(updated || !default_gateway->ipv6_gateway->active))
set_default_gateway(default_gateway,
CONNMAN_IPCONFIG_TYPE_IPV6);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment