From c4f74fcfb6aeff95d6ce697f705438e63e8a52a9 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 24 Oct 2017 20:46:24 +0200 Subject: [PATCH] device: don't configure automatic default-routes if an explicit gateway is set Since commit 5c299454b49b165f645c25fd3e083c0bb747ad91 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: 5c299454b49b165f645c25fd3e083c0bb747ad91 --- src/devices/nm-device.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 3060c60959..0ea45d5e5a 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -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);