summaryrefslogtreecommitdiff
path: root/src/network/networkd-netdev-tunnel.c
diff options
context:
space:
mode:
authorSusant Sahani <susant@redhat.com>2015-04-22 14:14:54 +0530
committerTom Gundersen <teg@jklm.no>2015-04-29 21:54:00 +0200
commit5289f3ff0773bd6d0ce584a06aacb834ffa56fb9 (patch)
tree04d302f41164715b057cd9aa958ff840d0fba34a /src/network/networkd-netdev-tunnel.c
parent882f407f3133f3603b69be162940002a9a37ba48 (diff)
networkd: tunnel improve logging
Replaces a lof ot strerror() usage with log_netdev_error_errno()
Diffstat (limited to 'src/network/networkd-netdev-tunnel.c')
-rw-r--r--src/network/networkd-netdev-tunnel.c240
1 files changed, 64 insertions, 176 deletions
diff --git a/src/network/networkd-netdev-tunnel.c b/src/network/networkd-netdev-tunnel.c
index 89ad3ee048..7aa9317a18 100644
--- a/src/network/networkd-netdev-tunnel.c
+++ b/src/network/networkd-netdev-tunnel.c
@@ -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;
}
@@ -156,9 +116,9 @@ static int netdev_gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
assert(netdev);
if (netdev->kind == NETDEV_KIND_GRE)
- t = GRE(netdev);
+ t = GRE(netdev);
else
- t = GRETAP(netdev);
+ t = GRETAP(netdev);
assert(t);
assert(t->family == AF_INET);
@@ -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;
}
@@ -223,9 +159,9 @@ static int netdev_ip6gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl
assert(netdev);
if (netdev->kind == NETDEV_KIND_IP6GRE)
- t = IP6GRE(netdev);
+ t = IP6GRE(netdev);
else
- t = IP6GRETAP(netdev);
+ t = IP6GRETAP(netdev);
assert(t);
assert(t->family == AF_INET6);
@@ -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;
}
@@ -409,13 +297,13 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
assert(t);
if (t->remote.in.s_addr == INADDR_ANY) {
- log_warning("Tunnel without remote address configured in %s. Ignoring", filename);
- return -EINVAL;
+ log_warning("Tunnel without remote address configured in %s. Ignoring", filename);
+ return -EINVAL;
}
if (t->family != AF_INET && t->family != AF_INET6) {
- log_warning("Tunnel with invalid address family configured in %s. Ignoring", filename);
- return -EINVAL;
+ log_warning("Tunnel with invalid address family configured in %s. Ignoring", filename);
+ return -EINVAL;
}
if (netdev->kind == NETDEV_KIND_IP6TNL) {