From a2662633a5ea21387cb9645440dc48b96b6100df Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 28 Aug 2014 18:16:35 +0200 Subject: [PATCH] core: modify the values/route metric returned by nm_device_get_priority() nm_device_get_priority() is used to select the "best" device for the default route. The absolute values don't matter at that point and the relative ordering is not changed by this patch. It is also directly used for route priority/metric. As we soon allow the user to overwrite the setting, we want to get more space between the individual device-types. That way, a user could overwrite the default metric for a wifi device to be 109 (making it lower then the default value 110), but still less preferred then other non-wifi types. Obviously, this patch is a visible change of behavior as now routes get different metrics assigned. Signed-off-by: Thomas Haller --- src/devices/nm-device.c | 47 +++++++++++++++-------------- src/vpn-manager/nm-vpn-connection.h | 3 ++ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index efb7f25d2d..efb4a69257 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -640,7 +640,7 @@ nm_device_get_device_type (NMDevice *self) int nm_device_get_priority (NMDevice *self) { - g_return_val_if_fail (NM_IS_DEVICE (self), 100); + g_return_val_if_fail (NM_IS_DEVICE (self), 1000); /* Device 'priority' is used for two things: * @@ -653,30 +653,31 @@ nm_device_get_priority (NMDevice *self) */ switch (nm_device_get_device_type (self)) { + /* 10 is reserved for VPN (NM_VPN_ROUTE_METRIC_DEFAULT) */ case NM_DEVICE_TYPE_ETHERNET: - return 1; - case NM_DEVICE_TYPE_INFINIBAND: - return 2; - case NM_DEVICE_TYPE_ADSL: - return 3; - case NM_DEVICE_TYPE_WIMAX: - return 4; - case NM_DEVICE_TYPE_BOND: - return 5; - case NM_DEVICE_TYPE_TEAM: - return 6; - case NM_DEVICE_TYPE_VLAN: - return 7; - case NM_DEVICE_TYPE_MODEM: - return 8; - case NM_DEVICE_TYPE_BT: - return 9; - case NM_DEVICE_TYPE_WIFI: - return 10; - case NM_DEVICE_TYPE_OLPC_MESH: - return 11; - default: return 20; + case NM_DEVICE_TYPE_INFINIBAND: + return 30; + case NM_DEVICE_TYPE_ADSL: + return 40; + case NM_DEVICE_TYPE_WIMAX: + return 50; + case NM_DEVICE_TYPE_BOND: + return 60; + case NM_DEVICE_TYPE_TEAM: + return 70; + case NM_DEVICE_TYPE_VLAN: + return 80; + case NM_DEVICE_TYPE_MODEM: + return 90; + case NM_DEVICE_TYPE_BT: + return 100; + case NM_DEVICE_TYPE_WIFI: + return 110; + case NM_DEVICE_TYPE_OLPC_MESH: + return 120; + default: + return 200; } } diff --git a/src/vpn-manager/nm-vpn-connection.h b/src/vpn-manager/nm-vpn-connection.h index 31a2734e39..047113c318 100644 --- a/src/vpn-manager/nm-vpn-connection.h +++ b/src/vpn-manager/nm-vpn-connection.h @@ -46,6 +46,9 @@ #define NM_VPN_CONNECTION_INTERNAL_RETRY_AFTER_FAILURE "internal-retry-after-failure" +#define NM_VPN_ROUTE_METRIC_DEFAULT 10 + + struct _NMVpnConnection { NMActiveConnection parent; };