mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 02:30:08 +01:00
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.
This commit is contained in:
parent
6801cd65bf
commit
c16e871888
2 changed files with 7 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue