mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 11:50:14 +01:00
core: ignore gateway host route during connection generation
When a gateway is not in the prefix of any of the interface's IP addresses, NetworkManager adds a static host route to the gateway through the interface to ensure the gateway can be reached. That route will not be part of the persistent connection (since it was added automatically) but would normally be picked up by connection generation. This would cause the generated connection not to match with the persistent connection, because the persistent connection does not have the host route. Ignore the gateway host route when capturing the interface's existing IP configuration.
This commit is contained in:
parent
befa9083e8
commit
4fba2260f3
2 changed files with 32 additions and 0 deletions
|
|
@ -210,6 +210,22 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
|
|||
}
|
||||
}
|
||||
|
||||
/* If there is a host route to the gateway, ignore that route. It is
|
||||
* automatically added by NetworkManager when needed.
|
||||
*/
|
||||
if (has_gateway) {
|
||||
for (i = 0; i < priv->routes->len; i++) {
|
||||
const NMPlatformIP4Route *route = &g_array_index (priv->routes, NMPlatformIP4Route, i);
|
||||
|
||||
if ( (route->plen == 32)
|
||||
&& (route->network == priv->gateway)
|
||||
&& (route->gateway == 0)) {
|
||||
g_array_remove_index (priv->routes, i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If the interface has the default route, and has IPv4 addresses, capture
|
||||
* nameservers from /etc/resolv.conf.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -212,6 +212,22 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf)
|
|||
}
|
||||
}
|
||||
|
||||
/* If there is a host route to the gateway, ignore that route. It is
|
||||
* automatically added by NetworkManager when needed.
|
||||
*/
|
||||
if (has_gateway) {
|
||||
for (i = 0; i < priv->routes->len; i++) {
|
||||
const NMPlatformIP6Route *route = &g_array_index (priv->routes, NMPlatformIP6Route, i);
|
||||
|
||||
if ( route->plen == 128
|
||||
&& IN6_ARE_ADDR_EQUAL (&route->network, &priv->gateway)
|
||||
&& IN6_IS_ADDR_UNSPECIFIED (&route->gateway)) {
|
||||
g_array_remove_index (priv->routes, i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If the interface has the default route, and has IPv4 addresses, capture
|
||||
* nameservers from /etc/resolv.conf.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue