summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/devices/nm-device.c5
-rw-r--r--src/nm-core-utils.h6
2 files changed, 7 insertions, 4 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 55ad6c3237..b861f2cb65 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -5553,10 +5553,7 @@ _device_get_default_route_from_platform (NMDevice *self, int addr_family, NMPlat
continue;
/* if there are several default routes, find the one with the best metric */
- m = r->metric;
- if (addr_family != AF_INET)
- m = nm_utils_ip6_route_metric_normalize (r->metric);
-
+ m = nm_utils_ip_route_metric_normalize (addr_family, r->metric);
if (!route || m < route_metric) {
route = NMP_OBJECT_CAST_IP_ROUTE (plobj);
route_metric = m;
diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h
index 42afcb0e2d..f9545653de 100644
--- a/src/nm-core-utils.h
+++ b/src/nm-core-utils.h
@@ -174,6 +174,12 @@ nm_utils_ip6_route_metric_normalize (guint32 metric)
return metric ? metric : 1024 /*NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6*/;
}
+static inline guint32
+nm_utils_ip_route_metric_normalize (int addr_family, guint32 metric)
+{
+ return addr_family == AF_INET6 ? nm_utils_ip6_route_metric_normalize (metric) : metric;
+}
+
int nm_utils_modprobe (GError **error, gboolean suppress_error_loggin, const char *arg1, ...) G_GNUC_NULL_TERMINATED;
guint64 nm_utils_get_start_time_for_pid (pid_t pid, char *out_state, pid_t *out_ppid);