Skip to content

Commit 9380d89

Browse files
committed
Merge branch 'in6addr_any-cleanups'
Kuniyuki Iwashima says: ==================== ipv6: Random cleanup for in6addr_any. The first patch removes in6addr_any alternatives and the second removes redundant initialisation of a local variable. Changes: v2: Use ipv6_addr_any() in patch 1. (David Ahern) v1: https://lore.kernel.org/netdev/20230322012204.33157-1-kuniyu@amazon.com/ ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 5a8c8b7 + be689c7 commit 9380d89

File tree

7 files changed

+18
-29
lines changed

7 files changed

+18
-29
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,15 @@ int mlx5e_tc_set_attr_rx_tun(struct mlx5e_tc_flow *flow,
9898
#if IS_ENABLED(CONFIG_INET) && IS_ENABLED(CONFIG_IPV6)
9999
else if (ip_version == 6) {
100100
int ipv6_size = MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6);
101-
struct in6_addr zerov6 = {};
102101

103102
daddr = MLX5_ADDR_OF(fte_match_param, spec->match_value,
104103
outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6);
105104
saddr = MLX5_ADDR_OF(fte_match_param, spec->match_value,
106105
outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6);
107106
memcpy(&tun_attr->dst_ip.v6, daddr, ipv6_size);
108107
memcpy(&tun_attr->src_ip.v6, saddr, ipv6_size);
109-
if (!memcmp(&tun_attr->dst_ip.v6, &zerov6, sizeof(zerov6)) ||
110-
!memcmp(&tun_attr->src_ip.v6, &zerov6, sizeof(zerov6)))
108+
if (ipv6_addr_any(&tun_attr->dst_ip.v6) ||
109+
ipv6_addr_any(&tun_attr->src_ip.v6))
111110
return 0;
112111
}
113112
#endif

include/net/ip6_fib.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,10 @@ void rt6_get_prefsrc(const struct rt6_info *rt, struct in6_addr *addr)
469469
rcu_read_lock();
470470

471471
from = rcu_dereference(rt->from);
472-
if (from) {
472+
if (from)
473473
*addr = from->fib6_prefsrc.addr;
474-
} else {
475-
struct in6_addr in6_zero = {};
476-
477-
*addr = in6_zero;
478-
}
474+
else
475+
*addr = in6addr_any;
479476

480477
rcu_read_unlock();
481478
}

include/trace/events/fib.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ TRACE_EVENT(fib_table_lookup,
3636
),
3737

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

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

8988
in6 = (struct in6_addr *)__entry->gw6;
90-
*in6 = in6_zero;
89+
*in6 = in6addr_any;
9190
}
9291
),
9392

include/trace/events/fib6.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,8 @@ TRACE_EVENT(fib6_table_lookup,
6868
strcpy(__entry->name, "-");
6969
}
7070
if (res->f6i == net->ipv6.fib6_null_entry) {
71-
struct in6_addr in6_zero = {};
72-
7371
in6 = (struct in6_addr *)__entry->gw;
74-
*in6 = in6_zero;
75-
72+
*in6 = in6addr_any;
7673
} else if (res->nh) {
7774
in6 = (struct in6_addr *)__entry->gw;
7875
*in6 = res->nh->fib_nh_gw6;

net/6lowpan/iphc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ static u8 lowpan_compress_ctx_addr(u8 **hc_ptr, const struct net_device *dev,
848848
const struct lowpan_iphc_ctx *ctx,
849849
const unsigned char *lladdr, bool sam)
850850
{
851-
struct in6_addr tmp = {};
851+
struct in6_addr tmp;
852852
u8 dam;
853853

854854
switch (lowpan_dev(dev)->lltype) {

net/ethtool/ioctl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/net.h>
2828
#include <linux/pm_runtime.h>
2929
#include <net/devlink.h>
30+
#include <net/ipv6.h>
3031
#include <net/xdp_sock_drv.h>
3132
#include <net/flow_offload.h>
3233
#include <linux/ethtool_netlink.h>
@@ -3127,7 +3128,6 @@ struct ethtool_rx_flow_rule *
31273128
ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input)
31283129
{
31293130
const struct ethtool_rx_flow_spec *fs = input->fs;
3130-
static struct in6_addr zero_addr = {};
31313131
struct ethtool_rx_flow_match *match;
31323132
struct ethtool_rx_flow_rule *flow;
31333133
struct flow_action_entry *act;
@@ -3233,20 +3233,20 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input)
32333233

32343234
v6_spec = &fs->h_u.tcp_ip6_spec;
32353235
v6_m_spec = &fs->m_u.tcp_ip6_spec;
3236-
if (memcmp(v6_m_spec->ip6src, &zero_addr, sizeof(zero_addr))) {
3236+
if (!ipv6_addr_any((struct in6_addr *)v6_m_spec->ip6src)) {
32373237
memcpy(&match->key.ipv6.src, v6_spec->ip6src,
32383238
sizeof(match->key.ipv6.src));
32393239
memcpy(&match->mask.ipv6.src, v6_m_spec->ip6src,
32403240
sizeof(match->mask.ipv6.src));
32413241
}
3242-
if (memcmp(v6_m_spec->ip6dst, &zero_addr, sizeof(zero_addr))) {
3242+
if (!ipv6_addr_any((struct in6_addr *)v6_m_spec->ip6dst)) {
32433243
memcpy(&match->key.ipv6.dst, v6_spec->ip6dst,
32443244
sizeof(match->key.ipv6.dst));
32453245
memcpy(&match->mask.ipv6.dst, v6_m_spec->ip6dst,
32463246
sizeof(match->mask.ipv6.dst));
32473247
}
3248-
if (memcmp(v6_m_spec->ip6src, &zero_addr, sizeof(zero_addr)) ||
3249-
memcmp(v6_m_spec->ip6dst, &zero_addr, sizeof(zero_addr))) {
3248+
if (!ipv6_addr_any((struct in6_addr *)v6_m_spec->ip6src) ||
3249+
!ipv6_addr_any((struct in6_addr *)v6_m_spec->ip6dst)) {
32503250
match->dissector.used_keys |=
32513251
BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS);
32523252
match->dissector.offset[FLOW_DISSECTOR_KEY_IPV6_ADDRS] =

net/ipv4/inet_hashtables.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -826,21 +826,19 @@ bool inet_bind2_bucket_match_addr_any(const struct inet_bind2_bucket *tb, const
826826
unsigned short port, int l3mdev, const struct sock *sk)
827827
{
828828
#if IS_ENABLED(CONFIG_IPV6)
829-
struct in6_addr addr_any = {};
830-
831829
if (sk->sk_family != tb->family) {
832830
if (sk->sk_family == AF_INET)
833831
return net_eq(ib2_net(tb), net) && tb->port == port &&
834832
tb->l3mdev == l3mdev &&
835-
ipv6_addr_equal(&tb->v6_rcv_saddr, &addr_any);
833+
ipv6_addr_any(&tb->v6_rcv_saddr);
836834

837835
return false;
838836
}
839837

840838
if (sk->sk_family == AF_INET6)
841839
return net_eq(ib2_net(tb), net) && tb->port == port &&
842840
tb->l3mdev == l3mdev &&
843-
ipv6_addr_equal(&tb->v6_rcv_saddr, &addr_any);
841+
ipv6_addr_any(&tb->v6_rcv_saddr);
844842
else
845843
#endif
846844
return net_eq(ib2_net(tb), net) && tb->port == port &&
@@ -866,11 +864,10 @@ inet_bhash2_addr_any_hashbucket(const struct sock *sk, const struct net *net, in
866864
{
867865
struct inet_hashinfo *hinfo = tcp_or_dccp_get_hashinfo(sk);
868866
u32 hash;
869-
#if IS_ENABLED(CONFIG_IPV6)
870-
struct in6_addr addr_any = {};
871867

868+
#if IS_ENABLED(CONFIG_IPV6)
872869
if (sk->sk_family == AF_INET6)
873-
hash = ipv6_portaddr_hash(net, &addr_any, port);
870+
hash = ipv6_portaddr_hash(net, &in6addr_any, port);
874871
else
875872
#endif
876873
hash = ipv4_portaddr_hash(net, 0, port);

0 commit comments

Comments
 (0)