diff options
author | Thomas Haller <thaller@redhat.com> | 2017-08-30 19:10:59 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-09-08 11:05:04 +0200 |
commit | c16e8718880b18fcaa8d2e4bf3b4ee98ee995768 (patch) | |
tree | f856b3e2e1d6ee0c225642aa9031e4c23ad7f189 | |
parent | 6801cd65bf5b429d7295f335605742b92642c508 (diff) | |
download | NetworkManager-c16e8718880b18fcaa8d2e4bf3b4ee98ee995768.tar.gz |
core: nm_utils_ip_route_metric_normalize() util
Functions that take and addr_family argument are just nicer
to use at places where we treat IPv4 and IPv6 generically.
-rw-r--r-- | src/devices/nm-device.c | 5 | ||||
-rw-r--r-- | src/nm-core-utils.h | 6 |
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); |