diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-02-17 17:29:43 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-02-17 19:48:07 +0100 |
commit | 94876904bbd7596c58e0a4a60efc0c1e74eb8e98 (patch) | |
tree | 64c982842362623d9ec64a816d3094faa076b1f7 /src/network/netdev | |
parent | network: assign values after all checks are passed (diff) | |
download | systemd-94876904bbd7596c58e0a4a60efc0c1e74eb8e98.tar.xz systemd-94876904bbd7596c58e0a4a60efc0c1e74eb8e98.zip |
tree-wide: use in_addr_is_set() or friends
Diffstat (limited to 'src/network/netdev')
-rw-r--r-- | src/network/netdev/geneve.c | 2 | ||||
-rw-r--r-- | src/network/netdev/l2tp-tunnel.c | 8 | ||||
-rw-r--r-- | src/network/netdev/tunnel.c | 12 | ||||
-rw-r--r-- | src/network/netdev/vxlan.c | 8 |
4 files changed, 14 insertions, 16 deletions
diff --git a/src/network/netdev/geneve.c b/src/network/netdev/geneve.c index edf92ec93c..fd0b5119e7 100644 --- a/src/network/netdev/geneve.c +++ b/src/network/netdev/geneve.c @@ -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 diff --git a/src/network/netdev/l2tp-tunnel.c b/src/network/netdev/l2tp-tunnel.c index a909b15764..32ec024558 100644 --- a/src/network/netdev/l2tp-tunnel.c +++ b/src/network/netdev/l2tp-tunnel.c @@ -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); diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c index fdaec488a2..2fab269397 100644 --- a/src/network/netdev/tunnel.c +++ b/src/network/netdev/tunnel.c @@ -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; } diff --git a/src/network/netdev/vxlan.c b/src/network/netdev/vxlan.c index 6748f67f8f..52d8b3736c 100644 --- a/src/network/netdev/vxlan.c +++ b/src/network/netdev/vxlan.c @@ -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); |