Blame SOURCES/1006-dhcp-client-id-fixes-3-rh1640494.patch

f86c11
From 083e415a4908e2cdf7a9bf627d0aa637a7f2b04f Mon Sep 17 00:00:00 2001
f86c11
From: Thomas Haller <thaller@redhat.com>
f86c11
Date: Thu, 27 Sep 2018 15:39:29 +0200
f86c11
Subject: [PATCH 1/7] all/trivial: rename hexstr<>bin conversion functions
f86c11
f86c11
"bin2str" and "str2bin" are not very clear. These strings are
f86c11
hex-strings. Rename.
f86c11
f86c11
(cherry picked from commit 6714440669d27a59a6e0bcadd642c28f0c9d5737)
f86c11
(cherry picked from commit cc93cf46adb8957ff21eb295c7680954ee1aabc2)
f86c11
---
f86c11
 libnm-core/nm-core-internal.h                 | 18 +++++------
f86c11
 libnm-core/nm-utils.c                         | 32 +++++++++----------
f86c11
 src/devices/nm-device.c                       | 12 +++----
f86c11
 src/dhcp/nm-dhcp-utils.c                      |  2 +-
f86c11
 .../plugins/ifcfg-rh/nms-ifcfg-rh-reader.c    |  2 +-
f86c11
 5 files changed, 33 insertions(+), 33 deletions(-)
f86c11
f86c11
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
f86c11
index cd2a77a71..be95ba0e1 100644
f86c11
--- a/libnm-core/nm-core-internal.h
f86c11
+++ b/libnm-core/nm-core-internal.h
f86c11
@@ -212,15 +212,15 @@ guint nm_setting_ethtool_init_features (NMSettingEthtool *setting,
f86c11
 guint8 *_nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize buffer_length, gsize *out_length);
f86c11
 const char *nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_case, char *buf, gsize buf_len);
f86c11
 
f86c11
-char *_nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case);
f86c11
-void _nm_utils_bin2str_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
f86c11
-
f86c11
-guint8 *_nm_utils_str2bin_full (const char *asc,
f86c11
-                                gboolean delimiter_required,
f86c11
-                                const char *delimiter_candidates,
f86c11
-                                guint8 *buffer,
f86c11
-                                gsize buffer_length,
f86c11
-                                gsize *out_len);
f86c11
+char *_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case);
f86c11
+void _nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
f86c11
+
f86c11
+guint8 *_nm_utils_hexstr2bin_full (const char *asc,
f86c11
+                                   gboolean delimiter_required,
f86c11
+                                   const char *delimiter_candidates,
f86c11
+                                   guint8 *buffer,
f86c11
+                                   gsize buffer_length,
f86c11
+                                   gsize *out_len);
f86c11
 
f86c11
 GSList *    _nm_utils_hash_values_to_slist (GHashTable *hash);
f86c11
 
f86c11
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
f86c11
index d4cbde1df..962cf8b8f 100644
f86c11
--- a/libnm-core/nm-utils.c
f86c11
+++ b/libnm-core/nm-utils.c
f86c11
@@ -3613,12 +3613,12 @@ nm_utils_hwaddr_len (int type)
f86c11
 }
f86c11
 
f86c11
 guint8 *
f86c11
-_nm_utils_str2bin_full (const char *asc,
f86c11
-                        gboolean delimiter_required,
f86c11
-                        const char *delimiter_candidates,
f86c11
-                        guint8 *buffer,
f86c11
-                        gsize buffer_length,
f86c11
-                        gsize *out_len)
f86c11
+_nm_utils_hexstr2bin_full (const char *asc,
f86c11
+                           gboolean delimiter_required,
f86c11
+                           const char *delimiter_candidates,
f86c11
+                           guint8 *buffer,
f86c11
+                           gsize buffer_length,
f86c11
+                           gsize *out_len)
f86c11
 {
f86c11
 	const char *in = asc;
f86c11
 	guint8 *out = buffer;
f86c11
@@ -3688,7 +3688,7 @@ _nm_utils_str2bin_full (const char *asc,
f86c11
 	return buffer;
f86c11
 }
f86c11
 
f86c11
-#define hwaddr_aton(asc, buffer, buffer_length, out_len) _nm_utils_str2bin_full ((asc), TRUE, ":-", (buffer), (buffer_length), (out_len))
f86c11
+#define hwaddr_aton(asc, buffer, buffer_length, out_len) _nm_utils_hexstr2bin_full ((asc), TRUE, ":-", (buffer), (buffer_length), (out_len))
f86c11
 
f86c11
 /**
f86c11
  * nm_utils_hexstr2bin:
f86c11
@@ -3714,7 +3714,7 @@ nm_utils_hexstr2bin (const char *hex)
f86c11
 
f86c11
 	buffer_length = strlen (hex) / 2 + 3;
f86c11
 	buffer = g_malloc (buffer_length);
f86c11
-	if (!_nm_utils_str2bin_full (hex, FALSE, ":", buffer, buffer_length, &len)) {
f86c11
+	if (!_nm_utils_hexstr2bin_full (hex, FALSE, ":", buffer, buffer_length, &len)) {
f86c11
 		g_free (buffer);
f86c11
 		return NULL;
f86c11
 	}
f86c11
@@ -3815,7 +3815,7 @@ nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize length)
f86c11
 }
f86c11
 
f86c11
 void
f86c11
-_nm_utils_bin2str_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out)
f86c11
+_nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out)
f86c11
 {
f86c11
 	const guint8 *in = addr;
f86c11
 	const char *LOOKUP = upper_case ? "0123456789ABCDEF" : "0123456789abcdef";
f86c11
@@ -3865,7 +3865,7 @@ nm_utils_bin2hexstr (gconstpointer src, gsize len, int final_len)
f86c11
 	g_return_val_if_fail (final_len < 0 || (gsize) final_len < buflen, NULL);
f86c11
 
f86c11
 	result = g_malloc (buflen);
f86c11
-	_nm_utils_bin2str_full (src, len, '\0', FALSE, result);
f86c11
+	_nm_utils_bin2hexstr_full (src, len, '\0', FALSE, result);
f86c11
 
f86c11
 	/* Cut converted key off at the correct length for this cipher type */
f86c11
 	if (final_len >= 0 && (gsize) final_len < buflen)
f86c11
@@ -3892,7 +3892,7 @@ nm_utils_hwaddr_ntoa (gconstpointer addr, gsize length)
f86c11
 	g_return_val_if_fail (length > 0, g_strdup (""));
f86c11
 
f86c11
 	result = g_malloc (length * 3);
f86c11
-	_nm_utils_bin2str_full (addr, length, ':', TRUE, result);
f86c11
+	_nm_utils_bin2hexstr_full (addr, length, ':', TRUE, result);
f86c11
 	return result;
f86c11
 }
f86c11
 
f86c11
@@ -3905,12 +3905,12 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas
f86c11
 	if (buf_len < addr_len * 3)
f86c11
 		g_return_val_if_reached (NULL);
f86c11
 
f86c11
-	_nm_utils_bin2str_full (addr, addr_len, ':', upper_case, buf);
f86c11
+	_nm_utils_bin2hexstr_full (addr, addr_len, ':', upper_case, buf);
f86c11
 	return buf;
f86c11
 }
f86c11
 
f86c11
 /**
f86c11
- * _nm_utils_bin2str:
f86c11
+ * _nm_utils_bin2hexstr:
f86c11
  * @addr: (type guint8) (array length=length): a binary hardware address
f86c11
  * @length: the length of @addr
f86c11
  * @upper_case: the case for the hexadecimal digits.
f86c11
@@ -3920,7 +3920,7 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas
f86c11
  * Return value: (transfer full): the textual form of @addr
f86c11
  */
f86c11
 char *
f86c11
-_nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case)
f86c11
+_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case)
f86c11
 {
f86c11
 	char *result;
f86c11
 
f86c11
@@ -3928,7 +3928,7 @@ _nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case)
f86c11
 	g_return_val_if_fail (length > 0, g_strdup (""));
f86c11
 
f86c11
 	result = g_malloc (length * 3);
f86c11
-	_nm_utils_bin2str_full (addr, length, ':', upper_case, result);
f86c11
+	_nm_utils_bin2hexstr_full (addr, length, ':', upper_case, result);
f86c11
 	return result;
f86c11
 }
f86c11
 
f86c11
@@ -4596,7 +4596,7 @@ _nm_utils_dhcp_duid_valid (const char *duid, GBytes **out_duid_bin)
f86c11
 		return TRUE;
f86c11
 	}
f86c11
 
f86c11
-	if (_nm_utils_str2bin_full (duid, FALSE, ":", duid_arr, sizeof (duid_arr), &duid_len)) {
f86c11
+	if (_nm_utils_hexstr2bin_full (duid, FALSE, ":", duid_arr, sizeof (duid_arr), &duid_len)) {
f86c11
 		/* MAX DUID length is 128 octects + the type code (2 octects). */
f86c11
 		if (   duid_len > 2
f86c11
 		    && duid_len <= (128 + 2)) {
f86c11
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
f86c11
index 51751ecf3..2de575cff 100644
f86c11
--- a/src/devices/nm-device.c
f86c11
+++ b/src/devices/nm-device.c
f86c11
@@ -14349,9 +14349,9 @@ nm_device_spawn_iface_helper (NMDevice *self)
f86c11
 			if (client_id) {
f86c11
 				g_ptr_array_add (argv, g_strdup ("--dhcp4-clientid"));
f86c11
 				g_ptr_array_add (argv,
f86c11
-				                 _nm_utils_bin2str (g_bytes_get_data (client_id, NULL),
f86c11
-				                                    g_bytes_get_size (client_id),
f86c11
-				                                    FALSE));
f86c11
+				                 _nm_utils_bin2hexstr (g_bytes_get_data (client_id, NULL),
f86c11
+				                                       g_bytes_get_size (client_id),
f86c11
+				                                       FALSE));
f86c11
 			}
f86c11
 
f86c11
 			hostname = nm_dhcp_client_get_hostname (priv->dhcp4.client);
f86c11
@@ -14389,9 +14389,9 @@ nm_device_spawn_iface_helper (NMDevice *self)
f86c11
 		if (nm_device_get_ip_iface_identifier (self, &iid, FALSE)) {
f86c11
 			g_ptr_array_add (argv, g_strdup ("--iid"));
f86c11
 			g_ptr_array_add (argv,
f86c11
-			                 _nm_utils_bin2str (iid.id_u8,
f86c11
-			                                    sizeof (NMUtilsIPv6IfaceId),
f86c11
-			                                    FALSE));
f86c11
+			                 _nm_utils_bin2hexstr (iid.id_u8,
f86c11
+			                                       sizeof (NMUtilsIPv6IfaceId),
f86c11
+			                                       FALSE));
f86c11
 		}
f86c11
 
f86c11
 		g_ptr_array_add (argv, g_strdup ("--addr-gen-mode"));
f86c11
diff --git a/src/dhcp/nm-dhcp-utils.c b/src/dhcp/nm-dhcp-utils.c
f86c11
index 6bbc670b2..f6d97b5ff 100644
f86c11
--- a/src/dhcp/nm-dhcp-utils.c
f86c11
+++ b/src/dhcp/nm-dhcp-utils.c
f86c11
@@ -729,7 +729,7 @@ nm_dhcp_utils_duid_to_string (GBytes *duid)
f86c11
 	g_return_val_if_fail (duid != NULL, NULL);
f86c11
 
f86c11
 	data = g_bytes_get_data (duid, &len;;
f86c11
-	return _nm_utils_bin2str (data, len, FALSE);
f86c11
+	return _nm_utils_bin2hexstr (data, len, FALSE);
f86c11
 }
f86c11
 
f86c11
 /**
f86c11
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
f86c11
index 09a379914..f8c4d18d4 100644
f86c11
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
f86c11
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
f86c11
@@ -189,7 +189,7 @@ _secret_password_raw_to_bytes (const char *ifcfg_key,
f86c11
 		password_raw += 2;
f86c11
 
f86c11
 	secret = nm_secret_buf_new (strlen (password_raw) / 2 + 3);
f86c11
-	if (!_nm_utils_str2bin_full (password_raw, FALSE, ":", secret->bin, secret->len, &len)) {
f86c11
+	if (!_nm_utils_hexstr2bin_full (password_raw, FALSE, ":", secret->bin, secret->len, &len)) {
f86c11
 		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
f86c11
 		             "Invalid hex password in %s",
f86c11
 		             ifcfg_key);
f86c11
-- 
f86c11
2.19.1
f86c11
f86c11
f86c11
From 3305ae13a18b39b3cde94ee80e882a48610b677e Mon Sep 17 00:00:00 2001
f86c11
From: Thomas Haller <thaller@redhat.com>
f86c11
Date: Thu, 27 Sep 2018 15:47:35 +0200
f86c11
Subject: [PATCH 2/7] libnm: return output buffer from
f86c11
 _nm_utils_bin2hexstr_full()
f86c11
f86c11
It's just more convenient, as it allows better chaining.
f86c11
f86c11
Also, allow passing %NULL as @out buffer. It's clear how
f86c11
large the output buffer must be, so for convenience let the
f86c11
function (optionally) allocate a new buffer.
f86c11
f86c11
This behavior of whether to
f86c11
  - take @out, fill it, and return @out
f86c11
  - take no @out, allocate new buffer, fill and and return it
f86c11
is slightly error prone. But it was already error prone before, when
f86c11
it would accept an input buffer without explicit buffer length. I think
f86c11
this makes it more safe, because in the common case the caller can avoid
f86c11
pre-allocating a buffer of the right size and the function gets it
f86c11
right.
f86c11
f86c11
(cherry picked from commit 21df8d38effc8d9a36d7f2ac5fb674ddbf848a25)
f86c11
(cherry picked from commit f4973558dc7036b54b23c69ae57123ef26ba8d0c)
f86c11
---
f86c11
 libnm-core/nm-core-internal.h |  2 +-
f86c11
 libnm-core/nm-utils.c         | 53 +++++++++++++++++++++++++----------
f86c11
 2 files changed, 39 insertions(+), 16 deletions(-)
f86c11
f86c11
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
f86c11
index be95ba0e1..c3be9acef 100644
f86c11
--- a/libnm-core/nm-core-internal.h
f86c11
+++ b/libnm-core/nm-core-internal.h
f86c11
@@ -213,7 +213,7 @@ guint8 *_nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize buffer_le
f86c11
 const char *nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_case, char *buf, gsize buf_len);
f86c11
 
f86c11
 char *_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case);
f86c11
-void _nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
f86c11
+char *_nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
f86c11
 
f86c11
 guint8 *_nm_utils_hexstr2bin_full (const char *asc,
f86c11
                                    gboolean delimiter_required,
f86c11
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
f86c11
index 962cf8b8f..ef0fd4084 100644
f86c11
--- a/libnm-core/nm-utils.c
f86c11
+++ b/libnm-core/nm-utils.c
f86c11
@@ -3814,16 +3814,46 @@ nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize length)
f86c11
 	return buffer;
f86c11
 }
f86c11
 
f86c11
-void
f86c11
-_nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out)
f86c11
+/**
f86c11
+ * _nm_utils_bin2hexstr_full:
f86c11
+ * @addr: pointer of @length bytes.
f86c11
+ * @length: number of bytes in @addr
f86c11
+ * @delimiter: either '\0', otherwise the output string will have the
f86c11
+ *   given delimiter character between each two hex numbers.
f86c11
+ * @upper_case: if TRUE, use upper case ASCII characters for hex.
f86c11
+ * @out: if %NULL, the function will allocate a new buffer of
f86c11
+ *   either (@length*2+1) or (@length*3) bytes, depending on whether
f86c11
+ *   a @delimiter is specified. In that case, the allocated buffer will
f86c11
+ *   be returned and must be freed by the caller.
f86c11
+ *   If not %NULL, the buffer must already be preallocated and contain
f86c11
+ *   at least (@length*2+1) or (@length*3) bytes, depending on the delimiter.
f86c11
+ *
f86c11
+ * Returns: the binary value converted to a hex string. If @out is given,
f86c11
+ *   this always returns @out. If @out is %NULL, a newly allocated string
f86c11
+ *   is returned.
f86c11
+ */
f86c11
+char *
f86c11
+_nm_utils_bin2hexstr_full (gconstpointer addr,
f86c11
+                           gsize length,
f86c11
+                           char delimiter,
f86c11
+                           gboolean upper_case,
f86c11
+                           char *out)
f86c11
 {
f86c11
 	const guint8 *in = addr;
f86c11
 	const char *LOOKUP = upper_case ? "0123456789ABCDEF" : "0123456789abcdef";
f86c11
+	char *out0;
f86c11
 
f86c11
 	nm_assert (addr);
f86c11
-	nm_assert (out);
f86c11
 	nm_assert (length > 0);
f86c11
 
f86c11
+	if (out)
f86c11
+		out0 = out;
f86c11
+	else {
f86c11
+		out0 = out = g_new (char, delimiter == '\0'
f86c11
+		                          ? length * 2 + 1
f86c11
+		                          : length * 3);
f86c11
+	}
f86c11
+
f86c11
 	/* @out must contain at least @length*3 bytes if @delimiter is set,
f86c11
 	 * otherwise, @length*2+1. */
f86c11
 
f86c11
@@ -3840,6 +3870,7 @@ _nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimite
f86c11
 	}
f86c11
 
f86c11
 	*out = 0;
f86c11
+	return out0;
f86c11
 }
f86c11
 
f86c11
 /**
f86c11
@@ -3865,6 +3896,7 @@ nm_utils_bin2hexstr (gconstpointer src, gsize len, int final_len)
f86c11
 	g_return_val_if_fail (final_len < 0 || (gsize) final_len < buflen, NULL);
f86c11
 
f86c11
 	result = g_malloc (buflen);
f86c11
+
f86c11
 	_nm_utils_bin2hexstr_full (src, len, '\0', FALSE, result);
f86c11
 
f86c11
 	/* Cut converted key off at the correct length for this cipher type */
f86c11
@@ -3886,14 +3918,10 @@ nm_utils_bin2hexstr (gconstpointer src, gsize len, int final_len)
f86c11
 char *
f86c11
 nm_utils_hwaddr_ntoa (gconstpointer addr, gsize length)
f86c11
 {
f86c11
-	char *result;
f86c11
-
f86c11
 	g_return_val_if_fail (addr, g_strdup (""));
f86c11
 	g_return_val_if_fail (length > 0, g_strdup (""));
f86c11
 
f86c11
-	result = g_malloc (length * 3);
f86c11
-	_nm_utils_bin2hexstr_full (addr, length, ':', TRUE, result);
f86c11
-	return result;
f86c11
+	return _nm_utils_bin2hexstr_full (addr, length, ':', TRUE, NULL);
f86c11
 }
f86c11
 
f86c11
 const char *
f86c11
@@ -3905,8 +3933,7 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas
f86c11
 	if (buf_len < addr_len * 3)
f86c11
 		g_return_val_if_reached (NULL);
f86c11
 
f86c11
-	_nm_utils_bin2hexstr_full (addr, addr_len, ':', upper_case, buf);
f86c11
-	return buf;
f86c11
+	return _nm_utils_bin2hexstr_full (addr, addr_len, ':', upper_case, buf);
f86c11
 }
f86c11
 
f86c11
 /**
f86c11
@@ -3922,14 +3949,10 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas
f86c11
 char *
f86c11
 _nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case)
f86c11
 {
f86c11
-	char *result;
f86c11
-
f86c11
 	g_return_val_if_fail (addr, g_strdup (""));
f86c11
 	g_return_val_if_fail (length > 0, g_strdup (""));
f86c11
 
f86c11
-	result = g_malloc (length * 3);
f86c11
-	_nm_utils_bin2hexstr_full (addr, length, ':', upper_case, result);
f86c11
-	return result;
f86c11
+	return _nm_utils_bin2hexstr_full (addr, length, ':', upper_case, NULL);
f86c11
 }
f86c11
 
f86c11
 /**
f86c11
-- 
f86c11
2.19.1
f86c11
f86c11
f86c11
From 10792c768f1074f4803cba9840d2662793d69c38 Mon Sep 17 00:00:00 2001
f86c11
From: Thomas Haller <thaller@redhat.com>
f86c11
Date: Thu, 27 Sep 2018 16:05:29 +0200
f86c11
Subject: [PATCH 3/7] all: drop _nm_utils_bin2hexstr()
f86c11
f86c11
We already have nm_utils_bin2hexstr() and _nm_utils_bin2hexstr_full().
f86c11
This is confusing.
f86c11
f86c11
  - nm_utils_bin2hexstr() is public API of libnm. Also, it has
f86c11
    a last argument @final_len to truncate the string at that
f86c11
    length.
f86c11
    It uses no delimiter and lower-case characters.
f86c11
f86c11
  - _nm_utils_bin2hexstr_full() does not do any truncation, but
f86c11
    it has options to specify a delimiter, the character case,
f86c11
    and to update a given buffer in-place. Also, like
f86c11
    nm_utils_bin2hexstr() and _nm_utils_bin2hexstr() it can
f86c11
    allocate a new buffer on demand.
f86c11
f86c11
  - _nm_utils_bin2hexstr() would use ':' as delimiter and make
f86c11
    the case configurable. Also, it would always allocate the returned
f86c11
    buffer.
f86c11
f86c11
It's too much and confusing. Drop _nm_utils_bin2hexstr() which is internal
f86c11
API and just a wrapper around _nm_utils_bin2hexstr_full().
f86c11
f86c11
(cherry picked from commit b537c0388a0ca7320d01c9ba2c6b5b4fe45f267f)
f86c11
(cherry picked from commit 2a8bef4454d6b1e8aeded8bbd2122538a5da41a4)
f86c11
---
f86c11
 libnm-core/nm-core-internal.h |  1 -
f86c11
 libnm-core/nm-utils.c         | 19 -------------------
f86c11
 src/devices/nm-device.c       | 16 ++++++++++------
f86c11
 src/dhcp/nm-dhcp-utils.c      |  4 ++--
f86c11
 4 files changed, 12 insertions(+), 28 deletions(-)
f86c11
f86c11
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
f86c11
index c3be9acef..9edd332d5 100644
f86c11
--- a/libnm-core/nm-core-internal.h
f86c11
+++ b/libnm-core/nm-core-internal.h
f86c11
@@ -212,7 +212,6 @@ guint nm_setting_ethtool_init_features (NMSettingEthtool *setting,
f86c11
 guint8 *_nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize buffer_length, gsize *out_length);
f86c11
 const char *nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_case, char *buf, gsize buf_len);
f86c11
 
f86c11
-char *_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case);
f86c11
 char *_nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
f86c11
 
f86c11
 guint8 *_nm_utils_hexstr2bin_full (const char *asc,
f86c11
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
f86c11
index ef0fd4084..457189698 100644
f86c11
--- a/libnm-core/nm-utils.c
f86c11
+++ b/libnm-core/nm-utils.c
f86c11
@@ -3936,25 +3936,6 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas
f86c11
 	return _nm_utils_bin2hexstr_full (addr, addr_len, ':', upper_case, buf);
f86c11
 }
f86c11
 
f86c11
-/**
f86c11
- * _nm_utils_bin2hexstr:
f86c11
- * @addr: (type guint8) (array length=length): a binary hardware address
f86c11
- * @length: the length of @addr
f86c11
- * @upper_case: the case for the hexadecimal digits.
f86c11
- *
f86c11
- * Converts @addr to textual form.
f86c11
- *
f86c11
- * Return value: (transfer full): the textual form of @addr
f86c11
- */
f86c11
-char *
f86c11
-_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case)
f86c11
-{
f86c11
-	g_return_val_if_fail (addr, g_strdup (""));
f86c11
-	g_return_val_if_fail (length > 0, g_strdup (""));
f86c11
-
f86c11
-	return _nm_utils_bin2hexstr_full (addr, length, ':', upper_case, NULL);
f86c11
-}
f86c11
-
f86c11
 /**
f86c11
  * nm_utils_hwaddr_valid:
f86c11
  * @asc: the ASCII representation of a hardware address
f86c11
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
f86c11
index 2de575cff..c6d591db8 100644
f86c11
--- a/src/devices/nm-device.c
f86c11
+++ b/src/devices/nm-device.c
f86c11
@@ -14349,9 +14349,11 @@ nm_device_spawn_iface_helper (NMDevice *self)
f86c11
 			if (client_id) {
f86c11
 				g_ptr_array_add (argv, g_strdup ("--dhcp4-clientid"));
f86c11
 				g_ptr_array_add (argv,
f86c11
-				                 _nm_utils_bin2hexstr (g_bytes_get_data (client_id, NULL),
f86c11
-				                                       g_bytes_get_size (client_id),
f86c11
-				                                       FALSE));
f86c11
+				                 _nm_utils_bin2hexstr_full (g_bytes_get_data (client_id, NULL),
f86c11
+				                                            g_bytes_get_size (client_id),
f86c11
+				                                            ':',
f86c11
+				                                            FALSE,
f86c11
+				                                            NULL));
f86c11
 			}
f86c11
 
f86c11
 			hostname = nm_dhcp_client_get_hostname (priv->dhcp4.client);
f86c11
@@ -14389,9 +14391,11 @@ nm_device_spawn_iface_helper (NMDevice *self)
f86c11
 		if (nm_device_get_ip_iface_identifier (self, &iid, FALSE)) {
f86c11
 			g_ptr_array_add (argv, g_strdup ("--iid"));
f86c11
 			g_ptr_array_add (argv,
f86c11
-			                 _nm_utils_bin2hexstr (iid.id_u8,
f86c11
-			                                       sizeof (NMUtilsIPv6IfaceId),
f86c11
-			                                       FALSE));
f86c11
+			                 _nm_utils_bin2hexstr_full (iid.id_u8,
f86c11
+			                                            sizeof (NMUtilsIPv6IfaceId),
f86c11
+			                                            ':',
f86c11
+			                                            FALSE,
f86c11
+			                                            NULL));
f86c11
 		}
f86c11
 
f86c11
 		g_ptr_array_add (argv, g_strdup ("--addr-gen-mode"));
f86c11
diff --git a/src/dhcp/nm-dhcp-utils.c b/src/dhcp/nm-dhcp-utils.c
f86c11
index f6d97b5ff..9b1653b8f 100644
f86c11
--- a/src/dhcp/nm-dhcp-utils.c
f86c11
+++ b/src/dhcp/nm-dhcp-utils.c
f86c11
@@ -726,10 +726,10 @@ nm_dhcp_utils_duid_to_string (GBytes *duid)
f86c11
 	gconstpointer data;
f86c11
 	gsize len;
f86c11
 
f86c11
-	g_return_val_if_fail (duid != NULL, NULL);
f86c11
+	g_return_val_if_fail (duid, NULL);
f86c11
 
f86c11
 	data = g_bytes_get_data (duid, &len;;
f86c11
-	return _nm_utils_bin2hexstr (data, len, FALSE);
f86c11
+	return _nm_utils_bin2hexstr_full (data, len, ':', FALSE, NULL);
f86c11
 }
f86c11
 
f86c11
 /**
f86c11
-- 
f86c11
2.19.1
f86c11
f86c11
f86c11
From 7135449107363ab356db4d4e2afc45bab4952978 Mon Sep 17 00:00:00 2001
f86c11
From: Thomas Haller <thaller@redhat.com>
f86c11
Date: Thu, 27 Sep 2018 16:29:55 +0200
f86c11
Subject: [PATCH 4/7] libnm: cleanup _nm_utils_hexstr2bin*() helper
f86c11
f86c11
Add 3 variants of _nm_utils_hexstr2bin*():
f86c11
f86c11
  - _nm_utils_hexstr2bin_full(), which takes a preallocated
f86c11
    buffer and fills it.
f86c11
  - _nm_utils_hexstr2bin_alloc() which returns a malloc'ed
f86c11
    buffer
f86c11
  - _nm_utils_hexstr2bin_buf(), which fills a preallocated
f86c11
    buffer of a specific size.
f86c11
f86c11
(cherry picked from commit be6c7fa5f66c0fa155d703996a5a858c88b8230c)
f86c11
(cherry picked from commit 5dc8a14576d2ea9732518586027df6b0c3c8784f)
f86c11
---
f86c11
 libnm-core/nm-core-internal.h                 |  16 ++-
f86c11
 libnm-core/nm-utils.c                         | 123 +++++++++++++-----
f86c11
 .../plugins/ifcfg-rh/nms-ifcfg-rh-reader.c    |   2 +-
f86c11
 3 files changed, 105 insertions(+), 36 deletions(-)
f86c11
f86c11
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
f86c11
index 9edd332d5..761461084 100644
f86c11
--- a/libnm-core/nm-core-internal.h
f86c11
+++ b/libnm-core/nm-core-internal.h
f86c11
@@ -214,13 +214,25 @@ const char *nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboole
f86c11
 
f86c11
 char *_nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
f86c11
 
f86c11
-guint8 *_nm_utils_hexstr2bin_full (const char *asc,
f86c11
+guint8 *_nm_utils_hexstr2bin_full (const char *hexstr,
f86c11
+                                   gboolean allow_0x_prefix,
f86c11
                                    gboolean delimiter_required,
f86c11
                                    const char *delimiter_candidates,
f86c11
+                                   gsize required_len,
f86c11
                                    guint8 *buffer,
f86c11
-                                   gsize buffer_length,
f86c11
+                                   gsize buffer_len,
f86c11
                                    gsize *out_len);
f86c11
 
f86c11
+#define _nm_utils_hexstr2bin_buf(hexstr, allow_0x_prefix, delimiter_required, delimiter_candidates, buffer) \
f86c11
+    _nm_utils_hexstr2bin_full ((hexstr), (allow_0x_prefix), (delimiter_required), (delimiter_candidates), G_N_ELEMENTS (buffer), (buffer), G_N_ELEMENTS (buffer), NULL)
f86c11
+
f86c11
+guint8 *_nm_utils_hexstr2bin_alloc (const char *hexstr,
f86c11
+                                    gboolean allow_0x_prefix,
f86c11
+                                    gboolean delimiter_required,
f86c11
+                                    const char *delimiter_candidates,
f86c11
+                                    gsize required_len,
f86c11
+                                    gsize *out_len);
f86c11
+
f86c11
 GSList *    _nm_utils_hash_values_to_slist (GHashTable *hash);
f86c11
 
f86c11
 GHashTable *_nm_utils_copy_strdict (GHashTable *strdict);
f86c11
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
f86c11
index 457189698..59b7f0432 100644
f86c11
--- a/libnm-core/nm-utils.c
f86c11
+++ b/libnm-core/nm-utils.c
f86c11
@@ -3613,60 +3613,68 @@ nm_utils_hwaddr_len (int type)
f86c11
 }
f86c11
 
f86c11
 guint8 *
f86c11
-_nm_utils_hexstr2bin_full (const char *asc,
f86c11
+_nm_utils_hexstr2bin_full (const char *hexstr,
f86c11
+                           gboolean allow_0x_prefix,
f86c11
                            gboolean delimiter_required,
f86c11
                            const char *delimiter_candidates,
f86c11
+                           gsize required_len,
f86c11
                            guint8 *buffer,
f86c11
-                           gsize buffer_length,
f86c11
+                           gsize buffer_len,
f86c11
                            gsize *out_len)
f86c11
 {
f86c11
-	const char *in = asc;
f86c11
+	const char *in = hexstr;
f86c11
 	guint8 *out = buffer;
f86c11
 	gboolean delimiter_has = TRUE;
f86c11
 	guint8 delimiter = '\0';
f86c11
+	gsize len;
f86c11
 
f86c11
-	nm_assert (asc);
f86c11
+	nm_assert (hexstr);
f86c11
 	nm_assert (buffer);
f86c11
-	nm_assert (buffer_length);
f86c11
-	nm_assert (out_len);
f86c11
+	nm_assert (required_len > 0 || out_len);
f86c11
+
f86c11
+	if (   allow_0x_prefix
f86c11
+	    && in[0] == '0'
f86c11
+	    && in[1] == 'x')
f86c11
+		in += 2;
f86c11
 
f86c11
 	while (TRUE) {
f86c11
 		const guint8 d1 = in[0];
f86c11
 		guint8 d2;
f86c11
+		int i1, i2;
f86c11
 
f86c11
-		if (!g_ascii_isxdigit (d1))
f86c11
-			return NULL;
f86c11
-
f86c11
-#define HEXVAL(c) ((c) <= '9' ? (c) - '0' : ((c) & 0x4F) - ('A' - 10))
f86c11
+		i1 = nm_utils_hexchar_to_int (d1);
f86c11
+		if (i1 < 0)
f86c11
+			goto fail;
f86c11
 
f86c11
 		/* If there's no leading zero (ie "aa:b:cc") then fake it */
f86c11
 		d2 = in[1];
f86c11
-		if (d2 && g_ascii_isxdigit (d2)) {
f86c11
-			*out++ = (HEXVAL (d1) << 4) + HEXVAL (d2);
f86c11
+		if (   d2
f86c11
+		    && (i2 = nm_utils_hexchar_to_int (d2)) >= 0) {
f86c11
+			*out++ = (i1 << 4) + i2;
f86c11
 			d2 = in[2];
f86c11
 			if (!d2)
f86c11
 				break;
f86c11
 			in += 2;
f86c11
 		} else {
f86c11
 			/* Fake leading zero */
f86c11
-			*out++ = HEXVAL (d1);
f86c11
+			*out++ = i1;
f86c11
 			if (!d2) {
f86c11
 				if (!delimiter_has) {
f86c11
 					/* when using no delimiter, there must be pairs of hex chars */
f86c11
-					return NULL;
f86c11
+					goto fail;
f86c11
 				}
f86c11
 				break;
f86c11
 			}
f86c11
 			in += 1;
f86c11
 		}
f86c11
 
f86c11
-		if (--buffer_length == 0)
f86c11
-			return NULL;
f86c11
+		if (--buffer_len == 0)
f86c11
+			goto fail;
f86c11
 
f86c11
 		if (delimiter_has) {
f86c11
 			if (d2 != delimiter) {
f86c11
 				if (delimiter)
f86c11
-					return NULL;
f86c11
+					goto fail;
f86c11
 				if (delimiter_candidates) {
f86c11
 					while (delimiter_candidates[0]) {
f86c11
 						if (delimiter_candidates++[0] == d2)
f86c11
@@ -3675,7 +3683,7 @@ _nm_utils_hexstr2bin_full (const char *asc,
f86c11
 				}
f86c11
 				if (!delimiter) {
f86c11
 					if (delimiter_required)
f86c11
-						return NULL;
f86c11
+						goto fail;
f86c11
 					delimiter_has = FALSE;
f86c11
 					continue;
f86c11
 				}
f86c11
@@ -3684,11 +3692,66 @@ _nm_utils_hexstr2bin_full (const char *asc,
f86c11
 		}
f86c11
 	}
f86c11
 
f86c11
-	*out_len = out - buffer;
f86c11
-	return buffer;
f86c11
+	len = out - buffer;
f86c11
+	if (   required_len == 0
f86c11
+	    || len == required_len) {
f86c11
+		NM_SET_OUT (out_len, len);
f86c11
+		return buffer;
f86c11
+	}
f86c11
+
f86c11
+fail:
f86c11
+	NM_SET_OUT (out_len, 0);
f86c11
+	return NULL;
f86c11
 }
f86c11
 
f86c11
-#define hwaddr_aton(asc, buffer, buffer_length, out_len) _nm_utils_hexstr2bin_full ((asc), TRUE, ":-", (buffer), (buffer_length), (out_len))
f86c11
+guint8 *
f86c11
+_nm_utils_hexstr2bin_alloc (const char *hexstr,
f86c11
+                            gboolean allow_0x_prefix,
f86c11
+                            gboolean delimiter_required,
f86c11
+                            const char *delimiter_candidates,
f86c11
+                            gsize required_len,
f86c11
+                            gsize *out_len)
f86c11
+{
f86c11
+	guint8 *buffer;
f86c11
+	gsize buffer_len, len;
f86c11
+
f86c11
+	g_return_val_if_fail (hexstr, NULL);
f86c11
+
f86c11
+	nm_assert (required_len > 0 || out_len);
f86c11
+
f86c11
+	if (   allow_0x_prefix
f86c11
+	    && hexstr[0] == '0'
f86c11
+	    && hexstr[1] == 'x')
f86c11
+		hexstr += 2;
f86c11
+
f86c11
+	if (!hexstr[0])
f86c11
+		goto fail;
f86c11
+
f86c11
+	if (required_len > 0)
f86c11
+		buffer_len = required_len;
f86c11
+	else
f86c11
+		buffer_len = strlen (hexstr) / 2 + 3;
f86c11
+
f86c11
+	buffer = g_malloc (buffer_len);
f86c11
+
f86c11
+	if (_nm_utils_hexstr2bin_full (hexstr,
f86c11
+	                               FALSE,
f86c11
+	                               delimiter_required,
f86c11
+	                               delimiter_candidates,
f86c11
+	                               required_len,
f86c11
+	                               buffer,
f86c11
+	                               buffer_len,
f86c11
+	                               &len)) {
f86c11
+		NM_SET_OUT (out_len, len);
f86c11
+		return buffer;
f86c11
+	}
f86c11
+
f86c11
+	g_free (buffer);
f86c11
+
f86c11
+fail:
f86c11
+	NM_SET_OUT (out_len, 0);
f86c11
+	return NULL;
f86c11
+}
f86c11
 
f86c11
 /**
f86c11
  * nm_utils_hexstr2bin:
f86c11
@@ -3705,23 +3768,17 @@ GBytes *
f86c11
 nm_utils_hexstr2bin (const char *hex)
f86c11
 {
f86c11
 	guint8 *buffer;
f86c11
-	gsize buffer_length, len;
f86c11
-
f86c11
-	g_return_val_if_fail (hex != NULL, NULL);
f86c11
-
f86c11
-	if (hex[0] == '0' && hex[1] == 'x')
f86c11
-		hex += 2;
f86c11
+	gsize len;
f86c11
 
f86c11
-	buffer_length = strlen (hex) / 2 + 3;
f86c11
-	buffer = g_malloc (buffer_length);
f86c11
-	if (!_nm_utils_hexstr2bin_full (hex, FALSE, ":", buffer, buffer_length, &len)) {
f86c11
-		g_free (buffer);
f86c11
+	buffer = _nm_utils_hexstr2bin_alloc (hex, TRUE, FALSE, ":", 0, &len;;
f86c11
+	if (!buffer)
f86c11
 		return NULL;
f86c11
-	}
f86c11
 	buffer = g_realloc (buffer, len);
f86c11
 	return g_bytes_new_take (buffer, len);
f86c11
 }
f86c11
 
f86c11
+#define hwaddr_aton(asc, buffer, buffer_len, out_len) _nm_utils_hexstr2bin_full ((asc), FALSE, TRUE, ":-", 0, (buffer), (buffer_len), (out_len))
f86c11
+
f86c11
 /**
f86c11
  * nm_utils_hwaddr_atoba:
f86c11
  * @asc: the ASCII representation of a hardware address
f86c11
@@ -4600,7 +4657,7 @@ _nm_utils_dhcp_duid_valid (const char *duid, GBytes **out_duid_bin)
f86c11
 		return TRUE;
f86c11
 	}
f86c11
 
f86c11
-	if (_nm_utils_hexstr2bin_full (duid, FALSE, ":", duid_arr, sizeof (duid_arr), &duid_len)) {
f86c11
+	if (_nm_utils_hexstr2bin_full (duid, FALSE, FALSE, ":", 0, duid_arr, sizeof (duid_arr), &duid_len)) {
f86c11
 		/* MAX DUID length is 128 octects + the type code (2 octects). */
f86c11
 		if (   duid_len > 2
f86c11
 		    && duid_len <= (128 + 2)) {
f86c11
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
f86c11
index f8c4d18d4..70fffb888 100644
f86c11
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
f86c11
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
f86c11
@@ -189,7 +189,7 @@ _secret_password_raw_to_bytes (const char *ifcfg_key,
f86c11
 		password_raw += 2;
f86c11
 
f86c11
 	secret = nm_secret_buf_new (strlen (password_raw) / 2 + 3);
f86c11
-	if (!_nm_utils_hexstr2bin_full (password_raw, FALSE, ":", secret->bin, secret->len, &len)) {
f86c11
+	if (!_nm_utils_hexstr2bin_full (password_raw, FALSE, FALSE, ":", 0, secret->bin, secret->len, &len)) {
f86c11
 		g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
f86c11
 		             "Invalid hex password in %s",
f86c11
 		             ifcfg_key);
f86c11
-- 
f86c11
2.19.1
f86c11
f86c11
f86c11
From 944ce0bf973a47007cc0b79f8d6636985f1156fb Mon Sep 17 00:00:00 2001
f86c11
From: Thomas Haller <thaller@redhat.com>
f86c11
Date: Thu, 18 Oct 2018 08:17:52 +0200
f86c11
Subject: [PATCH 5/7] dhcp: log client-id of DHCP instance
f86c11
f86c11
(cherry picked from commit 2af1dc1d287334dcd02d8282fcfdbe3a8e031363)
f86c11
(cherry picked from commit 16bde2d1eca80ddaade01e35b0c6fc34bc937fe2)
f86c11
---
f86c11
 src/dhcp/nm-dhcp-client.c | 9 +++++++++
f86c11
 1 file changed, 9 insertions(+)
f86c11
f86c11
diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c
f86c11
index 16db83068..143d26184 100644
f86c11
--- a/src/dhcp/nm-dhcp-client.c
f86c11
+++ b/src/dhcp/nm-dhcp-client.c
f86c11
@@ -230,6 +230,15 @@ _set_client_id (NMDhcpClient *self, GBytes *client_id, gboolean take)
f86c11
 	priv->client_id = client_id;
f86c11
 	if (!take && client_id)
f86c11
 		g_bytes_ref (client_id);
f86c11
+
f86c11
+	{
f86c11
+		gs_free char *s = NULL;
f86c11
+
f86c11
+		_LOGT ("client-id: %s",
f86c11
+		       priv->client_id
f86c11
+		         ? (s = nm_dhcp_utils_duid_to_string (priv->client_id))
f86c11
+		         : "default");
f86c11
+	}
f86c11
 }
f86c11
 
f86c11
 void
f86c11
-- 
f86c11
2.19.1
f86c11
f86c11
f86c11
From 6724db6016f558e23772c5c92d7ea1be6c080219 Mon Sep 17 00:00:00 2001
f86c11
From: Thomas Haller <thaller@redhat.com>
f86c11
Date: Wed, 3 Oct 2018 21:50:27 +0200
f86c11
Subject: [PATCH 6/7] core: add "nm-sd-utils.h" to access system internal
f86c11
 helper
f86c11
f86c11
We have a fork of a lot of useful systemd helper code.
f86c11
However, until now we shyed away from using it aside from
f86c11
the bits that we really need.
f86c11
f86c11
That means, although we have some really nice implementations
f86c11
in our source-tree, we didn't use them. Either we were missing
f86c11
them, or we had to re-implement them.
f86c11
f86c11
Add "nm-sd-utils.h" header to very carefully make internal
f86c11
systemd API accessible to the rest of core.
f86c11
f86c11
This is not intended as a vehicle to access all of internal
f86c11
API. Instead, this must be used with care, and only a hand picked
f86c11
selection of functions must be exposed. Use with caution, but where it
f86c11
makes sense.
f86c11
f86c11
(cherry picked from commit eece5aff0992c9076a9b5513e2a893e37e4999ea)
f86c11
(cherry picked from commit 7494145649aa81155bcfc71fc84a923fdec605e3)
f86c11
---
f86c11
 Makefile.am                       |  2 ++
f86c11
 src/systemd/meson.build           |  3 +-
f86c11
 src/systemd/nm-sd-utils.c         | 45 ++++++++++++++++++++++++++++++
f86c11
 src/systemd/nm-sd-utils.h         | 33 ++++++++++++++++++++++
f86c11
 src/systemd/src/basic/path-util.c |  2 --
f86c11
 src/tests/test-systemd.c          | 46 +++++++++++++++++++++++++++++++
f86c11
 6 files changed, 128 insertions(+), 3 deletions(-)
f86c11
 create mode 100644 src/systemd/nm-sd-utils.c
f86c11
 create mode 100644 src/systemd/nm-sd-utils.h
f86c11
f86c11
diff --git a/Makefile.am b/Makefile.am
f86c11
index 5b0feefa4..24b460bd0 100644
f86c11
--- a/Makefile.am
f86c11
+++ b/Makefile.am
f86c11
@@ -1390,6 +1390,8 @@ src_libsystemd_nm_la_libadd = \
f86c11
 src_libsystemd_nm_la_SOURCES = \
f86c11
 	src/systemd/nm-sd.c \
f86c11
 	src/systemd/nm-sd.h \
f86c11
+	src/systemd/nm-sd-utils.c \
f86c11
+	src/systemd/nm-sd-utils.h \
f86c11
 	src/systemd/sd-adapt/nm-sd-adapt.c \
f86c11
 	src/systemd/sd-adapt/nm-sd-adapt.h \
f86c11
 	src/systemd/sd-adapt/architecture.h \
f86c11
diff --git a/src/systemd/meson.build b/src/systemd/meson.build
f86c11
index 870721b0d..1bf1ea41d 100644
f86c11
--- a/src/systemd/meson.build
f86c11
+++ b/src/systemd/meson.build
f86c11
@@ -49,7 +49,8 @@ sources = files(
f86c11
   'src/libsystemd/sd-id128/id128-util.c',
f86c11
   'src/libsystemd/sd-id128/sd-id128.c',
f86c11
   'src/shared/dns-domain.c',
f86c11
-  'nm-sd.c'
f86c11
+  'nm-sd.c',
f86c11
+  'nm-sd-utils.c',
f86c11
 )
f86c11
 
f86c11
 incs = [
f86c11
diff --git a/src/systemd/nm-sd-utils.c b/src/systemd/nm-sd-utils.c
f86c11
new file mode 100644
f86c11
index 000000000..914b4b448
f86c11
--- /dev/null
f86c11
+++ b/src/systemd/nm-sd-utils.c
f86c11
@@ -0,0 +1,45 @@
f86c11
+/* This library is free software; you can redistribute it and/or
f86c11
+ * modify it under the terms of the GNU Lesser General Public
f86c11
+ * License as published by the Free Software Foundation; either
f86c11
+ * version 2 of the License, or (at your option) any later version.
f86c11
+ *
f86c11
+ * This library is distributed in the hope that it will be useful,
f86c11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
f86c11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
f86c11
+ * Lesser General Public License for more details.
f86c11
+ *
f86c11
+ * You should have received a copy of the GNU Lesser General Public
f86c11
+ * License along with this library; if not, write to the
f86c11
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
f86c11
+ * Boston, MA 02110-1301 USA.
f86c11
+ *
f86c11
+ * Copyright (C) 2018 Red Hat, Inc.
f86c11
+ */
f86c11
+
f86c11
+#include "nm-default.h"
f86c11
+
f86c11
+#include "nm-sd-utils.h"
f86c11
+
f86c11
+#include "nm-sd-adapt.h"
f86c11
+
f86c11
+#include "path-util.h"
f86c11
+
f86c11
+/*****************************************************************************/
f86c11
+
f86c11
+gboolean
f86c11
+nm_sd_utils_path_equal (const char *a, const char *b)
f86c11
+{
f86c11
+	return path_equal (a, b);
f86c11
+}
f86c11
+
f86c11
+char *
f86c11
+nm_sd_utils_path_simplify (char *path, gboolean kill_dots)
f86c11
+{
f86c11
+	return path_simplify (path, kill_dots);
f86c11
+}
f86c11
+
f86c11
+const char *
f86c11
+nm_sd_utils_path_startswith (const char *path, const char *prefix)
f86c11
+{
f86c11
+	return path_startswith (path, prefix);
f86c11
+}
f86c11
diff --git a/src/systemd/nm-sd-utils.h b/src/systemd/nm-sd-utils.h
f86c11
new file mode 100644
f86c11
index 000000000..8ca920e27
f86c11
--- /dev/null
f86c11
+++ b/src/systemd/nm-sd-utils.h
f86c11
@@ -0,0 +1,33 @@
f86c11
+/* This library is free software; you can redistribute it and/or
f86c11
+ * modify it under the terms of the GNU Lesser General Public
f86c11
+ * License as published by the Free Software Foundation; either
f86c11
+ * version 2 of the License, or (at your option) any later version.
f86c11
+ *
f86c11
+ * This library is distributed in the hope that it will be useful,
f86c11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
f86c11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
f86c11
+ * Lesser General Public License for more details.
f86c11
+ *
f86c11
+ * You should have received a copy of the GNU Lesser General Public
f86c11
+ * License along with this library; if not, write to the
f86c11
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
f86c11
+ * Boston, MA 02110-1301 USA.
f86c11
+ *
f86c11
+ * Copyright (C) 2018 Red Hat, Inc.
f86c11
+ */
f86c11
+
f86c11
+#ifndef __NM_SD_UTILS_H__
f86c11
+#define __NM_SD_UTILS_H__
f86c11
+
f86c11
+/*****************************************************************************/
f86c11
+
f86c11
+gboolean nm_sd_utils_path_equal (const char *a, const char *b);
f86c11
+
f86c11
+char *nm_sd_utils_path_simplify (char *path, gboolean kill_dots);
f86c11
+
f86c11
+const char *nm_sd_utils_path_startswith (const char *path, const char *prefix);
f86c11
+
f86c11
+/*****************************************************************************/
f86c11
+
f86c11
+#endif /* __NM_SD_UTILS_H__ */
f86c11
+
f86c11
diff --git a/src/systemd/src/basic/path-util.c b/src/systemd/src/basic/path-util.c
f86c11
index 5202eae3c..3656a0110 100644
f86c11
--- a/src/systemd/src/basic/path-util.c
f86c11
+++ b/src/systemd/src/basic/path-util.c
f86c11
@@ -380,7 +380,6 @@ char *path_simplify(char *path, bool kill_dots) {
f86c11
         return path;
f86c11
 }
f86c11
 
f86c11
-#if 0 /* NM_IGNORED */
f86c11
 char* path_startswith(const char *path, const char *prefix) {
f86c11
         assert(path);
f86c11
         assert(prefix);
f86c11
@@ -423,7 +422,6 @@ char* path_startswith(const char *path, const char *prefix) {
f86c11
                 prefix += b;
f86c11
         }
f86c11
 }
f86c11
-#endif /* NM_IGNORED */
f86c11
 
f86c11
 int path_compare(const char *a, const char *b) {
f86c11
         int d;
f86c11
diff --git a/src/tests/test-systemd.c b/src/tests/test-systemd.c
f86c11
index ab5fed22a..4660bd0d1 100644
f86c11
--- a/src/tests/test-systemd.c
f86c11
+++ b/src/tests/test-systemd.c
f86c11
@@ -20,6 +20,7 @@
f86c11
 #include "nm-default.h"
f86c11
 
f86c11
 #include "systemd/nm-sd.h"
f86c11
+#include "systemd/nm-sd-utils.h"
f86c11
 
f86c11
 #include "nm-test-utils-core.h"
f86c11
 
f86c11
@@ -173,6 +174,50 @@ test_sd_event (void)
f86c11
 
f86c11
 /*****************************************************************************/
f86c11
 
f86c11
+static void
f86c11
+test_path_equal (void)
f86c11
+{
f86c11
+#define _path_equal_check1(path, kill_dots, expected) \
f86c11
+	G_STMT_START { \
f86c11
+		const gboolean _kill_dots = (kill_dots); \
f86c11
+		const char *_path0 = (path); \
f86c11
+		const char *_expected = (expected); \
f86c11
+		gs_free char *_path = g_strdup (_path0); \
f86c11
+		const char *_path_result; \
f86c11
+		\
f86c11
+		if (   !_kill_dots \
f86c11
+		    && !nm_sd_utils_path_equal (_path0, _expected)) \
f86c11
+			g_error ("Paths \"%s\" and \"%s\" don't compare equal", _path0, _expected); \
f86c11
+		\
f86c11
+		_path_result = nm_sd_utils_path_simplify (_path, _kill_dots); \
f86c11
+		g_assert (_path_result == _path); \
f86c11
+		g_assert_cmpstr (_path, ==, _expected); \
f86c11
+	} G_STMT_END
f86c11
+
f86c11
+#define _path_equal_check(path, expected_no_kill_dots, expected_kill_dots) \
f86c11
+	G_STMT_START { \
f86c11
+		_path_equal_check1 (path, FALSE, expected_no_kill_dots); \
f86c11
+		_path_equal_check1 (path, TRUE,  expected_kill_dots ?: expected_no_kill_dots); \
f86c11
+	} G_STMT_END
f86c11
+
f86c11
+	_path_equal_check ("",                  "",                NULL);
f86c11
+	_path_equal_check (".",                 ".",               "");
f86c11
+	_path_equal_check ("..",                "..",              NULL);
f86c11
+	_path_equal_check ("/..",               "/..",             NULL);
f86c11
+	_path_equal_check ("//..",              "/..",             NULL);
f86c11
+	_path_equal_check ("/.",                "/.",              "/");
f86c11
+	_path_equal_check ("./",                ".",               "");
f86c11
+	_path_equal_check ("./.",               "./.",             "");
f86c11
+	_path_equal_check (".///.",             "./.",             "");
f86c11
+	_path_equal_check (".///./",            "./.",             "");
f86c11
+	_path_equal_check (".////",             ".",               "");
f86c11
+	_path_equal_check ("//..//foo/",        "/../foo",         NULL);
f86c11
+	_path_equal_check ("///foo//./bar/.",   "/foo/./bar/.",    "/foo/bar");
f86c11
+	_path_equal_check (".//./foo//./bar/.", "././foo/./bar/.", "foo/bar");
f86c11
+}
f86c11
+
f86c11
+/*****************************************************************************/
f86c11
+
f86c11
 NMTST_DEFINE ();
f86c11
 
f86c11
 int
f86c11
@@ -183,6 +228,7 @@ main (int argc, char **argv)
f86c11
 	g_test_add_func ("/systemd/dhcp/create", test_dhcp_create);
f86c11
 	g_test_add_func ("/systemd/lldp/create", test_lldp_create);
f86c11
 	g_test_add_func ("/systemd/sd-event", test_sd_event);
f86c11
+	g_test_add_func ("/systemd/test_path_equal", test_path_equal);
f86c11
 
f86c11
 	return g_test_run ();
f86c11
 }
f86c11
-- 
f86c11
2.19.1
f86c11
f86c11
f86c11
From af9de51249ee7a750248f43bed38e0344e8bee9f Mon Sep 17 00:00:00 2001
f86c11
From: Thomas Haller <thaller@redhat.com>
f86c11
Date: Mon, 12 Nov 2018 15:23:36 +0100
f86c11
Subject: [PATCH 7/7] build: avoid header conflict for <linux/if.h> and
f86c11
 <net/if.h> with "nm-platform.h"
f86c11
f86c11
In the past, the headers "linux/if.h" and "net/if.h" were incompatible.
f86c11
That means, we can either include one or the other, but not both.
f86c11
This is fixed in the meantime, however the issue still exists when
f86c11
building against older kernel/glibc.
f86c11
f86c11
That means, including one of these headers from a header file
f86c11
is problematic. In particular if it's a header like "nm-platform.h",
f86c11
which itself is dragged in by many other headers.
f86c11
f86c11
Avoid that by not including these headers from "platform.h", but instead
f86c11
from the source files where needed (or possibly from less popular header
f86c11
files).
f86c11
f86c11
Currently there is no problem. However, this allows an unknowing user to
f86c11
include <net/if.h> at the same time with "nm-platform.h", which is easy
f86c11
to get wrong.
f86c11
f86c11
(cherry picked from commit 37e47fbdabd6439c022a5fc3b72176aa6c4e569f)
f86c11
(cherry picked from commit aa7acb0ae3046d142a5469b50a9464bc9e6543ac)
f86c11
---
f86c11
 src/devices/nm-device-infiniband.c        |  1 +
f86c11
 src/devices/nm-device-ip-tunnel.c         |  1 +
f86c11
 src/devices/nm-device-macvlan.c           |  1 +
f86c11
 src/devices/nm-device-wpan.c              |  1 +
f86c11
 src/dhcp/nm-dhcp-dhclient-utils.c         |  1 +
f86c11
 src/ndisc/nm-ndisc.h                      |  1 +
f86c11
 src/nm-test-utils-core.h                  |  4 ++--
f86c11
 src/platform/nm-fake-platform.c           |  1 +
f86c11
 src/platform/nm-platform-utils.c          |  1 +
f86c11
 src/platform/nm-platform.c                |  1 +
f86c11
 src/platform/nm-platform.h                | 20 ++++++++++----------
f86c11
 src/platform/nmp-object.c                 |  1 +
f86c11
 src/platform/tests/test-common.h          |  3 +++
f86c11
 src/platform/wifi/nm-wifi-utils-nl80211.c |  1 +
f86c11
 src/platform/wpan/nm-wpan-utils.c         |  2 ++
f86c11
 src/tests/test-ip6-config.c               |  1 +
f86c11
 16 files changed, 29 insertions(+), 12 deletions(-)
f86c11
f86c11
diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c
f86c11
index 41fac157d..5138b6846 100644
f86c11
--- a/src/devices/nm-device-infiniband.c
f86c11
+++ b/src/devices/nm-device-infiniband.c
f86c11
@@ -22,6 +22,7 @@
f86c11
 
f86c11
 #include "nm-device-infiniband.h"
f86c11
 
f86c11
+#include <linux/if.h>
f86c11
 #include <linux/if_infiniband.h>
f86c11
 
f86c11
 #include "NetworkManagerUtils.h"
f86c11
diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c
f86c11
index 568403c62..1c7e6d51e 100644
f86c11
--- a/src/devices/nm-device-ip-tunnel.c
f86c11
+++ b/src/devices/nm-device-ip-tunnel.c
f86c11
@@ -27,6 +27,7 @@
f86c11
 #include <linux/if.h>
f86c11
 #include <linux/ip.h>
f86c11
 #include <linux/if_tunnel.h>
f86c11
+#include <linux/ip6_tunnel.h>
f86c11
 
f86c11
 #include "nm-device-private.h"
f86c11
 #include "nm-manager.h"
f86c11
diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c
f86c11
index ff386c82e..2b2121545 100644
f86c11
--- a/src/devices/nm-device-macvlan.c
f86c11
+++ b/src/devices/nm-device-macvlan.c
f86c11
@@ -23,6 +23,7 @@
f86c11
 #include "nm-device-macvlan.h"
f86c11
 
f86c11
 #include <string.h>
f86c11
+#include <linux/if_link.h>
f86c11
 
f86c11
 #include "nm-device-private.h"
f86c11
 #include "settings/nm-settings.h"
f86c11
diff --git a/src/devices/nm-device-wpan.c b/src/devices/nm-device-wpan.c
f86c11
index f910b0b89..05b507d58 100644
f86c11
--- a/src/devices/nm-device-wpan.c
f86c11
+++ b/src/devices/nm-device-wpan.c
f86c11
@@ -25,6 +25,7 @@
f86c11
 #include <stdlib.h>
f86c11
 #include <string.h>
f86c11
 #include <sys/types.h>
f86c11
+#include <linux/if.h>
f86c11
 
f86c11
 #include "nm-act-request.h"
f86c11
 #include "nm-device-private.h"
f86c11
diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c
f86c11
index d8f8dd98d..105511974 100644
f86c11
--- a/src/dhcp/nm-dhcp-dhclient-utils.c
f86c11
+++ b/src/dhcp/nm-dhcp-dhclient-utils.c
f86c11
@@ -24,6 +24,7 @@
f86c11
 #include <string.h>
f86c11
 #include <ctype.h>
f86c11
 #include <arpa/inet.h>
f86c11
+#include <net/if.h>
f86c11
 
f86c11
 #include "nm-utils/nm-dedup-multi.h"
f86c11
 
f86c11
diff --git a/src/ndisc/nm-ndisc.h b/src/ndisc/nm-ndisc.h
f86c11
index fdc5615f5..290587546 100644
f86c11
--- a/src/ndisc/nm-ndisc.h
f86c11
+++ b/src/ndisc/nm-ndisc.h
f86c11
@@ -23,6 +23,7 @@
f86c11
 
f86c11
 #include <stdlib.h>
f86c11
 #include <netinet/in.h>
f86c11
+#include <linux/if_addr.h>
f86c11
 
f86c11
 #include "nm-setting-ip6-config.h"
f86c11
 #include "NetworkManagerUtils.h"
f86c11
diff --git a/src/nm-test-utils-core.h b/src/nm-test-utils-core.h
f86c11
index 5e89cb39f..dbfe71ada 100644
f86c11
--- a/src/nm-test-utils-core.h
f86c11
+++ b/src/nm-test-utils-core.h
f86c11
@@ -88,8 +88,8 @@ nmtst_platform_ip4_address_full (const char *address, const char *peer_address,
f86c11
 {
f86c11
 	NMPlatformIP4Address *addr = nmtst_platform_ip4_address (address, peer_address, plen);
f86c11
 
f86c11
-	G_STATIC_ASSERT (IFNAMSIZ == sizeof (addr->label));
f86c11
-	g_assert (!label || strlen (label) < IFNAMSIZ);
f86c11
+	G_STATIC_ASSERT (NMP_IFNAMSIZ == sizeof (addr->label));
f86c11
+	g_assert (!label || strlen (label) < NMP_IFNAMSIZ);
f86c11
 
f86c11
 	addr->ifindex = ifindex;
f86c11
 	addr->addr_source = source;
f86c11
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
f86c11
index 82f9e2fb2..ef69b391b 100644
f86c11
--- a/src/platform/nm-fake-platform.c
f86c11
+++ b/src/platform/nm-fake-platform.c
f86c11
@@ -26,6 +26,7 @@
f86c11
 #include <unistd.h>
f86c11
 #include <netinet/icmp6.h>
f86c11
 #include <netinet/in.h>
f86c11
+#include <linux/if.h>
f86c11
 #include <linux/rtnetlink.h>
f86c11
 
f86c11
 #include "nm-utils.h"
f86c11
diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c
f86c11
index 216b15478..cc43b27fb 100644
f86c11
--- a/src/platform/nm-platform-utils.c
f86c11
+++ b/src/platform/nm-platform-utils.c
f86c11
@@ -29,6 +29,7 @@
f86c11
 #include <linux/ethtool.h>
f86c11
 #include <linux/sockios.h>
f86c11
 #include <linux/mii.h>
f86c11
+#include <linux/if.h>
f86c11
 #include <linux/version.h>
f86c11
 #include <linux/rtnetlink.h>
f86c11
 #include <fcntl.h>
f86c11
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
f86c11
index 7ddcf41ae..52ec4fec6 100644
f86c11
--- a/src/platform/nm-platform.c
f86c11
+++ b/src/platform/nm-platform.c
f86c11
@@ -31,6 +31,7 @@
f86c11
 #include <netdb.h>
f86c11
 #include <string.h>
f86c11
 #include <linux/ip.h>
f86c11
+#include <linux/if.h>
f86c11
 #include <linux/if_tun.h>
f86c11
 #include <linux/if_tunnel.h>
f86c11
 #include <linux/rtnetlink.h>
f86c11
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
f86c11
index 11495aff4..f7a23616b 100644
f86c11
--- a/src/platform/nm-platform.h
f86c11
+++ b/src/platform/nm-platform.h
f86c11
@@ -21,12 +21,6 @@
f86c11
 #ifndef __NETWORKMANAGER_PLATFORM_H__
f86c11
 #define __NETWORKMANAGER_PLATFORM_H__
f86c11
 
f86c11
-#include <netinet/in.h>
f86c11
-#include <linux/if.h>
f86c11
-#include <linux/if_addr.h>
f86c11
-#include <linux/if_link.h>
f86c11
-#include <linux/ip6_tunnel.h>
f86c11
-
f86c11
 #include "nm-dbus-interface.h"
f86c11
 #include "nm-core-types-internal.h"
f86c11
 
f86c11
@@ -53,6 +47,12 @@
f86c11
 
f86c11
 /*****************************************************************************/
f86c11
 
f86c11
+/* IFNAMSIZ is both defined in <linux/if.h> and <net/if.h>. In the past, these
f86c11
+ * headers conflicted, so we cannot simply include either of them in a header-file.*/
f86c11
+#define NMP_IFNAMSIZ 16
f86c11
+
f86c11
+/*****************************************************************************/
f86c11
+
f86c11
 struct udev_device;
f86c11
 
f86c11
 typedef gboolean (*NMPObjectPredicateFunc) (const NMPObject *obj,
f86c11
@@ -208,7 +208,7 @@ typedef enum {
f86c11
 
f86c11
 struct _NMPlatformLink {
f86c11
 	__NMPlatformObject_COMMON;
f86c11
-	char name[IFNAMSIZ];
f86c11
+	char name[NMP_IFNAMSIZ];
f86c11
 	NMLinkType type;
f86c11
 
f86c11
 	/* rtnl_link_get_type(), IFLA_INFO_KIND. */
f86c11
@@ -355,7 +355,7 @@ struct _NMPlatformIP4Address {
f86c11
 	 * */
f86c11
 	in_addr_t peer_address;  /* PTP peer address */
f86c11
 
f86c11
-	char label[IFNAMSIZ];
f86c11
+	char label[NMP_IFNAMSIZ];
f86c11
 };
f86c11
 
f86c11
 /**
f86c11
@@ -1105,12 +1105,12 @@ const char *nm_platform_error_to_string (NMPlatformError error,
f86c11
 	((const char *) NULL), -1, (path)
f86c11
 
f86c11
 #define NMP_SYSCTL_PATHID_NETDIR_unsafe(dirfd, ifname, path) \
f86c11
-	nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//\0") + IFNAMSIZ + strlen (path), \
f86c11
+	nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//\0") + NMP_IFNAMSIZ + strlen (path), \
f86c11
 	                 "net:/sys/class/net/%s/%s", (ifname), (path)), \
f86c11
 	(dirfd), (path)
f86c11
 
f86c11
 #define NMP_SYSCTL_PATHID_NETDIR(dirfd, ifname, path) \
f86c11
-	nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//"path"/\0") + IFNAMSIZ, \
f86c11
+	nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//"path"/\0") + NMP_IFNAMSIZ, \
f86c11
 	                 "net:/sys/class/net/%s/%s", (ifname), path), \
f86c11
 	(dirfd), (""path"")
f86c11
 
f86c11
diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c
f86c11
index fdc27440c..f7fa6cb3c 100644
f86c11
--- a/src/platform/nmp-object.c
f86c11
+++ b/src/platform/nmp-object.c
f86c11
@@ -24,6 +24,7 @@
f86c11
 
f86c11
 #include <unistd.h>
f86c11
 #include <linux/rtnetlink.h>
f86c11
+#include <linux/if.h>
f86c11
 #include <libudev.h>
f86c11
 
f86c11
 #include "nm-utils.h"
f86c11
diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h
f86c11
index 1baadfa11..7e81baeac 100644
f86c11
--- a/src/platform/tests/test-common.h
f86c11
+++ b/src/platform/tests/test-common.h
f86c11
@@ -21,6 +21,9 @@
f86c11
 #include <syslog.h>
f86c11
 #include <string.h>
f86c11
 #include <arpa/inet.h>
f86c11
+#include <linux/if.h>
f86c11
+#include <linux/if_link.h>
f86c11
+#include <linux/ip6_tunnel.h>
f86c11
 
f86c11
 #include "platform/nm-platform.h"
f86c11
 #include "platform/nmp-object.h"
f86c11
diff --git a/src/platform/wifi/nm-wifi-utils-nl80211.c b/src/platform/wifi/nm-wifi-utils-nl80211.c
f86c11
index b3bb2bb6e..39e3f9718 100644
f86c11
--- a/src/platform/wifi/nm-wifi-utils-nl80211.c
f86c11
+++ b/src/platform/wifi/nm-wifi-utils-nl80211.c
f86c11
@@ -30,6 +30,7 @@
f86c11
 #include <net/ethernet.h>
f86c11
 #include <unistd.h>
f86c11
 #include <linux/nl80211.h>
f86c11
+#include <linux/if.h>
f86c11
 
f86c11
 #include "platform/nm-netlink.h"
f86c11
 #include "nm-wifi-utils-private.h"
f86c11
diff --git a/src/platform/wpan/nm-wpan-utils.c b/src/platform/wpan/nm-wpan-utils.c
f86c11
index 0544539ac..882c4eec2 100644
f86c11
--- a/src/platform/wpan/nm-wpan-utils.c
f86c11
+++ b/src/platform/wpan/nm-wpan-utils.c
f86c11
@@ -21,6 +21,8 @@
f86c11
 
f86c11
 #include "nm-wpan-utils.h"
f86c11
 
f86c11
+#include <linux/if.h>
f86c11
+
f86c11
 #include "platform/linux/nl802154.h"
f86c11
 #include "platform/nm-netlink.h"
f86c11
 
f86c11
diff --git a/src/tests/test-ip6-config.c b/src/tests/test-ip6-config.c
f86c11
index a03d89b07..5b2550683 100644
f86c11
--- a/src/tests/test-ip6-config.c
f86c11
+++ b/src/tests/test-ip6-config.c
f86c11
@@ -22,6 +22,7 @@
f86c11
 
f86c11
 #include <string.h>
f86c11
 #include <arpa/inet.h>
f86c11
+#include <linux/if_addr.h>
f86c11
 
f86c11
 #include "nm-ip6-config.h"
f86c11
 
f86c11
-- 
f86c11
2.19.1
f86c11