device: don't configure automatic default-routes if an explicit gateway is set

Since commit 5c299454b4 we can configure
multiple default-routes.

That is especially useful with IPv6 to configure multiple routers.
It will also be useful, once we allow configuring manual default-routes,
like regular static routes.

However the problem is, that the default-route for the manual gateway
and the gateway from DHCP both get the same metric. So it's undefined
which route is used. To avoid that problem, and to restore previous
behavior, don't accept any default-routes if a gateway is set.

Fixes: 5c299454b4
This commit is contained in:
Thomas Haller 2017-10-24 20:46:24 +02:00 committed by Beniamino Galvani
parent b16c853bef
commit c4f74fcfb6

View file

@ -5785,7 +5785,11 @@ ip4_config_merge_and_apply (NMDevice *self,
if (s_ip4) {
ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip4);
ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip4);
ignore_default_routes = nm_setting_ip_config_get_never_default (s_ip4);
/* if the connection has an explicit gateway, we also ignore
* the default routes from other sources. */
ignore_default_routes = nm_setting_ip_config_get_never_default (s_ip4)
|| nm_setting_ip_config_get_gateway (s_ip4);
}
}
@ -6439,7 +6443,11 @@ ip6_config_merge_and_apply (NMDevice *self,
ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip6);
ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip6);
ignore_default_routes = nm_setting_ip_config_get_never_default (s_ip6);
/* if the connection has an explicit gateway, we also ignore
* the default routes from other sources. */
ignore_default_routes = nm_setting_ip_config_get_never_default (s_ip6)
|| nm_setting_ip_config_get_gateway (s_ip6);
if (nm_setting_ip6_config_get_addr_gen_mode (ip6) == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64)
token = nm_setting_ip6_config_get_token (ip6);