From ae2b8d6353391b86528e045ee9a56793871e8286 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 26 Nov 2014 20:47:44 +0100 Subject: [PATCH] core: rename NM_PLATFORM_ROUTE_METRIC_DEFAULT to NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6 For IPv4, iproute for example defaults to a metric of 0. Hence, the name NM_PLATFORM_ROUTE_METRIC_DEFAULT was misleading. Also add a NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4 define for completeness. https://bugzilla.gnome.org/show_bug.cgi?id=740780 --- src/NetworkManagerUtils.h | 4 ++-- src/devices/nm-device.c | 2 +- src/platform/nm-platform.h | 12 +++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h index 0ed7587a63..f2ff4bdbe7 100644 --- a/src/NetworkManagerUtils.h +++ b/src/NetworkManagerUtils.h @@ -39,14 +39,14 @@ const struct in6_addr *nm_utils_ip6_address_clear_host_address (struct in6_addr * @metric: the route metric * * For IPv6 route, kernel treats the value 0 as IP6_RT_PRIO_USER (1024). - * Thus, when comparing metric (values), we want to treat zero as NM_PLATFORM_ROUTE_METRIC_DEFAULT. + * Thus, when comparing metric (values), we want to treat zero as NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6. * * Returns: @metric, if @metric is not zero, otherwise 1024. */ static inline guint32 nm_utils_ip6_route_metric_normalize (guint32 metric) { - return metric ? metric : 1024 /*NM_PLATFORM_ROUTE_METRIC_DEFAULT*/; + return metric ? metric : 1024 /*NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6*/; } int nm_spawn_process (const char *args); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 009c6a626f..69a6d8cd02 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -669,7 +669,7 @@ nm_device_get_priority (NMDevice *self) * * For comparison, note that iproute2 by default adds IPv4 routes with * metric 0, and IPv6 routes with metric 1024. The latter is the IPv6 - * "user default" in the kernel (NM_PLATFORM_ROUTE_METRIC_DEFAULT). + * "user default" in the kernel (NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6). * In kernel, the full uint32_t range is available for route * metrics (except for IPv6, where 0 means 1024). */ diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 12198c79f4..941cd0a028 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -184,9 +184,15 @@ typedef union { #undef __NMPlatformIPAddress_COMMON -/* Adding an IPv6 route with metric 0, kernel translates to IP6_RT_PRIO_USER (1024). - * Thus, the value is not choosen arbitraily, but matches kernel IPv6 default. */ -#define NM_PLATFORM_ROUTE_METRIC_DEFAULT 1024 +/* Default value for adding an IPv4 route. This is also what iproute2 does. + * Note that contrary to IPv6, you can add routes with metric 0 and it is even + * the default. + */ +#define NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4 0 + +/* Default value for adding an IPv6 route. This is also what iproute2 does. + * Adding an IPv6 route with metric 0, kernel translates to IP6_RT_PRIO_USER (1024). */ +#define NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6 1024 /* For IPv4, kernel adds a device route (subnet routes) with metric 0 when user * configures addresses. */