diff options
author | Thomas Haller <thaller@redhat.com> | 2020-10-30 12:35:56 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-10-30 12:38:31 +0100 |
commit | 2898daa5185b81de3e93970c31bb9ee468c8645e (patch) | |
tree | cb21d5825272cda48254ee465044aa3d2758b650 | |
parent | 2ebe34a5daf43b36aa8d9f8d5278befe1b5d1875 (diff) | |
download | NetworkManager-2898daa5185b81de3e93970c31bb9ee468c8645e.tar.gz |
shared,all: introduce and use LOGD_IPX()/LOGD_DHCPX() macros
These macros are consistent with NMP_OBJECT_TYPE_IP_ADDRESS()
and NMP_OBJECT_TYPE_IP_ROUTE(), in name and usage.
Replace the previous functions that had inconsistent and a verbose
naming.
-rw-r--r-- | shared/nm-glib-aux/nm-logging-fwd.h | 10 | ||||
-rw-r--r-- | src/devices/nm-device.c | 16 | ||||
-rw-r--r-- | src/nm-logging.h | 12 |
3 files changed, 11 insertions, 27 deletions
diff --git a/shared/nm-glib-aux/nm-logging-fwd.h b/shared/nm-glib-aux/nm-logging-fwd.h index ee75b71325..2f550e5f9f 100644 --- a/shared/nm-glib-aux/nm-logging-fwd.h +++ b/shared/nm-glib-aux/nm-logging-fwd.h @@ -57,15 +57,11 @@ typedef enum { /*< skip >*/ /* aliases: */ LOGD_DHCP = LOGD_DHCP4 | LOGD_DHCP6, LOGD_IP = LOGD_IP4 | LOGD_IP6, -} NMLogDomain; -static inline NMLogDomain -LOGD_DHCP_from_addr_family(int addr_family) -{ - nm_assert_addr_family(addr_family); +#define LOGD_DHCPX(is_ipv4) ((is_ipv4) ? LOGD_DHCP4 : LOGD_DHCP6) +#define LOGD_IPX(is_ipv4) ((is_ipv4) ? LOGD_IP4 : LOGD_IP6) - return addr_family == AF_INET6 ? LOGD_DHCP6 : LOGD_DHCP4; -} +} NMLogDomain; /* Log levels */ typedef enum { /*< skip >*/ diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index bd08de9e19..aa3071cfb1 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -9088,7 +9088,7 @@ dhcp_grace_period_expired(NMDevice *self, int addr_family) priv->dhcp_data_x[IS_IPv4].grace_id = 0; priv->dhcp_data_x[IS_IPv4].grace_pending = FALSE; - _LOGI(LOGD_DHCP_from_addr_family(addr_family), + _LOGI(LOGD_DHCPX(IS_IPv4), "DHCPv%c: grace period expired", nm_utils_addr_family_to_char(addr_family)); @@ -9129,12 +9129,12 @@ dhcp_grace_period_start(NMDevice *self, int addr_family) * by a constant factor. */ timeout = _prop_get_ipvx_dhcp_timeout(self, addr_family); if (timeout == NM_DHCP_TIMEOUT_INFINITY) - _LOGI(LOGD_DHCP_from_addr_family(addr_family), + _LOGI(LOGD_DHCPX(IS_IPv4), "DHCPv%c: trying to acquire a new lease", nm_utils_addr_family_to_char(addr_family)); else { timeout = dhcp_grace_period_from_timeout(timeout); - _LOGI(LOGD_DHCP_from_addr_family(addr_family), + _LOGI(LOGD_DHCPX(IS_IPv4), "DHCPv%c: trying to acquire a new lease within %u seconds", nm_utils_addr_family_to_char(addr_family), timeout); @@ -12376,7 +12376,7 @@ nm_device_reactivate_ip_config(NMDevice * self, } if (nm_device_get_ip_ifindex(self) > 0 && !ip_config_merge_and_apply(self, addr_family, TRUE)) { - _LOGW(LOGD_IP_from_af(addr_family), + _LOGW(LOGD_IPX(IS_IPv4), "Failed to reapply IPv%c configuration", nm_utils_addr_family_to_char(addr_family)); } @@ -13415,7 +13415,7 @@ nm_device_set_ip_config(NMDevice * self, }))); nm_assert(IS_IPv4 || !ip4_dev_route_blacklist); - _LOGD(LOGD_IP_from_af(addr_family), + _LOGD(LOGD_IPX(IS_IPv4), "ip%c-config: update (commit=%d, new-config=%p)", nm_utils_addr_family_to_char(addr_family), commit, @@ -13452,7 +13452,7 @@ nm_device_set_ip_config(NMDevice * self, * this causes a re-read and reset. This should only happen for relevant changes */ nm_ip_config_replace(old_config, new_config, &has_changes); if (has_changes) { - _LOGD(LOGD_IP_from_af(addr_family), + _LOGD(LOGD_IPX(IS_IPv4), "ip%c-config: update IP Config instance (%s)", nm_utils_addr_family_to_char(addr_family), nm_dbus_object_get_path(NM_DBUS_OBJECT(old_config))); @@ -13463,14 +13463,14 @@ nm_device_set_ip_config(NMDevice * self, if (!nm_dbus_object_is_exported(NM_DBUS_OBJECT(new_config))) nm_dbus_object_export(NM_DBUS_OBJECT(new_config)); - _LOGD(LOGD_IP_from_af(addr_family), + _LOGD(LOGD_IPX(IS_IPv4), "ip%c-config: set IP Config instance (%s)", nm_utils_addr_family_to_char(addr_family), nm_dbus_object_get_path(NM_DBUS_OBJECT(new_config))); } else if (old_config /*&& !new_config*/) { has_changes = TRUE; priv->ip_config_x[IS_IPv4] = NULL; - _LOGD(LOGD_IP_from_af(addr_family), + _LOGD(LOGD_IPX(IS_IPv4), "ip%c-config: clear IP Config instance (%s)", nm_utils_addr_family_to_char(addr_family), nm_dbus_object_get_path(NM_DBUS_OBJECT(old_config))); diff --git a/src/nm-logging.h b/src/nm-logging.h index b2251c929d..cfaffa9885 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -17,18 +17,6 @@ #define NM_LOG_CONFIG_BACKEND_SYSLOG "syslog" #define NM_LOG_CONFIG_BACKEND_JOURNAL "journal" -static inline NMLogDomain -LOGD_IP_from_af(int addr_family) -{ - switch (addr_family) { - case AF_INET: - return LOGD_IP4; - case AF_INET6: - return LOGD_IP6; - } - g_return_val_if_reached(LOGD_NONE); -} - #define nm_log_err(domain, ...) nm_log(LOGL_ERR, (domain), NULL, NULL, __VA_ARGS__) #define nm_log_warn(domain, ...) nm_log(LOGL_WARN, (domain), NULL, NULL, __VA_ARGS__) #define nm_log_info(domain, ...) nm_log(LOGL_INFO, (domain), NULL, NULL, __VA_ARGS__) |