From 459e76bdfec02046235a8d909bbb7aa2bff26177 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 25 Jul 2017 13:33:02 +0200 Subject: [PATCH] platform: consolidate debug logging during link-add Don't log both in NMPlatform and NMLinuxPlatform. Also, log all provided arguments. --- src/platform/nm-linux-platform.c | 3 --- src/platform/nm-platform.c | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index e25091aa9a..d888dd002e 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -4141,9 +4141,6 @@ link_add (NMPlatform *platform, (void) nm_utils_modprobe (NULL, TRUE, "bonding", "max_bonds=0", NULL); } - _LOGD ("link: add link '%s' of type '%s' (%d)", - name, nm_link_type_to_string (type), (int) type); - nlmsg = _nl_msg_new_link (RTM_NEWLINK, NLM_F_CREATE | NLM_F_EXCL, 0, diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index c8c7663e0e..e086ac8eea 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -776,18 +776,31 @@ nm_platform_link_add (NMPlatform *self, const NMPlatformLink **out_link) { NMPlatformError plerr; + char addr_buf[NM_UTILS_HWADDR_LEN_MAX * 3]; _CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG); g_return_val_if_fail (name, NM_PLATFORM_ERROR_BUG); - g_return_val_if_fail ( (address != NULL) ^ (address_len == 0) , NM_PLATFORM_ERROR_BUG); + g_return_val_if_fail ((address != NULL) ^ (address_len == 0) , NM_PLATFORM_ERROR_BUG); + g_return_val_if_fail (address_len <= NM_UTILS_HWADDR_LEN_MAX, NM_PLATFORM_ERROR_BUG); g_return_val_if_fail ((!!veth_peer) == (type == NM_LINK_TYPE_VETH), NM_PLATFORM_ERROR_BUG); plerr = _link_add_check_existing (self, name, type, out_link); if (plerr != NM_PLATFORM_ERROR_SUCCESS) return plerr; - _LOGD ("link: adding %s '%s'", nm_link_type_to_string (type), name); + _LOGD ("link: add link '%s' of type '%s' (%d)" + "%s%s" /* address */ + "%s%s" /* veth peer */ + "", + name, + nm_link_type_to_string (type), + (int) type, + address ? ", address: " : "", + address ? nm_utils_hwaddr_ntoa_buf (address, address_len, FALSE, addr_buf, sizeof (addr_buf)) : "", + veth_peer ? ", veth-peer: " : "", + veth_peer ?: ""); + if (!klass->link_add (self, name, type, veth_peer, address, address_len, out_link)) return NM_PLATFORM_ERROR_UNSPECIFIED; return NM_PLATFORM_ERROR_SUCCESS;