Commit 8cdc3223 authored by Kuniyuki Iwashima's avatar Kuniyuki Iwashima Committed by David S. Miller
Browse files

ipv6: Remove in6addr_any alternatives.



Some code defines the IPv6 wildcard address as a local variable and
use it with memcmp() or ipv6_addr_equal().

Let's use in6addr_any and ipv6_addr_any() instead.

Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5a8c8b72
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -98,7 +98,6 @@ int mlx5e_tc_set_attr_rx_tun(struct mlx5e_tc_flow *flow,
#if IS_ENABLED(CONFIG_INET) && IS_ENABLED(CONFIG_IPV6)
	else if (ip_version == 6) {
		int ipv6_size = MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6);
		struct in6_addr zerov6 = {};

		daddr = MLX5_ADDR_OF(fte_match_param, spec->match_value,
				     outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6);
@@ -106,8 +105,8 @@ int mlx5e_tc_set_attr_rx_tun(struct mlx5e_tc_flow *flow,
				     outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6);
		memcpy(&tun_attr->dst_ip.v6, daddr, ipv6_size);
		memcpy(&tun_attr->src_ip.v6, saddr, ipv6_size);
		if (!memcmp(&tun_attr->dst_ip.v6, &zerov6, sizeof(zerov6)) ||
		    !memcmp(&tun_attr->src_ip.v6, &zerov6, sizeof(zerov6)))
		if (ipv6_addr_any(&tun_attr->dst_ip.v6) ||
		    ipv6_addr_any(&tun_attr->src_ip.v6))
			return 0;
	}
#endif
+3 −6
Original line number Diff line number Diff line
@@ -469,13 +469,10 @@ void rt6_get_prefsrc(const struct rt6_info *rt, struct in6_addr *addr)
	rcu_read_lock();

	from = rcu_dereference(rt->from);
	if (from) {
	if (from)
		*addr = from->fib6_prefsrc.addr;
	} else {
		struct in6_addr in6_zero = {};

		*addr = in6_zero;
	}
	else
		*addr = in6addr_any;

	rcu_read_unlock();
}
+2 −3
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ TRACE_EVENT(fib_table_lookup,
	),

	TP_fast_assign(
		struct in6_addr in6_zero = {};
		struct net_device *dev;
		struct in6_addr *in6;
		__be32 *p32;
@@ -74,7 +73,7 @@ TRACE_EVENT(fib_table_lookup,
				*p32 = nhc->nhc_gw.ipv4;

				in6 = (struct in6_addr *)__entry->gw6;
				*in6 = in6_zero;
				*in6 = in6addr_any;
			} else if (nhc->nhc_gw_family == AF_INET6) {
				p32 = (__be32 *) __entry->gw4;
				*p32 = 0;
@@ -87,7 +86,7 @@ TRACE_EVENT(fib_table_lookup,
			*p32 = 0;

			in6 = (struct in6_addr *)__entry->gw6;
			*in6 = in6_zero;
			*in6 = in6addr_any;
		}
	),

+1 −4
Original line number Diff line number Diff line
@@ -68,11 +68,8 @@ TRACE_EVENT(fib6_table_lookup,
			strcpy(__entry->name, "-");
		}
		if (res->f6i == net->ipv6.fib6_null_entry) {
			struct in6_addr in6_zero = {};

			in6 = (struct in6_addr *)__entry->gw;
			*in6 = in6_zero;

			*in6 = in6addr_any;
		} else if (res->nh) {
			in6 = (struct in6_addr *)__entry->gw;
			*in6 = res->nh->fib_nh_gw6;
+5 −5
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <linux/net.h>
#include <linux/pm_runtime.h>
#include <net/devlink.h>
#include <net/ipv6.h>
#include <net/xdp_sock_drv.h>
#include <net/flow_offload.h>
#include <linux/ethtool_netlink.h>
@@ -3127,7 +3128,6 @@ struct ethtool_rx_flow_rule *
ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input)
{
	const struct ethtool_rx_flow_spec *fs = input->fs;
	static struct in6_addr zero_addr = {};
	struct ethtool_rx_flow_match *match;
	struct ethtool_rx_flow_rule *flow;
	struct flow_action_entry *act;
@@ -3233,20 +3233,20 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input)

		v6_spec = &fs->h_u.tcp_ip6_spec;
		v6_m_spec = &fs->m_u.tcp_ip6_spec;
		if (memcmp(v6_m_spec->ip6src, &zero_addr, sizeof(zero_addr))) {
		if (!ipv6_addr_any((struct in6_addr *)v6_m_spec->ip6src)) {
			memcpy(&match->key.ipv6.src, v6_spec->ip6src,
			       sizeof(match->key.ipv6.src));
			memcpy(&match->mask.ipv6.src, v6_m_spec->ip6src,
			       sizeof(match->mask.ipv6.src));
		}
		if (memcmp(v6_m_spec->ip6dst, &zero_addr, sizeof(zero_addr))) {
		if (!ipv6_addr_any((struct in6_addr *)v6_m_spec->ip6dst)) {
			memcpy(&match->key.ipv6.dst, v6_spec->ip6dst,
			       sizeof(match->key.ipv6.dst));
			memcpy(&match->mask.ipv6.dst, v6_m_spec->ip6dst,
			       sizeof(match->mask.ipv6.dst));
		}
		if (memcmp(v6_m_spec->ip6src, &zero_addr, sizeof(zero_addr)) ||
		    memcmp(v6_m_spec->ip6dst, &zero_addr, sizeof(zero_addr))) {
		if (!ipv6_addr_any((struct in6_addr *)v6_m_spec->ip6src) ||
		    !ipv6_addr_any((struct in6_addr *)v6_m_spec->ip6dst)) {
			match->dissector.used_keys |=
				BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS);
			match->dissector.offset[FLOW_DISSECTOR_KEY_IPV6_ADDRS] =
Loading