about summary refs log tree commit diff
path: root/src/platform/nm-platform.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2015-01-22 00:29:39 +0100
committerMichael Biebl <biebl@debian.org>2015-01-22 00:29:39 +0100
commit2c032d8f1c6292c1338a615e6ec40252889ba85c (patch)
tree1f77182220b2b0264288ba4a476ab47e5bc48716 /src/platform/nm-platform.c
parent33491bc4279481db8ae47213e34a6d695a0e8830 (diff)
Imported Upstream version 1.0.0 upstream/1.0.0
Diffstat (limited to 'src/platform/nm-platform.c')
-rw-r--r--src/platform/nm-platform.c293
1 files changed, 220 insertions, 73 deletions
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index 542b0faa..14fc44c5 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -18,6 +18,8 @@
  * Copyright (C) 2012 Red Hat, Inc.
  */
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
@@ -26,6 +28,7 @@
 #include <string.h>
 #include <netlink/route/addr.h>
 
+#include "gsystem-local-alloc.h"
 #include "NetworkManagerUtils.h"
 #include "nm-utils.h"
 #include "nm-platform.h"
@@ -215,6 +218,21 @@ nm_platform_check_support_kernel_extended_ifa_flags ()
 	return klass->check_support_kernel_extended_ifa_flags (platform);
 }
 
+gboolean
+nm_platform_check_support_user_ipv6ll (void)
+{
+	static int supported = -1;
+
+	g_return_val_if_fail (NM_IS_PLATFORM (platform), FALSE);
+
+	if (!klass->check_support_user_ipv6ll)
+		return FALSE;
+
+	if (supported < 0)
+		supported = klass->check_support_user_ipv6ll (platform) ? 1 : 0;
+	return !!supported;
+}
+
 /******************************************************************/
 
 /**
@@ -730,6 +748,52 @@ nm_platform_link_uses_arp (int ifindex)
 }
 
 /**
+ * nm_platform_link_get_user_ip6vll_enabled:
+ * @ifindex: Interface index
+ *
+ * Check whether NM handles IPv6LL address creation for the link.  If the
+ * platform or OS doesn't support changing the IPv6LL address mode, this call
+ * will fail and return %FALSE.
+ *
+ * Returns: %TRUE if NM handles the IPv6LL address for @ifindex
+ */
+gboolean
+nm_platform_link_get_user_ipv6ll_enabled (int ifindex)
+{
+	reset_error ();
+
+	g_return_val_if_fail (ifindex >= 0, FALSE);
+	g_return_val_if_fail (klass->check_support_user_ipv6ll, FALSE);
+
+	if (klass->link_get_user_ipv6ll_enabled)
+		return klass->link_get_user_ipv6ll_enabled (platform, ifindex);
+	return FALSE;
+}
+
+/**
+ * nm_platform_link_set_user_ip6vll_enabled:
+ * @ifindex: Interface index
+ *
+ * Set whether NM handles IPv6LL address creation for the link.  If the
+ * platform or OS doesn't support changing the IPv6LL address mode, this call
+ * will fail and return %FALSE.
+ *
+ * Returns: %TRUE if the operation was successful, %FALSE if it failed.
+ */
+gboolean
+nm_platform_link_set_user_ipv6ll_enabled (int ifindex, gboolean enabled)
+{
+	reset_error ();
+
+	g_return_val_if_fail (ifindex >= 0, FALSE);
+	g_return_val_if_fail (klass->check_support_user_ipv6ll, FALSE);
+
+	if (klass->link_set_user_ipv6ll_enabled)
+		return klass->link_set_user_ipv6ll_enabled (platform, ifindex, enabled);
+	return FALSE;
+}
+
+/**
  * nm_platform_link_set_address:
  * @ifindex: Interface index
  * @address: The new MAC address
@@ -877,7 +941,7 @@ nm_platform_link_set_mtu (int ifindex, guint32 mtu)
 	g_return_val_if_fail (mtu > 0, FALSE);
 	g_return_val_if_fail (klass->link_set_mtu, FALSE);
 
-	debug ("link: setting '%s' (%d) mtu %d", nm_platform_link_get_name (ifindex), ifindex, mtu);
+	debug ("link: setting '%s' (%d) mtu %"G_GUINT32_FORMAT, nm_platform_link_get_name (ifindex), ifindex, mtu);
 	return klass->link_set_mtu (platform, ifindex, mtu);
 }
 
@@ -1051,7 +1115,7 @@ nm_platform_team_add (const char *name)
  * nm_platform_vlan_add:
  * @name: New interface name
  * @vlanid: VLAN identifier
- * @vlanflags: VLAN flags from libnm-util
+ * @vlanflags: VLAN flags from libnm
  *
  * Create a software VLAN device.
  */
@@ -1266,7 +1330,7 @@ nm_platform_wifi_get_capabilities (int ifindex, NMDeviceWifiCapabilities *caps)
 }
 
 gboolean
-nm_platform_wifi_get_bssid (int ifindex, struct ether_addr *bssid)
+nm_platform_wifi_get_bssid (int ifindex, guint8 *bssid)
 {
 	reset_error ();
 
@@ -1377,14 +1441,38 @@ nm_platform_mesh_set_channel (int ifindex, guint32 channel)
 }
 
 gboolean
-nm_platform_mesh_set_ssid (int ifindex, const GByteArray *ssid)
+nm_platform_mesh_set_ssid (int ifindex, const guint8 *ssid, gsize len)
 {
 	reset_error ();
 
 	g_return_val_if_fail (ifindex > 0, FALSE);
 	g_return_val_if_fail (ssid != NULL, FALSE);
 
-	return klass->mesh_set_ssid (platform, ifindex, ssid);
+	return klass->mesh_set_ssid (platform, ifindex, ssid, len);
+}
+
+#define TO_STRING_DEV_BUF_SIZE (5+15+1)
+static const char *
+_to_string_dev (int ifindex, char *buf, size_t size)
+{
+	g_assert (buf && size >= TO_STRING_DEV_BUF_SIZE);
+
+	if (ifindex) {
+		const char *name = ifindex > 0 ? nm_platform_link_get_name (ifindex) : NULL;
+		char *buf2;
+
+		strcpy (buf, " dev ");
+		buf2 = buf + 5;
+		size -= 5;
+
+		if (name)
+			g_strlcpy (buf2, name, size);
+		else
+			g_snprintf (buf2, size, "%d", ifindex);
+	} else
+		buf[0] = 0;
+
+	return buf;
 }
 
 /******************************************************************/
@@ -1482,28 +1570,41 @@ nm_platform_ip6_address_add (int ifindex,
 }
 
 gboolean
-nm_platform_ip4_address_delete (int ifindex, in_addr_t address, int plen)
+nm_platform_ip4_address_delete (int ifindex, in_addr_t address, int plen, in_addr_t peer_address)
 {
+	char str_dev[TO_STRING_DEV_BUF_SIZE];
+	char str_peer[NM_UTILS_INET_ADDRSTRLEN];
+
 	reset_error ();
 
 	g_return_val_if_fail (ifindex > 0, FALSE);
 	g_return_val_if_fail (plen > 0, FALSE);
 	g_return_val_if_fail (klass->ip4_address_delete, FALSE);
 
-	debug ("address: deleting IPv4 address %s/%d", nm_utils_inet4_ntop (address, NULL), plen);
-	return klass->ip4_address_delete (platform, ifindex, address, plen);
+	debug ("address: deleting IPv4 address %s/%d, %s%s%sifindex %d%s",
+	       nm_utils_inet4_ntop (address, NULL), plen,
+	       peer_address ? "peer " : "",
+	       peer_address ? nm_utils_inet4_ntop (peer_address, str_peer) : "",
+	       peer_address ? ", " : "",
+	       ifindex,
+	       _to_string_dev (ifindex, str_dev, sizeof (str_dev)));
+	return klass->ip4_address_delete (platform, ifindex, address, plen, peer_address);
 }
 
 gboolean
 nm_platform_ip6_address_delete (int ifindex, struct in6_addr address, int plen)
 {
+	char str_dev[TO_STRING_DEV_BUF_SIZE];
+
 	reset_error ();
 
 	g_return_val_if_fail (ifindex > 0, FALSE);
 	g_return_val_if_fail (plen > 0, FALSE);
 	g_return_val_if_fail (klass->ip6_address_delete, FALSE);
 
-	debug ("address: deleting IPv6 address %s/%d", nm_utils_inet6_ntop (&address, NULL), plen);
+	debug ("address: deleting IPv6 address %s/%d, ifindex %d%s",
+	       nm_utils_inet6_ntop (&address, NULL), plen, ifindex,
+	       _to_string_dev (ifindex, str_dev, sizeof (str_dev)));
 	return klass->ip6_address_delete (platform, ifindex, address, plen);
 }
 
@@ -1600,11 +1701,16 @@ _rebase_relative_time_on_now (guint32 timestamp, guint32 duration, guint32 now,
 static gboolean
 _address_get_lifetime (const NMPlatformIPAddress *address, guint32 now, guint32 padding, guint32 *out_lifetime, guint32 *out_preferred)
 {
-	gint32 lifetime, preferred;
+	guint32 lifetime, preferred;
 
 	if (address->lifetime == 0) {
 		*out_lifetime = NM_PLATFORM_LIFETIME_PERMANENT;
 		*out_preferred = NM_PLATFORM_LIFETIME_PERMANENT;
+
+		/* We treat lifetime==0 as permanent addresses to allow easy creation of such addresses
+		 * (without requiring to set the lifetime fields to NM_PLATFORM_LIFETIME_PERMANENT).
+		 * In that case we also expect that the other fields (timestamp and preferred) are left unset. */
+		g_return_val_if_fail (address->timestamp == 0 && address->preferred == 0, TRUE);
 	} else {
 		lifetime = _rebase_relative_time_on_now (address->timestamp, address->lifetime, now, padding);
 		if (!lifetime)
@@ -1626,10 +1732,31 @@ _address_get_lifetime (const NMPlatformIPAddress *address, guint32 now, guint32
 	return TRUE;
 }
 
+gboolean
+nm_platform_ip4_check_reinstall_device_route (int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric)
+{
+	g_return_val_if_fail (address, FALSE);
+
+	if (   ifindex <= 0
+	    || address->plen <= 0
+	    || address->plen >= 32)
+		return FALSE;
+
+	if (device_route_metric == NM_PLATFORM_ROUTE_METRIC_IP4_DEVICE_ROUTE) {
+		/* The automatically added route would be already our desired priority.
+		 * Nothing to do. */
+		return FALSE;
+	}
+
+	return klass->ip4_check_reinstall_device_route (platform, ifindex, address, device_route_metric);
+}
+
 /**
  * nm_platform_ip4_address_sync:
  * @ifindex: Interface index
  * @known_addresses: List of addresses
+ * @device_route_metric: the route metric for adding subnet routes (replaces
+ *   the kernel added routes).
  *
  * A convenience function to synchronize addresses for a specific interface
  * with the least possible disturbance. It simply removes addresses that are
@@ -1638,7 +1765,7 @@ _address_get_lifetime (const NMPlatformIPAddress *address, guint32 now, guint32
  * Returns: %TRUE on success.
  */
 gboolean
-nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses)
+nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses, guint32 device_route_metric)
 {
 	GArray *addresses;
 	NMPlatformIP4Address *address;
@@ -1651,7 +1778,7 @@ nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses)
 		address = &g_array_index (addresses, NMPlatformIP4Address, i);
 
 		if (!array_contains_ip4_address (known_addresses, address))
-			nm_platform_ip4_address_delete (ifindex, address->address, address->plen);
+			nm_platform_ip4_address_delete (ifindex, address->address, address->plen, address->peer_address);
 	}
 	g_array_free (addresses, TRUE);
 
@@ -1662,13 +1789,34 @@ nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses)
 	for (i = 0; i < known_addresses->len; i++) {
 		const NMPlatformIP4Address *known_address = &g_array_index (known_addresses, NMPlatformIP4Address, i);
 		guint32 lifetime, preferred;
+		guint32 network;
+		gboolean reinstall_device_route = FALSE;
 
 		/* add a padding of 5 seconds to avoid potential races. */
 		if (!_address_get_lifetime ((NMPlatformIPAddress *) known_address, now, 5, &lifetime, &preferred))
 			continue;
 
+		if (nm_platform_ip4_check_reinstall_device_route (ifindex, known_address, device_route_metric))
+			reinstall_device_route = TRUE;
+
 		if (!nm_platform_ip4_address_add (ifindex, known_address->address, known_address->peer_address, known_address->plen, lifetime, preferred, known_address->label))
 			return FALSE;
+
+		if (reinstall_device_route) {
+			/* Kernel automatically adds a device route for us with metric 0. That is not what we want.
+			 * Remove it, and re-add it.
+			 *
+			 * In face of having the same subnets on two different interfaces with the same metric,
+			 * this is a problem. Surprisingly, kernel is able to add two routes for the same subnet/prefix,metric
+			 * to different interfaces. We cannot. Adding one, would replace the other. This is avoided
+			 * by the above nm_platform_ip4_check_reinstall_device_route() check.
+			 */
+			network = nm_utils_ip4_address_clear_host_address (known_address->address, known_address->plen);
+			(void) nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_KERNEL, network, known_address->plen,
+			                                  0, known_address->address, device_route_metric, 0);
+			(void) nm_platform_ip4_route_delete (ifindex, network, known_address->plen,
+			                                     NM_PLATFORM_ROUTE_METRIC_IP4_DEVICE_ROUTE);
+		}
 	}
 
 	return TRUE;
@@ -1731,49 +1879,49 @@ nm_platform_ip6_address_sync (int ifindex, const GArray *known_addresses)
 gboolean
 nm_platform_address_flush (int ifindex)
 {
-	return nm_platform_ip4_address_sync (ifindex, NULL)
+	return nm_platform_ip4_address_sync (ifindex, NULL, 0)
 			&& nm_platform_ip6_address_sync (ifindex, NULL);
 }
 
 /******************************************************************/
 
 GArray *
-nm_platform_ip4_route_get_all (int ifindex, gboolean include_default)
+nm_platform_ip4_route_get_all (int ifindex, NMPlatformGetRouteMode mode)
 {
 	reset_error ();
 
-	g_return_val_if_fail (ifindex > 0, NULL);
+	g_return_val_if_fail (ifindex >= 0, NULL);
 	g_return_val_if_fail (klass->ip4_route_get_all, NULL);
 
-	return klass->ip4_route_get_all (platform, ifindex, include_default);
+	return klass->ip4_route_get_all (platform, ifindex, mode);
 }
 
 GArray *
-nm_platform_ip6_route_get_all (int ifindex, gboolean include_default)
+nm_platform_ip6_route_get_all (int ifindex, NMPlatformGetRouteMode mode)
 {
 	reset_error ();
 
-	g_return_val_if_fail (ifindex > 0, NULL);
+	g_return_val_if_fail (ifindex >= 0, NULL);
 	g_return_val_if_fail (klass->ip6_route_get_all, NULL);
 
-	return klass->ip6_route_get_all (platform, ifindex, include_default);
+	return klass->ip6_route_get_all (platform, ifindex, mode);
 }
 
 gboolean
-nm_platform_ip4_route_add (int ifindex, NMPlatformSource source,
+nm_platform_ip4_route_add (int ifindex, NMIPConfigSource source,
                            in_addr_t network, int plen,
-                           in_addr_t gateway, int metric, int mss)
+                           in_addr_t gateway, guint32 pref_src,
+                           guint32 metric, guint32 mss)
 {
 	reset_error ();
 
 	g_return_val_if_fail (platform, FALSE);
 	g_return_val_if_fail (0 <= plen && plen <= 32, FALSE);
-	g_return_val_if_fail (metric >= 0, FALSE);
-	g_return_val_if_fail (mss >= 0, FALSE);
 	g_return_val_if_fail (klass->ip4_route_add, FALSE);
 
 	if (nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM)) {
 		NMPlatformIP4Route route = { 0 };
+		char pref_src_buf[NM_UTILS_INET_ADDRSTRLEN];
 
 		route.ifindex = ifindex;
 		route.source = source;
@@ -1783,20 +1931,21 @@ nm_platform_ip4_route_add (int ifindex, NMPlatformSource source,
 		route.metric = metric;
 		route.mss = mss;
 
-		debug ("route: adding or updating IPv4 route: %s", nm_platform_ip4_route_to_string (&route));
+		debug ("route: adding or updating IPv4 route: %s%s%s%s", nm_platform_ip4_route_to_string (&route),
+		       pref_src ? " (src: " : "",
+		       pref_src ? nm_utils_inet4_ntop (pref_src, pref_src_buf) : "",
+		       pref_src ? ")" : "");
 	}
-	return klass->ip4_route_add (platform, ifindex, source, network, plen, gateway, metric, mss);
+	return klass->ip4_route_add (platform, ifindex, source, network, plen, gateway, pref_src, metric, mss);
 }
 
 gboolean
-nm_platform_ip6_route_add (int ifindex, NMPlatformSource source,
+nm_platform_ip6_route_add (int ifindex, NMIPConfigSource source,
                            struct in6_addr network, int plen, struct in6_addr gateway,
-                           int metric, int mss)
+                           guint32 metric, guint32 mss)
 {
 	g_return_val_if_fail (platform, FALSE);
 	g_return_val_if_fail (0 <= plen && plen <= 128, FALSE);
-	g_return_val_if_fail (metric >= 0, FALSE);
-	g_return_val_if_fail (mss >= 0, FALSE);
 	g_return_val_if_fail (klass->ip6_route_add, FALSE);
 
 	if (nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM)) {
@@ -1816,31 +1965,39 @@ nm_platform_ip6_route_add (int ifindex, NMPlatformSource source,
 }
 
 gboolean
-nm_platform_ip4_route_delete (int ifindex, in_addr_t network, int plen, int metric)
+nm_platform_ip4_route_delete (int ifindex, in_addr_t network, int plen, guint32 metric)
 {
+	char str_dev[TO_STRING_DEV_BUF_SIZE];
+
 	reset_error ();
 
 	g_return_val_if_fail (platform, FALSE);
 	g_return_val_if_fail (klass->ip4_route_delete, FALSE);
 
-	debug ("route: deleting IPv4 route %s/%d, metric=%d", nm_utils_inet4_ntop (network, NULL), plen, metric);
+	debug ("route: deleting IPv4 route %s/%d, metric=%"G_GUINT32_FORMAT", ifindex %d%s",
+	       nm_utils_inet4_ntop (network, NULL), plen, metric, ifindex,
+	       _to_string_dev (ifindex, str_dev, sizeof (str_dev)));
 	return klass->ip4_route_delete (platform, ifindex, network, plen, metric);
 }
 
 gboolean
-nm_platform_ip6_route_delete (int ifindex, struct in6_addr network, int plen, int metric)
+nm_platform_ip6_route_delete (int ifindex, struct in6_addr network, int plen, guint32 metric)
 {
+	char str_dev[TO_STRING_DEV_BUF_SIZE];
+
 	reset_error ();
 
 	g_return_val_if_fail (platform, FALSE);
 	g_return_val_if_fail (klass->ip6_route_delete, FALSE);
 
-	debug ("route: deleting IPv6 route %s/%d, metric=%d", nm_utils_inet6_ntop (&network, NULL), plen, metric);
+	debug ("route: deleting IPv6 route %s/%d, metric=%"G_GUINT32_FORMAT", ifindex %d%s",
+	       nm_utils_inet6_ntop (&network, NULL), plen, metric, ifindex,
+	       _to_string_dev (ifindex, str_dev, sizeof (str_dev)));
 	return klass->ip6_route_delete (platform, ifindex, network, plen, metric);
 }
 
 gboolean
-nm_platform_ip4_route_exists (int ifindex, in_addr_t network, int plen, int metric)
+nm_platform_ip4_route_exists (int ifindex, in_addr_t network, int plen, guint32 metric)
 {
 	reset_error ();
 
@@ -1851,7 +2008,7 @@ nm_platform_ip4_route_exists (int ifindex, in_addr_t network, int plen, int metr
 }
 
 gboolean
-nm_platform_ip6_route_exists (int ifindex, struct in6_addr network, int plen, int metric)
+nm_platform_ip6_route_exists (int ifindex, struct in6_addr network, int plen, guint32 metric)
 {
 	reset_error ();
 
@@ -1907,6 +2064,8 @@ array_contains_ip6_route (const GArray *routes, const NMPlatformIP6Route *route)
  * A convenience function to synchronize routes for a specific interface
  * with the least possible disturbance. It simply removes routes that are
  * not listed and adds routes that are.
+ * Default routes are ignored (both in @known_routes and those already
+ * configured on the device).
  *
  * Returns: %TRUE on success.
  */
@@ -1920,12 +2079,12 @@ nm_platform_ip4_route_sync (int ifindex, const GArray *known_routes)
 	int i, i_type;
 
 	/* Delete unknown routes */
-	routes = nm_platform_ip4_route_get_all (ifindex, FALSE);
+	routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
 	for (i = 0; i < routes->len; i++) {
 		route = &g_array_index (routes, NMPlatformIP4Route, i);
 
 		if (!array_contains_ip4_route (known_routes, route))
-			nm_platform_ip4_route_delete (ifindex, route->network, route->plen, route->metric);
+			(void) nm_platform_ip4_route_delete (ifindex, route->network, route->plen, route->metric);
 	}
 
 	if (!known_routes) {
@@ -1938,6 +2097,9 @@ nm_platform_ip4_route_sync (int ifindex, const GArray *known_routes)
 		for (i = 0; i < known_routes->len && success; i++) {
 			known_route = &g_array_index (known_routes, NMPlatformIP4Route, i);
 
+			if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (known_route))
+				continue;
+
 			if ((known_route->gateway == 0) ^ (i_type != 0)) {
 				/* Make two runs over the list of routes. On the first, only add
 				 * device routes, on the second the others (gateway routes). */
@@ -1951,9 +2113,10 @@ nm_platform_ip4_route_sync (int ifindex, const GArray *known_routes)
 				                                     known_route->network,
 				                                     known_route->plen,
 				                                     known_route->gateway,
+				                                     0,
 				                                     known_route->metric,
 				                                     known_route->mss);
-				if (!success && known_route->source < NM_PLATFORM_SOURCE_USER) {
+				if (!success && known_route->source < NM_IP_CONFIG_SOURCE_USER) {
 					nm_log_dbg (LOGD_PLATFORM, "ignore error adding IPv4 route to kernel: %s",
 					                           nm_platform_ip4_route_to_string (known_route));
 					success = TRUE;
@@ -1974,6 +2137,8 @@ nm_platform_ip4_route_sync (int ifindex, const GArray *known_routes)
  * A convenience function to synchronize routes for a specific interface
  * with the least possible disturbance. It simply removes routes that are
  * not listed and adds routes that are.
+ * Default routes are ignored (both in @known_routes and those already
+ * configured on the device).
  *
  * Returns: %TRUE on success.
  */
@@ -1987,7 +2152,7 @@ nm_platform_ip6_route_sync (int ifindex, const GArray *known_routes)
 	int i, i_type;
 
 	/* Delete unknown routes */
-	routes = nm_platform_ip6_route_get_all (ifindex, FALSE);
+	routes = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
 	for (i = 0; i < routes->len; i++) {
 		route = &g_array_index (routes, NMPlatformIP6Route, i);
 		route->ifindex = 0;
@@ -2006,6 +2171,9 @@ nm_platform_ip6_route_sync (int ifindex, const GArray *known_routes)
 		for (i = 0; i < known_routes->len && success; i++) {
 			known_route = &g_array_index (known_routes, NMPlatformIP6Route, i);
 
+			if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (known_route))
+				continue;
+
 			if (IN6_IS_ADDR_UNSPECIFIED (&known_route->gateway) ^ (i_type != 0)) {
 				/* Make two runs over the list of routes. On the first, only add
 				 * device routes, on the second the others (gateway routes). */
@@ -2021,7 +2189,7 @@ nm_platform_ip6_route_sync (int ifindex, const GArray *known_routes)
 				                                     known_route->gateway,
 				                                     known_route->metric,
 				                                     known_route->mss);
-				if (!success && known_route->source < NM_PLATFORM_SOURCE_USER) {
+				if (!success && known_route->source < NM_IP_CONFIG_SOURCE_USER) {
 					nm_log_dbg (LOGD_PLATFORM, "ignore error adding IPv6 route to kernel: %s",
 					                           nm_platform_ip6_route_to_string (known_route));
 					success = TRUE;
@@ -2044,26 +2212,26 @@ nm_platform_route_flush (int ifindex)
 /******************************************************************/
 
 static const char *
-source_to_string (NMPlatformSource source)
+source_to_string (NMIPConfigSource source)
 {
 	switch (source) {
-	case NM_PLATFORM_SOURCE_KERNEL:
+	case NM_IP_CONFIG_SOURCE_KERNEL:
 		return "kernel";
-	case NM_PLATFORM_SOURCE_SHARED:
+	case NM_IP_CONFIG_SOURCE_SHARED:
 		return "shared";
-	case NM_PLATFORM_SOURCE_IP4LL:
+	case NM_IP_CONFIG_SOURCE_IP4LL:
 		return "ipv4ll";
-	case NM_PLATFORM_SOURCE_PPP:
+	case NM_IP_CONFIG_SOURCE_PPP:
 		return "ppp";
-	case NM_PLATFORM_SOURCE_WWAN:
+	case NM_IP_CONFIG_SOURCE_WWAN:
 		return "wwan";
-	case NM_PLATFORM_SOURCE_VPN:
+	case NM_IP_CONFIG_SOURCE_VPN:
 		return "vpn";
-	case NM_PLATFORM_SOURCE_DHCP:
+	case NM_IP_CONFIG_SOURCE_DHCP:
 		return "dhcp";
-	case NM_PLATFORM_SOURCE_RDISC:
+	case NM_IP_CONFIG_SOURCE_RDISC:
 		return "rdisc";
-	case NM_PLATFORM_SOURCE_USER:
+	case NM_IP_CONFIG_SOURCE_USER:
 		return "user";
 	default:
 		break;
@@ -2071,27 +2239,6 @@ source_to_string (NMPlatformSource source)
 	return "unknown";
 }
 
-#define TO_STRING_DEV_BUF_SIZE (5+15+1)
-static void
-_to_string_dev (int ifindex, char *buf, size_t size)
-{
-	g_assert (buf && size >= TO_STRING_DEV_BUF_SIZE);
-
-	if (ifindex){
-		const char *name = ifindex > 0 ? nm_platform_link_get_name (ifindex) : NULL;
-
-		strcpy (buf, " dev ");
-		buf += 5;
-		size -= 5;
-
-		if (name)
-			g_strlcpy (buf, name, size);
-		else
-			g_snprintf (buf, size, "%d", ifindex);
-	} else
-		buf[0] = 0;
-}
-
 static const char *
 _lifetime_to_string (guint32 timestamp, guint32 lifetime, gint32 now, char *buf, size_t buf_size)
 {
@@ -2330,7 +2477,7 @@ nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route)
 
 	_to_string_dev (route->ifindex, str_dev, sizeof (str_dev));
 
-	g_snprintf (to_string_buffer, sizeof (to_string_buffer), "%s/%d via %s%s metric %u mss %u src %s",
+	g_snprintf (to_string_buffer, sizeof (to_string_buffer), "%s/%d via %s%s metric %"G_GUINT32_FORMAT" mss %"G_GUINT32_FORMAT" src %s",
 	            s_network, route->plen, s_gateway,
 	            str_dev,
 	            route->metric, route->mss,
@@ -2363,7 +2510,7 @@ nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route)
 
 	_to_string_dev (route->ifindex, str_dev, sizeof (str_dev));
 
-	g_snprintf (to_string_buffer, sizeof (to_string_buffer), "%s/%d via %s%s metric %u mss %u src %s",
+	g_snprintf (to_string_buffer, sizeof (to_string_buffer), "%s/%d via %s%s metric %"G_GUINT32_FORMAT" mss %"G_GUINT32_FORMAT" src %s",
 	            s_network, route->plen, s_gateway,
 	            str_dev,
 	            route->metric, route->mss,