summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-08-28 18:32:05 +0200
committerThomas Haller <thaller@redhat.com>2014-11-05 23:54:19 +0100
commitfb806756fff2d4f40fb41fc6a71b23414f7fc60d (patch)
treea2b2aee35892f5f9e6976b2bc08e7d7810ddade7
parent1d6d9221db907820ea8f1954f127ac23d9e88023 (diff)
downloadNetworkManager-fb806756fff2d4f40fb41fc6a71b23414f7fc60d.tar.gz
core: overwrite the default route priority via connection setting
Make use of the new settings nm_setting_ip4_config_get_route_metric() and nm_setting_ip6_config_get_route_metric(). If set, they override the route metric determined based on the device type. Similarly for VPN also prefer the setting from the connection. Thereby change the default priority (for VPN that have their own device) to NM_VPN_ROUTE_METRIC_DEFAULT instead of NM_PLATFORM_ROUTE_METRIC_DEFAULT. The latter would be a very low priority compared to the default metrics for devices. Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/devices/nm-device.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 003d900383..b90a19ced1 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -684,13 +684,33 @@ nm_device_get_priority (NMDevice *self)
guint32
nm_device_get_ip4_route_metric (NMDevice *self)
{
- return nm_device_get_priority (self);
+ NMConnection *connection;
+ gint64 route_metric = -1;
+
+ g_return_val_if_fail (NM_IS_DEVICE (self), G_MAXUINT32);
+
+ connection = nm_device_get_connection (self);
+
+ if (connection)
+ route_metric = nm_setting_ip4_config_get_route_metric (nm_connection_get_setting_ip4_config (connection));
+
+ return route_metric >= 0 ? route_metric : nm_device_get_priority (self);
}
guint32
nm_device_get_ip6_route_metric (NMDevice *self)
{
- return nm_device_get_priority (self);
+ NMConnection *connection;
+ gint64 route_metric = -1;
+
+ g_return_val_if_fail (NM_IS_DEVICE (self), G_MAXUINT32);
+
+ connection = nm_device_get_connection (self);
+
+ if (connection)
+ route_metric = nm_setting_ip6_config_get_route_metric (nm_connection_get_setting_ip6_config (connection));
+
+ return route_metric >= 0 ? route_metric : nm_device_get_priority (self);
}
const char *