diff options
author | Thomas Haller <thaller@redhat.com> | 2016-07-10 12:34:34 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-07-10 13:22:12 +0200 |
commit | 1c58ce0d748174b5b3a27dd077192b45fed2d0a4 (patch) | |
tree | 2643db10627c3c14d9fc0f188cac8dbf84372ce7 | |
parent | bfe4a69c2555b1bc8c89821425efcca660064eb5 (diff) | |
download | NetworkManager-1c58ce0d748174b5b3a27dd077192b45fed2d0a4.tar.gz |
dhcp: prefix logging messages with "dhcp"
-rw-r--r-- | src/dhcp-manager/nm-dhcp-client-logging.h | 23 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-client.c | 33 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-listener.c | 10 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-manager.c | 10 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-systemd.c | 2 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-utils.c | 126 |
6 files changed, 116 insertions, 88 deletions
diff --git a/src/dhcp-manager/nm-dhcp-client-logging.h b/src/dhcp-manager/nm-dhcp-client-logging.h index bb4f2f4aa6..96b6358033 100644 --- a/src/dhcp-manager/nm-dhcp-client-logging.h +++ b/src/dhcp-manager/nm-dhcp-client-logging.h @@ -52,4 +52,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 eab6132b2a..4ae06692d7 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,12 @@ get_duid (NMDhcpClient *self) { static GByteArray *duid = NULL; GByteArray *copy = NULL; - char *str; if (G_UNLIKELY (duid == NULL)) { + gs_free char *str = 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 +517,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 +532,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); @@ -629,7 +623,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; @@ -660,7 +654,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; } @@ -669,7 +663,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) { @@ -699,7 +694,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); } @@ -745,7 +740,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); } diff --git a/src/dhcp-manager/nm-dhcp-listener.c b/src/dhcp-manager/nm-dhcp-listener.c index 595b209748..eadff3ec54 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-manager.c b/src/dhcp-manager/nm-dhcp-manager.c index fe723e9684..50469c5cd5 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-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c index 28a8988613..d975a63500 100644 --- a/src/dhcp-manager/nm-dhcp-systemd.c +++ b/src/dhcp-manager/nm-dhcp-systemd.c @@ -193,7 +193,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 diff --git a/src/dhcp-manager/nm-dhcp-utils.c b/src/dhcp-manager/nm-dhcp-utils.c index 3c397ce1f6..a6a0f9bf92 100644 --- a/src/dhcp-manager/nm-dhcp-utils.c +++ b/src/dhcp-manager/nm-dhcp-utils.c @@ -28,11 +28,13 @@ #include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-platform.h" +#include "nm-dhcp-client-logging.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 +47,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 +63,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,7 +81,7 @@ 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; @@ -160,7 +162,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 +175,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 +183,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; } @@ -196,9 +199,9 @@ ip4_process_dhclient_rfc3442_routes (const char *str, 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 +211,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 +261,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 +269,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 +290,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 +299,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; } @@ -318,7 +325,7 @@ process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4 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 +334,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 +358,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 +403,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 +440,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 +465,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 */ @@ -468,18 +478,18 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex, 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.addr_source = NM_IP_CONFIG_SOURCE_DHCP; @@ -487,7 +497,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex, 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 +508,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 +522,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 +530,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 +541,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 +564,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 +577,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 +625,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 +634,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.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 +662,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 +673,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; |