summary refs log tree commit diff
path: root/src/dhcp-manager
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2016-08-26 02:18:32 +0200
committerMichael Biebl <biebl@debian.org>2016-08-26 02:18:32 +0200
commit7514efc2f38c9ace4557d4e69d68e7d380389030 (patch)
tree7fb00fda86cfcc2ca377f191633a7cfdbfea7ca3 /src/dhcp-manager
parentd6201f5d8daada3d64a0a3e0038e14eebec683ce (diff)
Imported Upstream version 1.4.0 upstream/1.4.0
Diffstat (limited to 'src/dhcp-manager')
-rw-r--r--src/dhcp-manager/Makefile.in14
-rw-r--r--src/dhcp-manager/nm-dhcp-client-logging.h24
-rw-r--r--src/dhcp-manager/nm-dhcp-client.c99
-rw-r--r--src/dhcp-manager/nm-dhcp-client.h2
-rw-r--r--src/dhcp-manager/nm-dhcp-dhclient-utils.c2
-rw-r--r--src/dhcp-manager/nm-dhcp-dhclient-utils.h2
-rw-r--r--src/dhcp-manager/nm-dhcp-dhclient.c6
-rw-r--r--src/dhcp-manager/nm-dhcp-dhclient.h1
-rw-r--r--src/dhcp-manager/nm-dhcp-listener.c10
-rw-r--r--src/dhcp-manager/nm-dhcp-listener.h2
-rw-r--r--src/dhcp-manager/nm-dhcp-manager.c10
-rw-r--r--src/dhcp-manager/nm-dhcp-manager.h2
-rw-r--r--src/dhcp-manager/nm-dhcp-systemd.c28
-rw-r--r--src/dhcp-manager/nm-dhcp-utils.c150
-rw-r--r--src/dhcp-manager/nm-dhcp-utils.h2
-rw-r--r--src/dhcp-manager/tests/Makefile.in14
-rw-r--r--src/dhcp-manager/tests/test-dhcp-dhclient.c2
-rw-r--r--src/dhcp-manager/tests/test-dhcp-utils.c2
18 files changed, 202 insertions, 170 deletions
diff --git a/src/dhcp-manager/Makefile.in b/src/dhcp-manager/Makefile.in
index 063489cb..dcb45183 100644
--- a/src/dhcp-manager/Makefile.in
+++ b/src/dhcp-manager/Makefile.in
@@ -91,8 +91,9 @@ host_triplet = @host@
 libexec_PROGRAMS = nm-dhcp-helper$(EXEEXT)
 subdir = src/dhcp-manager
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \
-	$(top_srcdir)/m4/compiler_warnings.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \
+	$(top_srcdir)/m4/ax_lib_readline.m4 \
+	$(top_srcdir)/m4/compiler_options.m4 \
 	$(top_srcdir)/m4/gettext.m4 \
 	$(top_srcdir)/m4/gnome-code-coverage.m4 \
 	$(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \
@@ -218,6 +219,7 @@ DHCLIENT_PATH = @DHCLIENT_PATH@
 DHCPCD_PATH = @DHCPCD_PATH@
 DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@
 DLLTOOL = @DLLTOOL@
+DL_LIBS = @DL_LIBS@
 DNSMASQ_PATH = @DNSMASQ_PATH@
 DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@
 DSYMUTIL = @DSYMUTIL@
@@ -274,13 +276,14 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
 INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
 INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
 IPTABLES_PATH = @IPTABLES_PATH@
+JANSSON_CFLAGS = @JANSSON_CFLAGS@
+JANSSON_LIBS = @JANSSON_LIBS@
 KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@
 LCOV = @LCOV@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@
 LIBAUDIT_LIBS = @LIBAUDIT_LIBS@
-LIBDL = @LIBDL@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBM = @LIBM@
@@ -292,6 +295,8 @@ LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@
 LIBSOUP_LIBS = @LIBSOUP_LIBS@
+LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@
+LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@
 LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@
 LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@
 LIBTOOL = @LIBTOOL@
@@ -352,6 +357,8 @@ QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
 READLINE_LIBS = @READLINE_LIBS@
+SANITIZERS = @SANITIZERS@
+SANITIZER_ENV = @SANITIZER_ENV@
 SED = @SED@
 SELINUX_CFLAGS = @SELINUX_CFLAGS@
 SELINUX_LIBS = @SELINUX_LIBS@
@@ -387,6 +394,7 @@ ac_ct_AR = @ac_ct_AR@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_RANLIB = @ac_ct_RANLIB@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
diff --git a/src/dhcp-manager/nm-dhcp-client-logging.h b/src/dhcp-manager/nm-dhcp-client-logging.h
index bb4f2f4a..8dd18bf2 100644
--- a/src/dhcp-manager/nm-dhcp-client-logging.h
+++ b/src/dhcp-manager/nm-dhcp-client-logging.h
@@ -21,7 +21,6 @@
 #ifndef __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__
 #define __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__
 
-#include "nm-default.h"
 #include "nm-dhcp-client.h"
 
 #define _NMLOG_PREFIX_NAME    "dhcp"
@@ -52,4 +51,27 @@
         } \
     } G_STMT_END
 
+#define _NMLOG2(level, domain, ifname, ...) \
+    G_STMT_START { \
+        const NMLogLevel _level = (level); \
+        const NMLogDomain _domain = (domain); \
+        \
+        /* we check first for LOGD_DHCP instead of the correct domain.
+         * In the worst case, we guess wrong and enter the block.
+         *
+         * Same for the _NMLOG_ENABLED() macro. Probably it would be more
+         * expensive to determine the correct value then what we could
+         * safe. */ \
+        if (nm_logging_enabled (_level, _domain)) { \
+            const char *__ifname = (ifname); \
+            \
+            nm_log (_level, _domain, \
+                    "%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
+                    _NMLOG_PREFIX_NAME, \
+                    (_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \
+                    NM_PRINT_FMT_QUOTED (__ifname, " (", __ifname, ")", "") \
+                    _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
+        } \
+    } G_STMT_END
+
 #endif /* __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__ */
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c
index c1025817..3be2ea03 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -448,6 +448,7 @@ generate_duid_from_machine_id (void)
 	GRand *generator;
 	guint i;
 	gs_free char *machine_id_s = NULL;
+	gs_free char *str = NULL;
 
 	machine_id_s = nm_utils_machine_id_read ();
 	if (nm_utils_machine_id_parse (machine_id_s, uuid)) {
@@ -457,7 +458,7 @@ generate_duid_from_machine_id (void)
 		g_checksum_get_digest (sum, buffer, &sumlen);
 		g_checksum_free (sum);
 	} else {
-		nm_log_warn (LOGD_DHCP6, "dhcp6: failed to read " SYSCONFDIR "/machine-id "
+		nm_log_warn (LOGD_DHCP, "dhcp: failed to read " SYSCONFDIR "/machine-id "
 		             "or " LOCALSTATEDIR "/lib/dbus/machine-id to generate "
 		             "DHCPv6 DUID; creating non-persistent random DUID.");
 
@@ -481,6 +482,8 @@ generate_duid_from_machine_id (void)
 	 */
 	g_byte_array_append (duid, buffer, 16);
 
+	nm_log_dbg (LOGD_DHCP, "dhcp: generated DUID %s",
+	            (str = nm_dhcp_utils_duid_to_string (duid)));
 	return duid;
 }
 
@@ -489,17 +492,10 @@ get_duid (NMDhcpClient *self)
 {
 	static GByteArray *duid = NULL;
 	GByteArray *copy = NULL;
-	char *str;
 
 	if (G_UNLIKELY (duid == NULL)) {
 		duid = generate_duid_from_machine_id ();
 		g_assert (duid);
-
-		if (nm_logging_enabled (LOGL_DEBUG, LOGD_DHCP6)) {
-			str = nm_dhcp_utils_duid_to_string (duid);
-			_LOGD ("generated DUID %s", str);
-			g_free (str);
-		}
 	}
 
 	if (G_LIKELY (duid)) {
@@ -519,7 +515,7 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
                           NMSettingIP6ConfigPrivacy privacy)
 {
 	NMDhcpClientPrivate *priv;
-	char *str;
+	gs_free char *str = NULL;
 
 	g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE);
 
@@ -534,11 +530,7 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
 	if (!priv->duid)
 		priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self);
 
-	if (nm_logging_enabled (LOGL_DEBUG, LOGD_DHCP6)) {
-		str = nm_dhcp_utils_duid_to_string (priv->duid);
-		_LOGD ("DUID is '%s'", str);
-		g_free (str);
-	}
+	_LOGD ("DUID is '%s'", (str = nm_dhcp_utils_duid_to_string (priv->duid)));
 
 	g_clear_pointer (&priv->hostname, g_free);
 	priv->hostname = g_strdup (hostname);
@@ -559,51 +551,49 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
 void
 nm_dhcp_client_stop_existing (const char *pid_file, const char *binary_name)
 {
-	char *pid_contents = NULL, *proc_contents = NULL, *proc_path = NULL;
-	long int tmp;
+	guint64 start_time;
+	pid_t pid, ppid;
+	const char *exe;
+	char proc_path[NM_STRLEN ("/proc/%lu/cmdline") + 100];
+	gs_free char *pid_contents = NULL, *proc_contents = NULL;
 
 	/* Check for an existing instance and stop it */
 	if (!g_file_get_contents (pid_file, &pid_contents, NULL, NULL))
 		return;
 
-	errno = 0;
-	tmp = strtol (pid_contents, NULL, 10);
-	if ((errno == 0) && (tmp > 1)) {
-		guint64 start_time;
-		const char *exe;
-		pid_t ppid;
-
-		/* Ensure the process is a DHCP client */
-		start_time = nm_utils_get_start_time_for_pid (tmp, NULL, &ppid);
-		proc_path = g_strdup_printf ("/proc/%ld/cmdline", tmp);
-		if (   start_time
-		    && g_file_get_contents (proc_path, &proc_contents, NULL, NULL)) {
-			exe = strrchr (proc_contents, '/');
-			if (exe)
-				exe++;
-			else
-				exe = proc_contents;
-
-			if (!strcmp (exe, binary_name)) {
-				if (ppid == getpid ()) {
-					/* the process is our own child. */
-					nm_utils_kill_child_sync (tmp, SIGTERM, LOGD_DHCP, "dhcp-client", NULL, 1000 / 2, 1000 / 20);
-				} else {
-					nm_utils_kill_process_sync (tmp, start_time, SIGTERM, LOGD_DHCP,
-					                            "dhcp-client", 1000 / 2, 1000 / 20, 2000);
-				}
-			}
-		}
+	pid = _nm_utils_ascii_str_to_int64 (pid_contents, 10, 1, G_MAXINT64, 0);
+	if (pid <= 0)
+		goto out;
+
+	start_time = nm_utils_get_start_time_for_pid (pid, NULL, &ppid);
+	if (start_time == 0)
+		goto out;
+
+	nm_sprintf_buf (proc_path, "/proc/%lu/cmdline", (long unsigned) pid);
+	if (!g_file_get_contents (proc_path, &proc_contents, NULL, NULL))
+		goto out;
+
+	exe = strrchr (proc_contents, '/');
+	if (exe)
+		exe++;
+	else
+		exe = proc_contents;
+	if (!nm_streq0 (exe, binary_name))
+		goto out;
+
+	if (ppid == getpid ()) {
+		/* the process is our own child. */
+		nm_utils_kill_child_sync (pid, SIGTERM, LOGD_DHCP, "dhcp-client", NULL, 1000 / 2, 1000 / 20);
+	} else {
+		nm_utils_kill_process_sync (pid, start_time, SIGTERM, LOGD_DHCP,
+		                            "dhcp-client", 1000 / 2, 1000 / 20, 2000);
 	}
 
+out:
 	if (remove (pid_file) == -1) {
 		nm_log_dbg (LOGD_DHCP, "dhcp: could not remove pid file \"%s\": %d (%s)",
 		            pid_file, errno, g_strerror (errno));
 	}
-
-	g_free (proc_path);
-	g_free (pid_contents);
-	g_free (proc_contents);
 }
 
 void
@@ -631,7 +621,7 @@ nm_dhcp_client_stop (NMDhcpClient *self, gboolean release)
 /********************************************/
 
 static char *
-bytearray_variant_to_string (GVariant *value, const char *key)
+bytearray_variant_to_string (NMDhcpClient *self, GVariant *value, const char *key)
 {
 	const guint8 *array;
 	gsize length;
@@ -662,7 +652,7 @@ bytearray_variant_to_string (GVariant *value, const char *key)
 
 	converted = str->str;
 	if (!g_utf8_validate (converted, -1, NULL))
-		nm_log_warn (LOGD_DHCP, "dhcp: option '%s' couldn't be converted to UTF-8", key);
+		_LOGW ("option '%s' couldn't be converted to UTF-8", key);
 	g_string_free (str, FALSE);
 	return converted;
 }
@@ -671,7 +661,8 @@ bytearray_variant_to_string (GVariant *value, const char *key)
 #define NEW_TAG "new_"
 
 static void
-maybe_add_option (GHashTable *hash,
+maybe_add_option (NMDhcpClient *self,
+                  GHashTable *hash,
                   const char *key,
                   GVariant *value)
 {
@@ -701,7 +692,7 @@ maybe_add_option (GHashTable *hash,
 	if (!key[0])
 		return;
 
-	str_value = bytearray_variant_to_string (value, key);
+	str_value = bytearray_variant_to_string (self, value, key);
 	if (str_value)
 		g_hash_table_insert (hash, g_strdup (key), str_value);
 }
@@ -747,7 +738,7 @@ nm_dhcp_client_handle_event (gpointer unused,
 		str_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 		g_variant_iter_init (&iter, options);
 		while (g_variant_iter_next (&iter, "{&sv}", &name, &value)) {
-			maybe_add_option (str_options, name, value);
+			maybe_add_option (self, str_options, name, value);
 			g_variant_unref (value);
 		}
 
@@ -836,7 +827,7 @@ set_property (GObject *object, guint prop_id,
 	switch (prop_id) {
 	case PROP_IFACE:
 		/* construct-only */
-		priv->iface = g_strdup (g_value_get_string (value));
+		priv->iface = g_value_dup_string (value);
 		break;
 	case PROP_IFINDEX:
 		/* construct-only */
diff --git a/src/dhcp-manager/nm-dhcp-client.h b/src/dhcp-manager/nm-dhcp-client.h
index 1c78c5b1..5779d4ed 100644
--- a/src/dhcp-manager/nm-dhcp-client.h
+++ b/src/dhcp-manager/nm-dhcp-client.h
@@ -24,8 +24,6 @@
 #include <nm-ip4-config.h>
 #include <nm-ip6-config.h>
 
-#include "nm-default.h"
-
 #define NM_TYPE_DHCP_CLIENT            (nm_dhcp_client_get_type ())
 #define NM_DHCP_CLIENT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_CLIENT, NMDhcpClient))
 #define NM_DHCP_CLIENT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_CLIENT, NMDhcpClientClass))
diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.c b/src/dhcp-manager/nm-dhcp-dhclient-utils.c
index 008f8af2..8d4c54ae 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient-utils.c
+++ b/src/dhcp-manager/nm-dhcp-dhclient-utils.c
@@ -720,7 +720,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface,
 
 		address.timestamp = now_monotonic_ts;
 		address.lifetime = address.preferred = expiry;
-		address.source = NM_IP_CONFIG_SOURCE_DHCP;
+		address.addr_source = NM_IP_CONFIG_SOURCE_DHCP;
 
 		ip4 = nm_ip4_config_new (ifindex);
 		nm_ip4_config_add_address (ip4, &address);
diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.h b/src/dhcp-manager/nm-dhcp-dhclient-utils.h
index 0e255027..83d5a23d 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient-utils.h
+++ b/src/dhcp-manager/nm-dhcp-dhclient-utils.h
@@ -22,8 +22,6 @@
 #include <nm-setting-ip4-config.h>
 #include <nm-setting-ip6-config.h>
 
-#include "nm-default.h"
-
 char *nm_dhcp_dhclient_create_config (const char *interface,
                                       gboolean is_ip6,
                                       GBytes *client_id,
diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c
index b35921ec..bd020624 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient.c
+++ b/src/dhcp-manager/nm-dhcp-dhclient.c
@@ -18,7 +18,8 @@
  * Copyright (C) 2005 - 2012 Red Hat, Inc.
  */
 
-#include "config.h"
+#include <config.h>
+#define __CONFIG_H__
 
 #define _XOPEN_SOURCE
 #include <time.h>
@@ -178,6 +179,9 @@ merge_dhclient_config (NMDhcpDhclient *self,
 		}
 	}
 
+	if (is_ip6 && hostname && !strchr (hostname, '.'))
+		_LOGW ("hostname is not a FQDN, it will be ignored");
+
 	new = nm_dhcp_dhclient_create_config (iface, is_ip6, client_id, anycast_addr, hostname, fqdn, orig_path, orig, out_new_client_id);
 	g_assert (new);
 	success = g_file_set_contents (conf_file, new, -1, error);
diff --git a/src/dhcp-manager/nm-dhcp-dhclient.h b/src/dhcp-manager/nm-dhcp-dhclient.h
index 3e8d9c5d..7f0c855a 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient.h
+++ b/src/dhcp-manager/nm-dhcp-dhclient.h
@@ -19,7 +19,6 @@
 #ifndef __NETWORKMANAGER_DHCP_DHCLIENT_H__
 #define __NETWORKMANAGER_DHCP_DHCLIENT_H__
 
-#include "nm-default.h"
 #include "nm-dhcp-client.h"
 
 #define NM_TYPE_DHCP_DHCLIENT            (nm_dhcp_dhclient_get_type ())
diff --git a/src/dhcp-manager/nm-dhcp-listener.c b/src/dhcp-manager/nm-dhcp-listener.c
index 595b2097..eadff3ec 100644
--- a/src/dhcp-manager/nm-dhcp-listener.c
+++ b/src/dhcp-manager/nm-dhcp-listener.c
@@ -111,20 +111,20 @@ handle_event (GDBusConnection  *connection,
 
 	iface = get_option (options, "interface");
 	if (iface == NULL) {
-		nm_log_warn (LOGD_DHCP, "DHCP event: didn't have associated interface.");
+		nm_log_warn (LOGD_DHCP, "dhcp-event: didn't have associated interface.");
 		goto out;
 	}
 
 	pid_str = get_option (options, "pid");
 	pid = _nm_utils_ascii_str_to_int64 (pid_str, 10, 0, G_MAXINT32, -1);
 	if (pid == -1) {
-		nm_log_warn (LOGD_DHCP, "DHCP event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)");
+		nm_log_warn (LOGD_DHCP, "dhcp-event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)");
 		goto out;
 	}
 
 	reason = get_option (options, "reason");
 	if (reason == NULL) {
-		nm_log_warn (LOGD_DHCP, "(pid %d) DHCP event didn't have a reason", pid);
+		nm_log_warn (LOGD_DHCP, "dhcp-event: (pid %d) DHCP event didn't have a reason", pid);
 		goto out;
 	}
 
@@ -132,9 +132,9 @@ handle_event (GDBusConnection  *connection,
 	if (!handled) {
 		if (g_ascii_strcasecmp (reason, "RELEASE") == 0) {
 			/* Ignore event when the dhcp client gets killed and we receive its last message */
-			nm_log_dbg (LOGD_DHCP, "(pid %d) unhandled RELEASE DHCP event for interface %s", pid, iface);
+			nm_log_dbg (LOGD_DHCP, "dhcp-event: (pid %d) unhandled RELEASE DHCP event for interface %s", pid, iface);
 		} else
-			nm_log_warn (LOGD_DHCP, "(pid %d) unhandled DHCP event for interface %s", pid, iface);
+			nm_log_warn (LOGD_DHCP, "dhcp-event: (pid %d) unhandled DHCP event for interface %s", pid, iface);
 	}
 
 out:
diff --git a/src/dhcp-manager/nm-dhcp-listener.h b/src/dhcp-manager/nm-dhcp-listener.h
index b2631acc..ff31fe34 100644
--- a/src/dhcp-manager/nm-dhcp-listener.h
+++ b/src/dhcp-manager/nm-dhcp-listener.h
@@ -19,8 +19,6 @@
 #ifndef __NETWORKMANAGER_DHCP_LISTENER_H__
 #define __NETWORKMANAGER_DHCP_LISTENER_H__
 
-#include "nm-default.h"
-
 #define NM_TYPE_DHCP_LISTENER           (nm_dhcp_listener_get_type ())
 #define NM_DHCP_LISTENER(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_LISTENER, NMDhcpListener))
 #define NM_IS_DHCP_LISTENER(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_LISTENER))
diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c
index fe723e96..50469c5c 100644
--- a/src/dhcp-manager/nm-dhcp-manager.c
+++ b/src/dhcp-manager/nm-dhcp-manager.c
@@ -372,7 +372,7 @@ nm_dhcp_manager_init (NMDhcpManager *self)
 	for (iter = client_descs; iter; iter = iter->next) {
 		ClientDesc *desc = iter->data;
 
-		nm_log_dbg (LOGD_DHCP, "Registered DHCP client '%s' (%s)",
+		nm_log_dbg (LOGD_DHCP, "dhcp-init: Registered DHCP client '%s' (%s)",
 		            desc->name, g_type_name (desc->gtype));
 	}
 
@@ -380,7 +380,7 @@ nm_dhcp_manager_init (NMDhcpManager *self)
 	client = nm_config_get_dhcp_client (config);
 	if (nm_config_get_configure_and_quit (config)) {
 		if (g_strcmp0 (client, "internal") != 0)
-			nm_log_warn (LOGD_DHCP, "Using internal DHCP client since configure-and-quit is set.");
+			nm_log_warn (LOGD_DHCP, "dhcp-init: Using internal DHCP client since configure-and-quit is set.");
 		client = "internal";
 	}
 
@@ -389,7 +389,7 @@ nm_dhcp_manager_init (NMDhcpManager *self)
 
 	if (type == G_TYPE_INVALID) {
 		if (client)
-			nm_log_warn (LOGD_DHCP, "DHCP client '%s' not available", client);
+			nm_log_warn (LOGD_DHCP, "dhcp-init: DHCP client '%s' not available", client);
 
 		type = is_client_enabled ("dhclient");
 		if (type == G_TYPE_INVALID)
@@ -399,9 +399,9 @@ nm_dhcp_manager_init (NMDhcpManager *self)
 	}
 
 	if (type == G_TYPE_INVALID)
-		nm_log_warn (LOGD_DHCP, "No usable DHCP client found! DHCP configurations will fail");
+		nm_log_warn (LOGD_DHCP, "dhcp-init: No usable DHCP client found! DHCP configurations will fail");
 	else
-		nm_log_info (LOGD_DHCP, "Using DHCP client '%s'", find_client_desc (NULL, type)->name);
+		nm_log_info (LOGD_DHCP, "dhcp-init: Using DHCP client '%s'", find_client_desc (NULL, type)->name);
 
 	priv->client_type = type;
 	priv->clients = g_hash_table_new_full (g_direct_hash, g_direct_equal,
diff --git a/src/dhcp-manager/nm-dhcp-manager.h b/src/dhcp-manager/nm-dhcp-manager.h
index 42d968ab..df92c91c 100644
--- a/src/dhcp-manager/nm-dhcp-manager.h
+++ b/src/dhcp-manager/nm-dhcp-manager.h
@@ -22,8 +22,6 @@
 #ifndef __NETWORKMANAGER_DHCP_MANAGER_H__
 #define __NETWORKMANAGER_DHCP_MANAGER_H__
 
-
-#include "nm-default.h"
 #include "nm-dhcp-client.h"
 #include "nm-ip4-config.h"
 #include "nm-dhcp4-config.h"
diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c
index 82cb3350..ac8eb60a 100644
--- a/src/dhcp-manager/nm-dhcp-systemd.c
+++ b/src/dhcp-manager/nm-dhcp-systemd.c
@@ -34,13 +34,11 @@
 #include "NetworkManagerUtils.h"
 #include "nm-platform.h"
 #include "nm-dhcp-client-logging.h"
+#include "nm-sd.h"
 
 #include "sd-dhcp-client.h"
 #include "sd-dhcp6-client.h"
 
-#include "nm-sd-adapt.h"
-#include "dhcp-lease-internal.h"
-
 G_DEFINE_TYPE (NMDhcpSystemd, nm_dhcp_systemd, NM_TYPE_DHCP_CLIENT)
 
 #define NM_DHCP_SYSTEMD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemdPrivate))
@@ -193,7 +191,7 @@ add_requests_to_options (GHashTable *options, const ReqOption *requests)
 #define LOG_LEASE(domain, ...) \
 G_STMT_START { \
 	if (log_lease) { \
-		nm_log (LOGL_INFO, (domain), __VA_ARGS__); \
+		_LOG2I ((domain), (iface), __VA_ARGS__); \
 	} \
 } G_STMT_END
 
@@ -256,7 +254,7 @@ lease_to_ip4_config (const char *iface,
 	                SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME,
 	                end_time);
 
-	address.source = NM_IP_CONFIG_SOURCE_DHCP;
+	address.addr_source = NM_IP_CONFIG_SOURCE_DHCP;
 	nm_ip4_config_add_address (ip4_config, &address);
 
 	/* DNS Servers */
@@ -323,7 +321,7 @@ lease_to_ip4_config (const char *iface,
 			route.gateway = a.s_addr;
 
 			if (route.plen) {
-				route.source = NM_IP_CONFIG_SOURCE_DHCP;
+				route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
 				route.metric = default_priority;
 				nm_ip4_config_add_route (ip4_config, &route);
 
@@ -578,6 +576,8 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
 		return FALSE;
 	}
 
+	_LOGT ("dhcp-client4: set %p", priv->client4);
+
 	r = sd_dhcp_client_attach_event (priv->client4, NULL, 0);
 	if (r < 0) {
 		_LOGW ("failed to attach event (%d)", r);
@@ -602,9 +602,9 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
 		}
 	}
 
-	r = sd_dhcp_client_set_index (priv->client4, nm_dhcp_client_get_ifindex (client));
+	r = sd_dhcp_client_set_ifindex (priv->client4, nm_dhcp_client_get_ifindex (client));
 	if (r < 0) {
-		_LOGW ("failed to set ifindex (%d)", r);
+		_LOGW ("failed to set ififindex (%d)", r);
 		goto error;
 	}
 
@@ -741,7 +741,7 @@ lease_to_ip6_config (const char *iface,
 			.timestamp = ts,
 			.lifetime = lft_valid,
 			.preferred = lft_pref,
-			.source = NM_IP_CONFIG_SOURCE_DHCP,
+			.addr_source = NM_IP_CONFIG_SOURCE_DHCP,
 		};
 
 		nm_ip6_config_add_address (ip6_config, &address);
@@ -895,6 +895,8 @@ ip6_start (NMDhcpClient *client,
 		return FALSE;
 	}
 
+	_LOGT ("dhcp-client6: set %p", priv->client4);
+
 	if (info_only)
 	    sd_dhcp6_client_set_information_request (priv->client6, 1);
 
@@ -928,7 +930,7 @@ ip6_start (NMDhcpClient *client,
 		}
 	}
 
-	r = sd_dhcp6_client_set_index (priv->client6, nm_dhcp_client_get_ifindex (client));
+	r = sd_dhcp6_client_set_ifindex (priv->client6, nm_dhcp_client_get_ifindex (client));
 	if (r < 0) {
 		_LOGW ("failed to set ifindex (%d)", r);
 		goto error;
@@ -958,6 +960,8 @@ ip6_start (NMDhcpClient *client,
 		goto error;
 	}
 
+	nm_dhcp_client_start_timeout (client);
+
 	return TRUE;
 
 error:
@@ -973,6 +977,10 @@ stop (NMDhcpClient *client, gboolean release, const GByteArray *duid)
 	NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
 	int r = 0;
 
+	_LOGT ("dhcp-client%d: stop %p",
+	       priv->client4 ? '4' : '6',
+	       priv->client4 ? (gpointer) priv->client4 : (gpointer) priv->client6);
+
 	if (priv->client4) {
 		sd_dhcp_client_set_callback (priv->client4, NULL, NULL);
 		r = sd_dhcp_client_stop (priv->client4);
diff --git a/src/dhcp-manager/nm-dhcp-utils.c b/src/dhcp-manager/nm-dhcp-utils.c
index a88a7e6d..593d8c5d 100644
--- a/src/dhcp-manager/nm-dhcp-utils.c
+++ b/src/dhcp-manager/nm-dhcp-utils.c
@@ -28,11 +28,14 @@
 #include "nm-utils.h"
 #include "NetworkManagerUtils.h"
 #include "nm-platform.h"
+#include "nm-dhcp-client-logging.h"
+#include "nm-core-internal.h"
 
 /********************************************/
 
 static gboolean
-ip4_process_dhcpcd_rfc3442_routes (const char *str,
+ip4_process_dhcpcd_rfc3442_routes (const char *iface,
+                                   const char *str,
                                    guint32 priority,
                                    NMIP4Config *ip4_config,
                                    guint32 *gwaddr)
@@ -45,7 +48,7 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str,
 		goto out;
 
 	if ((g_strv_length (routes) % 2) != 0) {
-		nm_log_warn (LOGD_DHCP4, "  classless static routes provided, but invalid");
+		_LOG2W (LOGD_DHCP4, iface, "  classless static routes provided, but invalid");
 		goto out;
 	}
 
@@ -61,16 +64,16 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str,
 			errno = 0;
 			rt_cidr = strtol (slash + 1, NULL, 10);
 			if (errno || rt_cidr > 32) {
-				nm_log_warn (LOGD_DHCP4, "DHCP provided invalid classless static route cidr: '%s'", slash + 1);
+				_LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route cidr: '%s'", slash + 1);
 				continue;
 			}
 		}
 		if (inet_pton (AF_INET, *r, &rt_addr) <= 0) {
-			nm_log_warn (LOGD_DHCP4, "DHCP provided invalid classless static route address: '%s'", *r);
+			_LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route address: '%s'", *r);
 			continue;
 		}
 		if (inet_pton (AF_INET, *(r + 1), &rt_route) <= 0) {
-			nm_log_warn (LOGD_DHCP4, "DHCP provided invalid classless static route gateway: '%s'", *(r + 1));
+			_LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route gateway: '%s'", *(r + 1));
 			continue;
 		}
 
@@ -79,12 +82,12 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str,
 			/* FIXME: how to handle multiple routers? */
 			*gwaddr = rt_route;
 		} else {
-			nm_log_info (LOGD_DHCP4, "  classless static route %s/%d gw %s", *r, rt_cidr, *(r + 1));
+			_LOG2I (LOGD_DHCP4, iface, "  classless static route %s/%d gw %s", *r, rt_cidr, *(r + 1));
 			memset (&route, 0, sizeof (route));
 			route.network = rt_addr;
 			route.plen = rt_cidr;
 			route.gateway = rt_route;
-			route.source = NM_IP_CONFIG_SOURCE_DHCP;
+			route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
 			route.metric = priority;
 			nm_ip4_config_add_route (ip4_config, &route);
 		}
@@ -160,7 +163,8 @@ error:
 }
 
 static gboolean
-ip4_process_dhclient_rfc3442_routes (const char *str,
+ip4_process_dhclient_rfc3442_routes (const char *iface,
+                                     const char *str,
                                      guint32 priority,
                                      NMIP4Config *ip4_config,
                                      guint32 *gwaddr)
@@ -172,7 +176,7 @@ ip4_process_dhclient_rfc3442_routes (const char *str,
 
 	o = octets = g_strsplit_set (str, " .", 0);
 	if (g_strv_length (octets) < 5) {
-		nm_log_warn (LOGD_DHCP4, "ignoring invalid classless static routes '%s'", str);
+		_LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes '%s'", str);
 		goto out;
 	}
 
@@ -180,7 +184,7 @@ ip4_process_dhclient_rfc3442_routes (const char *str,
 		memset (&route, 0, sizeof (route));
 		o = (char **) process_dhclient_rfc3442_route ((const char **) o, &route, &success);
 		if (!success) {
-			nm_log_warn (LOGD_DHCP4, "ignoring invalid classless static routes");
+			_LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes");
 			break;
 		}
 
@@ -192,13 +196,13 @@ ip4_process_dhclient_rfc3442_routes (const char *str,
 			char addr[INET_ADDRSTRLEN];
 
 			/* normal route */
-			route.source = NM_IP_CONFIG_SOURCE_DHCP;
+			route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
 			route.metric = priority;
 			nm_ip4_config_add_route (ip4_config, &route);
 
-			nm_log_info (LOGD_DHCP4, "  classless static route %s/%d gw %s",
-			             nm_utils_inet4_ntop (route.network, addr), route.plen,
-			             nm_utils_inet4_ntop (route.gateway, NULL));
+			_LOG2I (LOGD_DHCP4, iface, "  classless static route %s/%d gw %s",
+			        nm_utils_inet4_ntop (route.network, addr), route.plen,
+			        nm_utils_inet4_ntop (route.gateway, NULL));
 		}
 	}
 
@@ -208,7 +212,8 @@ out:
 }
 
 static gboolean
-ip4_process_classless_routes (GHashTable *options,
+ip4_process_classless_routes (const char *iface,
+                              GHashTable *options,
                               guint32 priority,
                               NMIP4Config *ip4_config,
                               guint32 *gwaddr)
@@ -257,7 +262,7 @@ ip4_process_classless_routes (GHashTable *options,
 	p = str;
 	while (*p) {
 		if (!g_ascii_isdigit (*p) && (*p != ' ') && (*p != '.') && (*p != '/')) {
-			nm_log_warn (LOGD_DHCP4, "ignoring invalid classless static routes '%s'", str);
+			_LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes '%s'", str);
 			return FALSE;
 		}
 		p++;
@@ -265,14 +270,17 @@ ip4_process_classless_routes (GHashTable *options,
 
 	if (strchr (str, '/')) {
 		/* dhcpcd format */
-		return ip4_process_dhcpcd_rfc3442_routes (str, priority, ip4_config, gwaddr);
+		return ip4_process_dhcpcd_rfc3442_routes (iface, str, priority, ip4_config, gwaddr);
 	}
 
-	return ip4_process_dhclient_rfc3442_routes (str, priority, ip4_config, gwaddr);
+	return ip4_process_dhclient_rfc3442_routes (iface, str, priority, ip4_config, gwaddr);
 }
 
 static void
-process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4_config)
+process_classful_routes (const char *iface,
+                         GHashTable *options,
+                         guint32 priority,
+                         NMIP4Config *ip4_config)
 {
 	const char *str;
 	char **searches, **s;
@@ -283,7 +291,7 @@ process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4
 
 	searches = g_strsplit (str, " ", 0);
 	if ((g_strv_length (searches) % 2)) {
-		nm_log_info (LOGD_DHCP, "  static routes provided, but invalid");
+		_LOG2I (LOGD_DHCP, iface, "  static routes provided, but invalid");
 		goto out;
 	}
 
@@ -292,11 +300,11 @@ process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4
 		guint32 rt_addr, rt_route;
 
 		if (inet_pton (AF_INET, *s, &rt_addr) <= 0) {
-			nm_log_warn (LOGD_DHCP, "DHCP provided invalid static route address: '%s'", *s);
+			_LOG2W (LOGD_DHCP, iface, "DHCP provided invalid static route address: '%s'", *s);
 			continue;
 		}
 		if (inet_pton (AF_INET, *(s + 1), &rt_route) <= 0) {
-			nm_log_warn (LOGD_DHCP, "DHCP provided invalid static route gateway: '%s'", *(s + 1));
+			_LOG2W (LOGD_DHCP, iface, "DHCP provided invalid static route gateway: '%s'", *(s + 1));
 			continue;
 		}
 
@@ -314,11 +322,11 @@ process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4
 			route.plen = 32;
 		}
 		route.gateway = rt_route;
-		route.source = NM_IP_CONFIG_SOURCE_DHCP;
+		route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
 		route.metric = priority;
 
 		nm_ip4_config_add_route (ip4_config, &route);
-		nm_log_info (LOGD_DHCP, "  static route %s",
+		_LOG2I (LOGD_DHCP, iface, "  static route %s",
 		             nm_platform_ip4_route_to_string (&route, NULL, 0));
 	}
 
@@ -327,7 +335,10 @@ out:
 }
 
 static void
-process_domain_search (const char *str, GFunc add_func, gpointer user_data)
+process_domain_search (const char *iface,
+                       const char *str,
+                       GFunc add_func,
+                       gpointer user_data)
 {
 	char **searches, **s;
 	char *unescaped, *p;
@@ -348,14 +359,14 @@ process_domain_search (const char *str, GFunc add_func, gpointer user_data)
 	} while (*p++);
 
 	if (strchr (unescaped, '\\')) {
-		nm_log_warn (LOGD_DHCP, "  invalid domain search: '%s'", unescaped);
+		_LOG2W (LOGD_DHCP, iface, "  invalid domain search: '%s'", unescaped);
 		goto out;
 	}
 
 	searches = g_strsplit (unescaped, " ", 0);
 	for (s = searches; *s; s++) {
 		if (strlen (*s)) {
-			nm_log_info (LOGD_DHCP, "  domain search '%s'", *s);
+			_LOG2I (LOGD_DHCP, iface, "  domain search '%s'", *s);
 			add_func (*s, user_data);
 		}
 	}
@@ -393,29 +404,29 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
 
 	str = g_hash_table_lookup (options, "ip_address");
 	if (str && (inet_pton (AF_INET, str, &addr) > 0))
-		nm_log_info (LOGD_DHCP4, "  address %s", str);
+		_LOG2I (LOGD_DHCP4, iface, "  address %s", str);
 	else
 		goto error;
 
 	str = g_hash_table_lookup (options, "subnet_mask");
 	if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
 		plen = nm_utils_ip4_netmask_to_prefix (tmp_addr);
-		nm_log_info (LOGD_DHCP4, "  plen %d (%s)", plen, str);
+		_LOG2I (LOGD_DHCP4, iface, "  plen %d (%s)", plen, str);
 	} else {
 		/* Get default netmask for the IP according to appropriate class. */
 		plen = nm_utils_ip4_get_default_prefix (addr);
-		nm_log_info (LOGD_DHCP4, "  plen %d (default)", plen);
+		_LOG2I (LOGD_DHCP4, iface, "  plen %d (default)", plen);
 	}
 	nm_platform_ip4_address_set_addr (&address, addr, plen);
 
 	/* Routes: if the server returns classless static routes, we MUST ignore
 	 * the 'static_routes' option.
 	 */
-	if (!ip4_process_classless_routes (options, priority, ip4_config, &gwaddr))
-		process_classful_routes (options, priority, ip4_config);
+	if (!ip4_process_classless_routes (iface, options, priority, ip4_config, &gwaddr))
+		process_classful_routes (iface, options, priority, ip4_config);
 
 	if (gwaddr) {
-		nm_log_info (LOGD_DHCP4, "  gateway %s", nm_utils_inet4_ntop (gwaddr, NULL));
+		_LOG2I (LOGD_DHCP4, iface, "  gateway %s", nm_utils_inet4_ntop (gwaddr, NULL));
 		nm_ip4_config_set_gateway (ip4_config, gwaddr);
 	} else {
 		/* If the gateway wasn't provided as a classless static route with a
@@ -430,10 +441,10 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
 				/* FIXME: how to handle multiple routers? */
 				if (inet_pton (AF_INET, *s, &gwaddr) > 0) {
 					nm_ip4_config_set_gateway (ip4_config, gwaddr);
-					nm_log_info (LOGD_DHCP4, "  gateway %s", *s);
+					_LOG2I (LOGD_DHCP4, iface, "  gateway %s", *s);
 					break;
 				} else
-					nm_log_warn (LOGD_DHCP4, "ignoring invalid gateway '%s'", *s);
+					_LOG2W (LOGD_DHCP4, iface, "ignoring invalid gateway '%s'", *s);
 			}
 			g_strfreev (routers);
 		}
@@ -455,7 +466,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
 	if (str) {
 		if (inet_pton (AF_INET, str, &tmp_addr) > 0) {
 
-			nm_log_info (LOGD_DHCP4, "  server identifier %s", str);
+			_LOG2I (LOGD_DHCP4, iface, "  server identifier %s", str);
 			if (   nm_utils_ip4_address_clear_host_address(tmp_addr, address.plen) != nm_utils_ip4_address_clear_host_address(address.address, address.plen)
 			    && !nm_ip4_config_get_direct_route_for_host (ip4_config, tmp_addr)) {
 				/* DHCP server not on assigned subnet and the no direct route was returned. Add route */
@@ -465,29 +476,29 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
 				route.plen = 32;
 				/* this will be a device route if gwaddr is 0 */
 				route.gateway = gwaddr;
-				route.source = NM_IP_CONFIG_SOURCE_DHCP;
+				route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
 				route.metric = priority;
 				nm_ip4_config_add_route (ip4_config, &route);
-				nm_log_dbg (LOGD_IP, "adding route for server identifier: %s",
-				                      nm_platform_ip4_route_to_string (&route, NULL, 0));
+				_LOG2D (LOGD_IP, iface, "adding route for server identifier: %s",
+				        nm_platform_ip4_route_to_string (&route, NULL, 0));
 			}
 		}
 		else
-			nm_log_warn (LOGD_DHCP4, "ignoring invalid server identifier '%s'", str);
+			_LOG2W (LOGD_DHCP4, iface, "ignoring invalid server identifier '%s'", str);
 	}
 
 	str = g_hash_table_lookup (options, "dhcp_lease_time");
 	if (str) {
 		address.lifetime = address.preferred = strtoul (str, NULL, 10);
-		nm_log_info (LOGD_DHCP4, "  lease time %u", address.lifetime);
+		_LOG2I (LOGD_DHCP4, iface, "  lease time %u", address.lifetime);
 	}
 
-	address.source = NM_IP_CONFIG_SOURCE_DHCP;
+	address.addr_source = NM_IP_CONFIG_SOURCE_DHCP;
 	nm_ip4_config_add_address (ip4_config, &address);
 
 	str = g_hash_table_lookup (options, "host_name");
 	if (str)
-		nm_log_info (LOGD_DHCP4, "  hostname '%s'", str);
+		_LOG2I (LOGD_DHCP4, iface, "  hostname '%s'", str);
 
 	str = g_hash_table_lookup (options, "domain_name_servers");
 	if (str) {
@@ -498,10 +509,10 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
 			if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
 				if (tmp_addr) {
 					nm_ip4_config_add_nameserver (ip4_config, tmp_addr);
-					nm_log_info (LOGD_DHCP4, "  nameserver '%s'", *s);
+					_LOG2I (LOGD_DHCP4, iface, "  nameserver '%s'", *s);
 				}
 			} else
-				nm_log_warn (LOGD_DHCP4, "ignoring invalid nameserver '%s'", *s);
+				_LOG2W (LOGD_DHCP4, iface, "ignoring invalid nameserver '%s'", *s);
 		}
 		g_strfreev (dns);
 	}
@@ -512,7 +523,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
 		char **s;
 
 		for (s = domains; *s; s++) {
-			nm_log_info (LOGD_DHCP4, "  domain name '%s'", *s);
+			_LOG2I (LOGD_DHCP4, iface, "  domain name '%s'", *s);
 			nm_ip4_config_add_domain (ip4_config, *s);
 		}
 		g_strfreev (domains);
@@ -520,7 +531,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
 
 	str = g_hash_table_lookup (options, "domain_search");
 	if (str)
-		process_domain_search (str, ip4_add_domain_search, ip4_config);
+		process_domain_search (iface, str, ip4_add_domain_search, ip4_config);
 
 	str = g_hash_table_lookup (options, "netbios_name_servers");
 	if (str) {
@@ -531,10 +542,10 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
 			if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
 				if (tmp_addr) {
 					nm_ip4_config_add_wins (ip4_config, tmp_addr);
-					nm_log_info (LOGD_DHCP4, "  wins '%s'", *s);
+					_LOG2I (LOGD_DHCP4, iface, "  wins '%s'", *s);
 				}
 			} else
-				nm_log_warn (LOGD_DHCP4, "ignoring invalid WINS server '%s'", *s);
+				_LOG2W (LOGD_DHCP4, iface, "ignoring invalid WINS server '%s'", *s);
 		}
 		g_strfreev (nbns);
 	}
@@ -554,7 +565,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
 
 	str = g_hash_table_lookup (options, "nis_domain");
 	if (str) {
-		nm_log_info (LOGD_DHCP4, "  NIS domain '%s'", str);
+		_LOG2I (LOGD_DHCP4, iface, "  NIS domain '%s'", str);
 		nm_ip4_config_set_nis_domain (ip4_config, str);
 	}
 
@@ -567,10 +578,10 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
 			if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
 				if (tmp_addr) {
 					nm_ip4_config_add_nis_server (ip4_config, tmp_addr);
-					nm_log_info (LOGD_DHCP4, "  nis '%s'", *s);
+					_LOG2I (LOGD_DHCP4, iface, "  nis '%s'", *s);
 				}
 			} else
-				nm_log_warn (LOGD_DHCP4, "ignoring invalid NIS server '%s'", *s);
+				_LOG2W (LOGD_DHCP4, iface, "ignoring invalid NIS server '%s'", *s);
 		}
 		g_strfreev (nis);
 	}
@@ -615,8 +626,8 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
 
 	g_hash_table_iter_init (&iter, options);
 	while (g_hash_table_iter_next (&iter, &key, &value)) {
-		nm_log_dbg (LOGD_DHCP6, "(%s): option '%s'=>'%s'",
-		            iface, (const char *) key, (const char *) value);
+		_LOG2D (LOGD_DHCP6, iface, "(%s): option '%s'=>'%s'",
+		        iface, (const char *) key, (const char *) value);
 	}
 
 	ip6_config = nm_ip6_config_new (ifindex);
@@ -624,27 +635,27 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
 	str = g_hash_table_lookup (options, "max_life");
 	if (str) {
 		address.lifetime = strtoul (str, NULL, 10);
-		nm_log_info (LOGD_DHCP6, "  valid_lft %u", address.lifetime);
+		_LOG2I (LOGD_DHCP6, iface, "  valid_lft %u", address.lifetime);
 	}
 
 	str = g_hash_table_lookup (options, "preferred_life");
 	if (str) {
 		address.preferred = strtoul (str, NULL, 10);
-		nm_log_info (LOGD_DHCP6, "  preferred_lft %u", address.preferred);
+		_LOG2I (LOGD_DHCP6, iface, "  preferred_lft %u", address.preferred);
 	}
 
 	str = g_hash_table_lookup (options, "ip6_address");
 	if (str) {
 		if (!inet_pton (AF_INET6, str, &tmp_addr)) {
-			nm_log_warn (LOGD_DHCP6, "(%s): DHCP returned invalid address '%s'",
-			             iface, str);
+			_LOG2W (LOGD_DHCP6, iface, "(%s): DHCP returned invalid address '%s'",
+			        iface, str);
 			goto error;
 		}
 
 		address.address = tmp_addr;
-		address.source = NM_IP_CONFIG_SOURCE_DHCP;
+		address.addr_source = NM_IP_CONFIG_SOURCE_DHCP;
 		nm_ip6_config_add_address (ip6_config, &address);
-		nm_log_info (LOGD_DHCP6, "  address %s", str);
+		_LOG2I (LOGD_DHCP6, iface, "  address %s", str);
 	} else if (info_only == FALSE) {
 		/* No address in Managed mode is a hard error */
 		goto error;
@@ -652,7 +663,7 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
 
 	str = g_hash_table_lookup (options, "host_name");
 	if (str)
-		nm_log_info (LOGD_DHCP6, "  hostname '%s'", str);
+		_LOG2I (LOGD_DHCP6, iface, "  hostname '%s'", str);
 
 	str = g_hash_table_lookup (options, "dhcp6_name_servers");
 	if (str) {
@@ -663,17 +674,17 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
 			if (inet_pton (AF_INET6, *s, &tmp_addr) > 0) {
 				if (!IN6_IS_ADDR_UNSPECIFIED (&tmp_addr)) {
 					nm_ip6_config_add_nameserver (ip6_config, &tmp_addr);
-					nm_log_info (LOGD_DHCP6, "  nameserver '%s'", *s);
+					_LOG2I (LOGD_DHCP6, iface, "  nameserver '%s'", *s);
 				}
 			} else
-				nm_log_warn (LOGD_DHCP6, "ignoring invalid nameserver '%s'", *s);
+				_LOG2W (LOGD_DHCP6, iface, "ignoring invalid nameserver '%s'", *s);
 		}
 		g_strfreev (dns);
 	}
 
 	str = g_hash_table_lookup (options, "dhcp6_domain_search");
 	if (str)
-		process_domain_search (str, ip6_add_domain_search, ip6_config);
+		process_domain_search (iface, str, ip6_add_domain_search, ip6_config);
 
 	return ip6_config;
 
@@ -685,18 +696,9 @@ error:
 char *
 nm_dhcp_utils_duid_to_string (const GByteArray *duid)
 {
-	guint32 i = 0;
-	GString *s;
-
 	g_return_val_if_fail (duid != NULL, NULL);
 
-	s = g_string_sized_new (MIN (duid->len * 3, 50));
-	while (i < duid->len) {
-		if (s->len)
-			g_string_append_c (s, ':');
-		g_string_append_printf (s, "%02x", duid->data[i++]);
-	}
-	return g_string_free (s, FALSE);
+	return _nm_utils_bin2str (duid->data, duid->len, FALSE);
 }
 
 /**
diff --git a/src/dhcp-manager/nm-dhcp-utils.h b/src/dhcp-manager/nm-dhcp-utils.h
index 056982c3..6540b1ff 100644
--- a/src/dhcp-manager/nm-dhcp-utils.h
+++ b/src/dhcp-manager/nm-dhcp-utils.h
@@ -24,8 +24,6 @@
 #include <nm-ip4-config.h>
 #include <nm-ip6-config.h>
 
-#include "nm-default.h"
-
 NMIP4Config *nm_dhcp_utils_ip4_config_from_options (int ifindex,
                                                     const char *iface,
                                                     GHashTable *options,
diff --git a/src/dhcp-manager/tests/Makefile.in b/src/dhcp-manager/tests/Makefile.in
index 2528b3c5..1ce288ba 100644
--- a/src/dhcp-manager/tests/Makefile.in
+++ b/src/dhcp-manager/tests/Makefile.in
@@ -92,8 +92,9 @@ noinst_PROGRAMS = test-dhcp-dhclient$(EXEEXT) test-dhcp-utils$(EXEEXT)
 TESTS = test-dhcp-dhclient$(EXEEXT) test-dhcp-utils$(EXEEXT)
 subdir = src/dhcp-manager/tests
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \
-	$(top_srcdir)/m4/compiler_warnings.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/m4/attributes.m4 \
+	$(top_srcdir)/m4/ax_lib_readline.m4 \
+	$(top_srcdir)/m4/compiler_options.m4 \
 	$(top_srcdir)/m4/gettext.m4 \
 	$(top_srcdir)/m4/gnome-code-coverage.m4 \
 	$(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \
@@ -428,6 +429,7 @@ DHCLIENT_PATH = @DHCLIENT_PATH@
 DHCPCD_PATH = @DHCPCD_PATH@
 DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@
 DLLTOOL = @DLLTOOL@
+DL_LIBS = @DL_LIBS@
 DNSMASQ_PATH = @DNSMASQ_PATH@
 DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@
 DSYMUTIL = @DSYMUTIL@
@@ -484,13 +486,14 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
 INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
 INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
 IPTABLES_PATH = @IPTABLES_PATH@
+JANSSON_CFLAGS = @JANSSON_CFLAGS@
+JANSSON_LIBS = @JANSSON_LIBS@
 KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@
 LCOV = @LCOV@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@
 LIBAUDIT_LIBS = @LIBAUDIT_LIBS@
-LIBDL = @LIBDL@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBM = @LIBM@
@@ -502,6 +505,8 @@ LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@
 LIBSOUP_LIBS = @LIBSOUP_LIBS@
+LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@
+LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@
 LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@
 LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@
 LIBTOOL = @LIBTOOL@
@@ -562,6 +567,8 @@ QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
 READLINE_LIBS = @READLINE_LIBS@
+SANITIZERS = @SANITIZERS@
+SANITIZER_ENV = @SANITIZER_ENV@
 SED = @SED@
 SELINUX_CFLAGS = @SELINUX_CFLAGS@
 SELINUX_LIBS = @SELINUX_LIBS@
@@ -597,6 +604,7 @@ ac_ct_AR = @ac_ct_AR@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_RANLIB = @ac_ct_RANLIB@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
diff --git a/src/dhcp-manager/tests/test-dhcp-dhclient.c b/src/dhcp-manager/tests/test-dhcp-dhclient.c
index 046dd7e2..77849c8c 100644
--- a/src/dhcp-manager/tests/test-dhcp-dhclient.c
+++ b/src/dhcp-manager/tests/test-dhcp-dhclient.c
@@ -31,7 +31,7 @@
 #include "nm-ip4-config.h"
 #include "nm-platform.h"
 
-#include "nm-test-utils.h"
+#include "nm-test-utils-core.h"
 
 #define DEBUG 1
 
diff --git a/src/dhcp-manager/tests/test-dhcp-utils.c b/src/dhcp-manager/tests/test-dhcp-utils.c
index f477c061..89d693ed 100644
--- a/src/dhcp-manager/tests/test-dhcp-utils.c
+++ b/src/dhcp-manager/tests/test-dhcp-utils.c
@@ -28,7 +28,7 @@
 #include "nm-dhcp-utils.h"
 #include "nm-platform.h"
 
-#include "nm-test-utils.h"
+#include "nm-test-utils-core.h"
 
 typedef struct {
 	const char *name;