summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-02-03 00:09:13 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-02-11 01:28:09 +0900
commitd40b01e44b1bfc6af72284f722fff131d51ec349 (patch)
tree67e476d2f0bd1bdae02483d869a469eaeb22548e /src
parentc606db69ab5d872c79046aa1632e38be6ac6d1db (diff)
downloadsystemd-d40b01e44b1bfc6af72284f722fff131d51ec349.tar.gz
network: in_addr_is_null() may return negative errno
So, do not silently cast the returned value to boolean. Exception is the case that family is trivially AF_INET or AF_INET6.
Diffstat (limited to 'src')
-rw-r--r--src/network/netdev/geneve.c5
-rw-r--r--src/network/netdev/tunnel.c4
-rw-r--r--src/network/netdev/vxlan.c8
-rw-r--r--src/network/networkd-address.c2
-rw-r--r--src/network/networkd-route.c8
-rw-r--r--src/network/networkd-routing-policy-rule.c12
6 files changed, 14 insertions, 25 deletions
diff --git a/src/network/netdev/geneve.c b/src/network/netdev/geneve.c
index 089bbfea22..a5c52bbf82 100644
--- a/src/network/netdev/geneve.c
+++ b/src/network/netdev/geneve.c
@@ -83,16 +83,13 @@ static int netdev_geneve_create(NetDev *netdev) {
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GENEVE_ID attribute: %m");
}
- if (!in_addr_is_null(v->remote_family, &v->remote)) {
-
+ if (in_addr_is_null(v->remote_family, &v->remote) == 0) {
if (v->remote_family == AF_INET)
r = sd_netlink_message_append_in_addr(m, IFLA_GENEVE_REMOTE, &v->remote.in);
else
r = sd_netlink_message_append_in6_addr(m, IFLA_GENEVE_REMOTE6, &v->remote.in6);
-
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GENEVE_GROUP attribute: %m");
-
}
if (v->ttl) {
diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c
index 684edddb5f..c7058b3bec 100644
--- a/src/network/netdev/tunnel.c
+++ b/src/network/netdev/tunnel.c
@@ -578,8 +578,8 @@ int config_parse_tunnel_address(const char *unit,
* unspecified, also clear the address family.
*/
if (t->family != AF_UNSPEC &&
- in_addr_is_null(t->family, &t->local) &&
- in_addr_is_null(t->family, &t->remote))
+ in_addr_is_null(t->family, &t->local) != 0 &&
+ in_addr_is_null(t->family, &t->remote) != 0)
t->family = AF_UNSPEC;
return 0;
}
diff --git a/src/network/netdev/vxlan.c b/src/network/netdev/vxlan.c
index 4cb2eca3d2..4b855ae1e1 100644
--- a/src/network/netdev/vxlan.c
+++ b/src/network/netdev/vxlan.c
@@ -33,24 +33,20 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_netli
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_ID attribute: %m");
}
- if (!in_addr_is_null(v->remote_family, &v->remote)) {
-
+ if (in_addr_is_null(v->remote_family, &v->remote) == 0) {
if (v->remote_family == AF_INET)
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->remote.in);
else
r = sd_netlink_message_append_in6_addr(m, IFLA_VXLAN_GROUP6, &v->remote.in6);
-
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_GROUP attribute: %m");
}
- if (!in_addr_is_null(v->local_family, &v->local)) {
-
+ if (in_addr_is_null(v->local_family, &v->local) == 0) {
if (v->local_family == AF_INET)
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_LOCAL, &v->local.in);
else
r = sd_netlink_message_append_in6_addr(m, IFLA_VXLAN_LOCAL6, &v->local.in6);
-
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_LOCAL attribute: %m");
}
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 3cdbd9e37e..87345fb2d6 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -625,7 +625,7 @@ int address_configure(
if (r < 0)
return log_error_errno(r, "Could not append IFA_LOCAL attribute: %m");
- if (!in_addr_is_null(address->family, &address->in_addr_peer)) {
+ if (in_addr_is_null(address->family, &address->in_addr_peer) == 0) {
if (address->family == AF_INET)
r = sd_netlink_message_append_in_addr(req, IFA_ADDRESS, &address->in_addr_peer.in);
else if (address->family == AF_INET6)
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 5553a7e3bd..6dd7a07c32 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -408,7 +408,7 @@ int route_remove(Route *route, Link *link,
if (r < 0)
return log_error_errno(r, "Could not create RTM_DELROUTE message: %m");
- if (!in_addr_is_null(route->family, &route->gw)) {
+ if (in_addr_is_null(route->family, &route->gw) == 0) {
if (route->family == AF_INET)
r = sd_netlink_message_append_in_addr(req, RTA_GATEWAY, &route->gw.in);
else if (route->family == AF_INET6)
@@ -443,7 +443,7 @@ int route_remove(Route *route, Link *link,
return log_error_errno(r, "Could not set source prefix length: %m");
}
- if (!in_addr_is_null(route->family, &route->prefsrc)) {
+ if (in_addr_is_null(route->family, &route->prefsrc) == 0) {
if (route->family == AF_INET)
r = sd_netlink_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc.in);
else if (route->family == AF_INET6)
@@ -519,7 +519,7 @@ int route_configure(
if (r < 0)
return log_error_errno(r, "Could not create RTM_NEWROUTE message: %m");
- if (!in_addr_is_null(route->family, &route->gw)) {
+ if (in_addr_is_null(route->family, &route->gw) == 0) {
if (route->family == AF_INET)
r = sd_netlink_message_append_in_addr(req, RTA_GATEWAY, &route->gw.in);
else if (route->family == AF_INET6)
@@ -558,7 +558,7 @@ int route_configure(
return log_error_errno(r, "Could not set source prefix length: %m");
}
- if (!in_addr_is_null(route->family, &route->prefsrc)) {
+ if (in_addr_is_null(route->family, &route->prefsrc) == 0) {
if (route->family == AF_INET)
r = sd_netlink_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc.in);
else if (route->family == AF_INET6)
diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c
index 2dc78622ce..e5805ab0ea 100644
--- a/src/network/networkd-routing-policy-rule.c
+++ b/src/network/networkd-routing-policy-rule.c
@@ -369,12 +369,11 @@ int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *lin
if (r < 0)
return log_error_errno(r, "Could not allocate RTM_DELRULE message: %m");
- if (!in_addr_is_null(routing_policy_rule->family, &routing_policy_rule->from)) {
+ if (in_addr_is_null(routing_policy_rule->family, &routing_policy_rule->from) == 0) {
if (routing_policy_rule->family == AF_INET)
r = sd_netlink_message_append_in_addr(m, FRA_SRC, &routing_policy_rule->from.in);
else
r = sd_netlink_message_append_in6_addr(m, FRA_SRC, &routing_policy_rule->from.in6);
-
if (r < 0)
return log_error_errno(r, "Could not append FRA_SRC attribute: %m");
@@ -383,12 +382,11 @@ int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *lin
return log_error_errno(r, "Could not set source prefix length: %m");
}
- if (!in_addr_is_null(routing_policy_rule->family, &routing_policy_rule->to)) {
+ if (in_addr_is_null(routing_policy_rule->family, &routing_policy_rule->to) == 0) {
if (routing_policy_rule->family == AF_INET)
r = sd_netlink_message_append_in_addr(m, FRA_DST, &routing_policy_rule->to.in);
else
r = sd_netlink_message_append_in6_addr(m, FRA_DST, &routing_policy_rule->to.in6);
-
if (r < 0)
return log_error_errno(r, "Could not append FRA_DST attribute: %m");
@@ -496,12 +494,11 @@ int routing_policy_rule_configure(RoutingPolicyRule *rule, Link *link, link_netl
if (r < 0)
return log_error_errno(r, "Could not allocate RTM_NEWRULE message: %m");
- if (!in_addr_is_null(rule->family, &rule->from)) {
+ if (in_addr_is_null(rule->family, &rule->from) == 0) {
if (rule->family == AF_INET)
r = sd_netlink_message_append_in_addr(m, FRA_SRC, &rule->from.in);
else
r = sd_netlink_message_append_in6_addr(m, FRA_SRC, &rule->from.in6);
-
if (r < 0)
return log_error_errno(r, "Could not append FRA_SRC attribute: %m");
@@ -510,12 +507,11 @@ int routing_policy_rule_configure(RoutingPolicyRule *rule, Link *link, link_netl
return log_error_errno(r, "Could not set source prefix length: %m");
}
- if (!in_addr_is_null(rule->family, &rule->to)) {
+ if (in_addr_is_null(rule->family, &rule->to) == 0) {
if (rule->family == AF_INET)
r = sd_netlink_message_append_in_addr(m, FRA_DST, &rule->to.in);
else
r = sd_netlink_message_append_in6_addr(m, FRA_DST, &rule->to.in6);
-
if (r < 0)
return log_error_errno(r, "Could not append FRA_DST attribute: %m");