summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-06-11 13:03:15 +0200
committerThomas Haller <thaller@redhat.com>2018-06-12 14:45:40 +0200
commit67ffd17b6cd6c7da4723075cac4ee07ad1c0da85 (patch)
tree80b66465ba615f26b9efcd7dacfe82c4006a1845
parent374d147421a963a31f15c344c0ada4a39e7884f0 (diff)
downloadNetworkManager-67ffd17b6cd6c7da4723075cac4ee07ad1c0da85.tar.gz
device: unify logging of ipv6.dhcp-duid by giving common prefix
For better or worse, the logging done for ipv4.dhcp-client-id is prefixed with ipv4.dhcp-client-id. Let ipv6.dhcp-duid follow that pattern. Also, generate_duid_from_machine_id() would log at two places, it should use the same logging prefix. Also, it logs the value of "duid" variable. Ensure, that "duid" is not %NULL at that point. Also, fix leak of nm_dhcp_utils_duid_to_string() value during logging.
-rw-r--r--src/devices/nm-device.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index a084563534..07e2aba3e1 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -7821,6 +7821,7 @@ dhcp6_get_duid (NMDevice *self, NMConnection *connection, GBytes *hwaddr, NMDhcp
guint8 sha256_digest[32];
gsize len = sizeof (sha256_digest);
NMDhcpDuidEnforce duid_enforce = NM_DHCP_DUID_ENFORCE_ALWAYS;
+ gs_free char *logstr1 = NULL;
s_ip6 = nm_connection_get_setting_ip6_config (connection);
duid = nm_setting_ip6_config_get_dhcp_duid (NM_SETTING_IP6_CONFIG (s_ip6));
@@ -7829,9 +7830,11 @@ dhcp6_get_duid (NMDevice *self, NMConnection *connection, GBytes *hwaddr, NMDhcp
duid_default = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
"ipv6.dhcp-duid", self);
duid = duid_default;
+ if (!duid)
+ duid = "lease";
}
- if (!duid || nm_streq (duid, "lease")) {
+ if (nm_streq (duid, "lease")) {
duid_enforce = NM_DHCP_DUID_ENFORCE_NEVER;
duid_out = generate_duid_from_machine_id ();
if (!duid_out) {
@@ -7938,7 +7941,9 @@ out_fail:
{
guint8 uuid[16];
- _LOGW (LOGD_IP6, "duid-gen (%s): %s. Fallback to random DUID-UUID.", duid, duid_error);
+ _LOGW (LOGD_IP6 | LOGD_DHCP6,
+ "ipv6.dhcp-duid: failure to generate %s DUID: %s. Fallback to random DUID-UUID.",
+ duid, duid_error);
nm_utils_random_bytes (uuid, sizeof (uuid));
duid_out = generate_duid_uuid (uuid, sizeof (uuid));
@@ -7946,9 +7951,11 @@ out_fail:
out_good:
nm_assert (duid_out);
- _LOGD (LOGD_IP6, "DUID gen: '%s' (%s)",
- nm_dhcp_utils_duid_to_string (duid_out),
- (duid_enforce == NM_DHCP_DUID_ENFORCE_ALWAYS) ? "enforcing" : "fallback");
+ _LOGD (LOGD_IP6 | LOGD_DHCP6,
+ "ipv6.dhcp-duid: generate %s DUID '%s' (%s)",
+ duid,
+ (logstr1 = nm_dhcp_utils_duid_to_string (duid_out)),
+ (duid_enforce == NM_DHCP_DUID_ENFORCE_ALWAYS) ? "enforcing" : "fallback");
NM_SET_OUT (out_enforce, duid_enforce);
return duid_out;