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.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user