From 2f0d26e02cfc20c1a6423c3c611062c3d9418621 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 14 Jun 2018 11:43:33 +0200 Subject: device: avoid accidentally changing route-metric during config-reload It's not properly implemented, to change the route-metric while being active. That would require pecular re-initializations. Avoid that a configuration reload, can change the used route-metric unexpectedly. It doesn't cover all potential changes, because nm_manager_device_route_metric_reserve() might still return a different value. That is however rather unlikely, because neither the ifindex nor the device-type is expected to change. --- src/devices/nm-device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 08ed04fef4..a773b012fb 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1956,6 +1956,7 @@ guint32 nm_device_get_route_metric (NMDevice *self, int addr_family) { + NMDevicePrivate *priv; char *value; gint64 route_metric; NMSettingIPConfig *s_ip; @@ -1981,10 +1982,12 @@ nm_device_get_route_metric (NMDevice *self, } } + priv = NM_DEVICE_GET_PRIVATE (self); + /* use the current NMConfigData, which makes this configuration reloadable. * Note that that means that the route-metric might change between SIGHUP. * You must cache the returned value if that is a problem. */ - value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, + value = nm_config_data_get_connection_default (priv->cur_config_data, addr_family == AF_INET ? "ipv4.route-metric" : "ipv6.route-metric", self); if (value) { route_metric = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1); -- cgit v1.2.1