1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 00:51:24 +03:00

networkd: tunnel improve logging

Replaces a lof ot strerror() usage with log_netdev_error_errno()
This commit is contained in:
Susant Sahani 2015-04-22 14:14:54 +05:30 committed by Tom Gundersen
parent 882f407f31
commit 5289f3ff07

View File

@ -54,44 +54,24 @@ static int netdev_ipip_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
assert(t->family == AF_INET);
r = sd_rtnl_message_append_u32(m, IFLA_IPTUN_LINK, link->ifindex);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LINK attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_LINK attribute: %m");
r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &t->local.in);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LOCAL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_LOCAL attribute: %m");
r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &t->remote.in);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_REMOTE attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_REMOTE attribute: %m");
r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_TTL, t->ttl);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_TTL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_TTL attribute: %m");
r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_PMTUDISC, t->pmtudisc);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_PMTUDISC attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_PMTUDISC attribute: %m");
return r;
}
@ -107,44 +87,24 @@ static int netdev_sit_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
assert(t->family == AF_INET);
r = sd_rtnl_message_append_u32(m, IFLA_IPTUN_LINK, link->ifindex);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LINK attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_LINK attribute: %m");
r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &t->local.in);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LOCAL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_LOCAL attribute: %m");
r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &t->remote.in);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_REMOTE attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_REMOTE attribute: %m");
r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_TTL, t->ttl);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_TTL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_TTL attribute: %m");
r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_PMTUDISC, t->pmtudisc);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_PMTUDISC attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_PMTUDISC attribute: %m");
return r;
}
@ -166,52 +126,28 @@ static int netdev_gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
assert(m);
r = sd_rtnl_message_append_u32(m, IFLA_GRE_LINK, link->ifindex);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_GRE_LINK attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_LINK attribute: %m");
r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_LOCAL, &t->local.in);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_GRE_LOCAL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_LOCAL attribute: %m");
r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_REMOTE, &t->remote.in);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_GRE_REMOTE attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_REMOTE attribute: %m");
r = sd_rtnl_message_append_u8(m, IFLA_GRE_TTL, t->ttl);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_GRE_TTL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_TTL attribute: %m");
r = sd_rtnl_message_append_u8(m, IFLA_GRE_TOS, t->tos);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_GRE_TOS attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_TOS attribute: %m");
r = sd_rtnl_message_append_u8(m, IFLA_GRE_PMTUDISC, t->pmtudisc);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_GRE_PMTUDISC attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_PMTUDISC attribute: %m");
return r;
}
@ -233,36 +169,20 @@ static int netdev_ip6gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl
assert(m);
r = sd_rtnl_message_append_u32(m, IFLA_GRE_LINK, link->ifindex);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_GRE_LINK attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_LINK attribute: %m");
r = sd_rtnl_message_append_in6_addr(m, IFLA_GRE_LOCAL, &t->local.in6);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_GRE_LOCAL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_LOCAL attribute: %m");
r = sd_rtnl_message_append_in6_addr(m, IFLA_GRE_REMOTE, &t->remote.in6);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_GRE_REMOTE attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_REMOTE attribute: %m");
r = sd_rtnl_message_append_u8(m, IFLA_GRE_TTL, t->ttl);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_GRE_TTL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_TTL attribute: %m");
return r;
}
@ -278,28 +198,16 @@ static int netdev_vti_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
assert(t->family == AF_INET);
r = sd_rtnl_message_append_u32(m, IFLA_VTI_LINK, link->ifindex);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LINK attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_LINK attribute: %m");
r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_LOCAL, &t->local.in);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LOCAL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_LOCAL attribute: %m");
r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_REMOTE, &t->remote.in);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_REMOTE attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_REMOTE attribute: %m");
return r;
}
@ -316,36 +224,20 @@ static int netdev_ip6tnl_fill_message_create(NetDev *netdev, Link *link, sd_rtnl
assert(t->family == AF_INET6);
r = sd_rtnl_message_append_u32(m, IFLA_IPTUN_LINK, link->ifindex);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LINK attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_LINK attribute: %m");
r = sd_rtnl_message_append_in6_addr(m, IFLA_IPTUN_LOCAL, &t->local.in6);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LOCAL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_LOCAL attribute: %m");
r = sd_rtnl_message_append_in6_addr(m, IFLA_IPTUN_REMOTE, &t->remote.in6);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_REMOTE attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_REMOTE attribute: %m");
r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_TTL, t->ttl);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_TTL attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_TTL attribute: %m");
switch (t->ip6tnl_mode) {
case NETDEV_IP6_TNL_MODE_IP6IP6:
@ -361,12 +253,8 @@ static int netdev_ip6tnl_fill_message_create(NetDev *netdev, Link *link, sd_rtnl
}
r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_PROTO, proto);
if (r < 0) {
log_netdev_error(netdev,
"Could not append IFLA_IPTUN_MODE attribute: %s",
strerror(-r));
return r;
}
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPTUN_MODE attribute: %m");
return r;
}