tree-wide: use in_addr_is_set() or friends
This commit is contained in:
@@ -90,7 +90,7 @@ 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) == 0) {
|
||||
if (in_addr_is_set(v->remote_family, &v->remote)) {
|
||||
if (v->remote_family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(m, IFLA_GENEVE_REMOTE, &v->remote.in);
|
||||
else
|
||||
|
||||
@@ -252,7 +252,7 @@ static int l2tp_acquire_local_address_one(L2tpTunnel *t, Address *a, union in_ad
|
||||
if (a->family != t->family)
|
||||
return -EINVAL;
|
||||
|
||||
if (in_addr_is_null(a->family, &a->in_addr_peer) <= 0)
|
||||
if (in_addr_is_set(a->family, &a->in_addr_peer))
|
||||
return -EINVAL;
|
||||
|
||||
if (t->local_address_type == NETDEV_L2TP_LOCAL_ADDRESS_STATIC &&
|
||||
@@ -275,7 +275,7 @@ static int l2tp_acquire_local_address(L2tpTunnel *t, Link *link, union in_addr_u
|
||||
assert(ret);
|
||||
assert(IN_SET(t->family, AF_INET, AF_INET6));
|
||||
|
||||
if (!in_addr_is_null(t->family, &t->local)) {
|
||||
if (in_addr_is_set(t->family, &t->local)) {
|
||||
/* local address is explicitly specified. */
|
||||
*ret = t->local;
|
||||
return 0;
|
||||
@@ -435,7 +435,7 @@ int config_parse_l2tp_tunnel_address(
|
||||
addr_type = l2tp_local_address_type_from_string(rvalue);
|
||||
|
||||
if (addr_type >= 0) {
|
||||
if (in_addr_is_null(t->family, &t->remote) != 0)
|
||||
if (!in_addr_is_set(t->family, &t->remote))
|
||||
/* If Remote= is not specified yet, then also clear family. */
|
||||
t->family = AF_UNSPEC;
|
||||
|
||||
@@ -682,7 +682,7 @@ static int netdev_l2tp_tunnel_verify(NetDev *netdev, const char *filename) {
|
||||
"%s: L2TP tunnel with invalid address family configured. Ignoring",
|
||||
filename);
|
||||
|
||||
if (in_addr_is_null(t->family, &t->remote))
|
||||
if (!in_addr_is_set(t->family, &t->remote))
|
||||
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s: L2TP tunnel without a remote address configured. Ignoring",
|
||||
filename);
|
||||
|
||||
@@ -468,7 +468,7 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
|
||||
"vti/ipip/sit/gre tunnel without a local/remote IPv4 address configured in %s. Ignoring", filename);
|
||||
|
||||
if (IN_SET(netdev->kind, NETDEV_KIND_GRETAP, NETDEV_KIND_ERSPAN) &&
|
||||
(t->family != AF_INET || in_addr_is_null(t->family, &t->remote)))
|
||||
(t->family != AF_INET || !in_addr_is_set(t->family, &t->remote)))
|
||||
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
|
||||
"gretap/erspan tunnel without a remote IPv4 address configured in %s. Ignoring", filename);
|
||||
|
||||
@@ -478,7 +478,7 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
|
||||
"vti6/ip6tnl/ip6gre tunnel without a local/remote IPv6 address configured in %s. Ignoring", filename);
|
||||
|
||||
if (netdev->kind == NETDEV_KIND_IP6GRETAP &&
|
||||
(t->family != AF_INET6 || in_addr_is_null(t->family, &t->remote)))
|
||||
(t->family != AF_INET6 || !in_addr_is_set(t->family, &t->remote)))
|
||||
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
|
||||
"ip6gretap tunnel without a remote IPv6 address configured in %s. Ignoring", filename);
|
||||
|
||||
@@ -530,11 +530,9 @@ int config_parse_tunnel_address(const char *unit,
|
||||
*addr = IN_ADDR_NULL;
|
||||
|
||||
/* As a special case, if both the local and remote addresses are
|
||||
* unspecified, also clear the address family.
|
||||
*/
|
||||
if (t->family != AF_UNSPEC &&
|
||||
in_addr_is_null(t->family, &t->local) != 0 &&
|
||||
in_addr_is_null(t->family, &t->remote) != 0)
|
||||
* unspecified, also clear the address family. */
|
||||
if (!in_addr_is_set(t->family, &t->local) &&
|
||||
!in_addr_is_set(t->family, &t->remote))
|
||||
t->family = AF_UNSPEC;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ 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->group_family, &v->group) == 0) {
|
||||
if (in_addr_is_set(v->group_family, &v->group)) {
|
||||
if (v->group_family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->group.in);
|
||||
else
|
||||
r = sd_netlink_message_append_in6_addr(m, IFLA_VXLAN_GROUP6, &v->group.in6);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_GROUP attribute: %m");
|
||||
} else if (in_addr_is_null(v->remote_family, &v->remote) == 0) {
|
||||
} else if (in_addr_is_set(v->remote_family, &v->remote)) {
|
||||
if (v->remote_family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->remote.in);
|
||||
else
|
||||
@@ -53,7 +53,7 @@ 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_GROUP attribute: %m");
|
||||
}
|
||||
|
||||
if (in_addr_is_null(v->local_family, &v->local) == 0) {
|
||||
if (in_addr_is_set(v->local_family, &v->local)) {
|
||||
if (v->local_family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_LOCAL, &v->local.in);
|
||||
else
|
||||
@@ -354,7 +354,7 @@ static int netdev_vxlan_verify(NetDev *netdev, const char *filename) {
|
||||
if (!v->dest_port && v->generic_protocol_extension)
|
||||
v->dest_port = 4790;
|
||||
|
||||
if (in_addr_is_null(v->group_family, &v->group) == 0 && in_addr_is_null(v->remote_family, &v->remote) == 0)
|
||||
if (in_addr_is_set(v->group_family, &v->group) && in_addr_is_set(v->remote_family, &v->remote))
|
||||
return log_netdev_warning_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s: VXLAN both 'Group=' and 'Remote=' cannot be specified. Ignoring.",
|
||||
filename);
|
||||
|
||||
Reference in New Issue
Block a user