summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-28 00:42:35 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-28 02:18:46 +0100
commit6c861f0aeff9449ee1201bb56f89861921e41c45 (patch)
tree0ad90b640c3c00ece1f732d37532471697f7cf1d /src
parentbca3e263cfc68f506bfbafb11680f35aa13c38a5 (diff)
networkd: update logging macros for parameter order, and errno, to match rest of the code
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-dhcp4.c4
-rw-r--r--src/network/networkd-link.c60
-rw-r--r--src/network/networkd-link.h24
3 files changed, 31 insertions, 57 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 0a8c8ba8e4..ac59fd48c8 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -442,7 +442,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
}
if (r >= 0)
- log_link_struct(LOG_INFO, link,
+ log_link_struct(link, LOG_INFO,
"MESSAGE=%-*s: DHCPv4 address %u.%u.%u.%u/%u via %u.%u.%u.%u",
IFNAMSIZ,
link->ifname,
@@ -457,7 +457,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
ADDRESS_FMT_VAL(gateway),
NULL);
else
- log_link_struct(LOG_INFO, link,
+ log_link_struct(link, LOG_INFO,
"MESSAGE=%-*s: DHCPv4 address %u.%u.%u.%u/%u",
IFNAMSIZ,
link->ifname,
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index b46ac5c3c3..2eb0925d73 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -515,12 +515,7 @@ static int route_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not set route: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not set route: %m", IFNAMSIZ, link->ifname);
if (link->link_messages == 0) {
log_link_debug(link, "routes set");
@@ -576,12 +571,7 @@ int link_route_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -ESRCH)
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not drop route: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not drop route: %m", IFNAMSIZ, link->ifname);
return 1;
}
@@ -631,12 +621,7 @@ static int address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not set address: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not set address: %m", IFNAMSIZ, link->ifname);
else if (r >= 0) {
/* calling handler directly so take a ref */
link_ref(link);
@@ -695,12 +680,7 @@ int link_address_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata)
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EADDRNOTAVAIL)
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not drop address: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not drop address: %m", IFNAMSIZ, link->ifname);
return 1;
}
@@ -780,11 +760,7 @@ static int set_mtu_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0)
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not set MTU: %s",
- IFNAMSIZ, link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not set MTU: %m", IFNAMSIZ, link->ifname);
return 1;
}
@@ -1003,12 +979,7 @@ static int link_up_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
if (r < 0) {
/* we warn but don't fail the link, as it may
be brought up later */
- log_link_struct(LOG_WARNING, link,
- "MESSAGE=%-*s: could not bring up interface: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_warning_errno(link, -r, "%-*s: could not bring up interface: %m", IFNAMSIZ, link->ifname);
}
return 1;
@@ -1084,12 +1055,7 @@ static int netdev_join_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
- log_link_struct(LOG_ERR, link,
- "MESSAGE=%-*s: could not join netdev: %s",
- IFNAMSIZ,
- link->ifname, strerror(-r),
- "ERRNO=%d", -r,
- NULL);
+ log_link_error_errno(link, -r, "%-*s: could not join netdev: %m", IFNAMSIZ, link->ifname);
link_enter_failed(link);
return 1;
} else
@@ -1120,7 +1086,7 @@ static int link_enter_join_netdev(Link *link) {
return link_joined(link);
if (link->network->bond) {
- log_link_struct(LOG_DEBUG, link,
+ log_link_struct(link, LOG_DEBUG,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, link->network->bond->ifname,
@@ -1129,7 +1095,7 @@ static int link_enter_join_netdev(Link *link) {
r = netdev_join(link->network->bond, link, &netdev_join_handler);
if (r < 0) {
- log_link_struct(LOG_WARNING, link,
+ log_link_struct(link, LOG_WARNING,
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->bond->ifname,
@@ -1144,7 +1110,7 @@ static int link_enter_join_netdev(Link *link) {
}
if (link->network->bridge) {
- log_link_struct(LOG_DEBUG, link,
+ log_link_struct(link, LOG_DEBUG,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, link->network->bridge->ifname,
@@ -1154,7 +1120,7 @@ static int link_enter_join_netdev(Link *link) {
r = netdev_join(link->network->bridge, link,
&netdev_join_handler);
if (r < 0) {
- log_link_struct(LOG_WARNING, link,
+ log_link_struct(link, LOG_WARNING,
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->bridge->ifname,
@@ -1169,7 +1135,7 @@ static int link_enter_join_netdev(Link *link) {
}
HASHMAP_FOREACH(netdev, link->network->stacked_netdevs, i) {
- log_link_struct(LOG_DEBUG, link,
+ log_link_struct(link, LOG_DEBUG,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, netdev->ifname, NETDEVIF(netdev),
@@ -1177,7 +1143,7 @@ static int link_enter_join_netdev(Link *link) {
r = netdev_join(netdev, link, &netdev_join_handler);
if (r < 0) {
- log_link_struct(LOG_WARNING, link,
+ log_link_struct(link, LOG_WARNING,
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, netdev->ifname,
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index 61cdbf3132..56631757a9 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -132,14 +132,22 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
/* Macros which append INTERFACE= to the message */
-#define log_link_full(level, link, fmt, ...) log_object_internal(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
-#define log_link_debug(link, ...) log_link_full(LOG_DEBUG, link, ##__VA_ARGS__)
-#define log_link_info(link, ...) log_link_full(LOG_INFO, link, ##__VA_ARGS__)
-#define log_link_notice(link, ...) log_link_full(LOG_NOTICE, link, ##__VA_ARGS__)
-#define log_link_warning(link, ...) log_link_full(LOG_WARNING, link, ##__VA_ARGS__)
-#define log_link_error(link, ...) log_link_full(LOG_ERR, link, ##__VA_ARGS__)
-
-#define log_link_struct(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
+#define log_link_full(link, level, error, fmt, ...) \
+ log_object_internal(level, error, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
+
+#define log_link_debug(link, ...) log_link_full(link, LOG_DEBUG, 0, ##__VA_ARGS__)
+#define log_link_info(link, ...) log_link_full(link, LOG_INFO, 0, ##__VA_ARGS__)
+#define log_link_notice(link, ...) log_link_full(link, LOG_NOTICE, 0, ##__VA_ARGS__)
+#define log_link_warning(link, ...) log_link_full(link, LOG_WARNING, 0, ##__VA_ARGS__)
+#define log_link_error(link, ...) log_link_full(link, LOG_ERR, 0, ##__VA_ARGS__)
+
+#define log_link_debug_errno(link, error, ...) log_link_full(link, LOG_DEBUG, error, ##__VA_ARGS__)
+#define log_link_info_errno(link, error, ...) log_link_full(link, LOG_INFO, error, ##__VA_ARGS__)
+#define log_link_notice_errno(link, error, ...) log_link_full(link, LOG_NOTICE, error, ##__VA_ARGS__)
+#define log_link_warning_errno(link, error, ...) log_link_full(link, LOG_WARNING, error, ##__VA_ARGS__)
+#define log_link_error_errno(link, error, ...) log_link_full(link, LOG_ERR, error, ##__VA_ARGS__)
+
+#define log_link_struct(link, level, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
#define ADDRESS_FMT_VAL(address) \
(address).s_addr & 0xFF, \