* [PATCH v2 net-next 0/2] ipv6: Random cleanup for in6addr_any.
@ 2023-03-27 23:54 Kuniyuki Iwashima
2023-03-27 23:54 ` [PATCH v2 net-next 1/2] ipv6: Remove in6addr_any alternatives Kuniyuki Iwashima
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Kuniyuki Iwashima @ 2023-03-27 23:54 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
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/
Kuniyuki Iwashima (2):
ipv6: Remove in6addr_any alternatives.
6lowpan: Remove redundant initialisation.
.../net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 5 ++---
include/net/ip6_fib.h | 9 +++------
include/trace/events/fib.h | 5 ++---
include/trace/events/fib6.h | 5 +----
net/6lowpan/iphc.c | 2 +-
net/ethtool/ioctl.c | 10 +++++-----
net/ipv4/inet_hashtables.c | 11 ++++-------
7 files changed, 18 insertions(+), 29 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 net-next 1/2] ipv6: Remove in6addr_any alternatives.
2023-03-27 23:54 [PATCH v2 net-next 0/2] ipv6: Random cleanup for in6addr_any Kuniyuki Iwashima
@ 2023-03-27 23:54 ` Kuniyuki Iwashima
2023-03-28 6:27 ` Mark Bloch
2023-03-28 14:32 ` David Ahern
2023-03-27 23:54 ` [PATCH v2 net-next 2/2] 6lowpan: Remove redundant initialisation Kuniyuki Iwashima
2023-03-29 8:00 ` [PATCH v2 net-next 0/2] ipv6: Random cleanup for in6addr_any patchwork-bot+netdevbpf
2 siblings, 2 replies; 8+ messages in thread
From: Kuniyuki Iwashima @ 2023-03-27 23:54 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
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: Kuniyuki Iwashima <kuniyu@amazon.com>
---
.../net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 5 ++---
include/net/ip6_fib.h | 9 +++------
include/trace/events/fib.h | 5 ++---
include/trace/events/fib6.h | 5 +----
net/ethtool/ioctl.c | 10 +++++-----
net/ipv4/inet_hashtables.c | 11 ++++-------
6 files changed, 17 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
index a108e73c9f66..20c2d2ecaf93 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
@@ -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
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 6268963d9599..6f21d37a07c3 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -472,13 +472,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();
}
diff --git a/include/trace/events/fib.h b/include/trace/events/fib.h
index c2300c407f58..76297ecd4935 100644
--- a/include/trace/events/fib.h
+++ b/include/trace/events/fib.h
@@ -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;
}
),
diff --git a/include/trace/events/fib6.h b/include/trace/events/fib6.h
index 6e821eb79450..4d3e607b3cde 100644
--- a/include/trace/events/fib6.h
+++ b/include/trace/events/fib6.h
@@ -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;
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 646b3e490c71..59adc4e6e9ee 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -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] =
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 6edae3886885..e7391bf310a7 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -826,13 +826,11 @@ bool inet_bind2_bucket_match_addr_any(const struct inet_bind2_bucket *tb, const
unsigned short port, int l3mdev, const struct sock *sk)
{
#if IS_ENABLED(CONFIG_IPV6)
- struct in6_addr addr_any = {};
-
if (sk->sk_family != tb->family) {
if (sk->sk_family == AF_INET)
return net_eq(ib2_net(tb), net) && tb->port == port &&
tb->l3mdev == l3mdev &&
- ipv6_addr_equal(&tb->v6_rcv_saddr, &addr_any);
+ ipv6_addr_any(&tb->v6_rcv_saddr);
return false;
}
@@ -840,7 +838,7 @@ bool inet_bind2_bucket_match_addr_any(const struct inet_bind2_bucket *tb, const
if (sk->sk_family == AF_INET6)
return net_eq(ib2_net(tb), net) && tb->port == port &&
tb->l3mdev == l3mdev &&
- ipv6_addr_equal(&tb->v6_rcv_saddr, &addr_any);
+ ipv6_addr_any(&tb->v6_rcv_saddr);
else
#endif
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
{
struct inet_hashinfo *hinfo = tcp_or_dccp_get_hashinfo(sk);
u32 hash;
-#if IS_ENABLED(CONFIG_IPV6)
- struct in6_addr addr_any = {};
+#if IS_ENABLED(CONFIG_IPV6)
if (sk->sk_family == AF_INET6)
- hash = ipv6_portaddr_hash(net, &addr_any, port);
+ hash = ipv6_portaddr_hash(net, &in6addr_any, port);
else
#endif
hash = ipv4_portaddr_hash(net, 0, port);
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 net-next 2/2] 6lowpan: Remove redundant initialisation.
2023-03-27 23:54 [PATCH v2 net-next 0/2] ipv6: Random cleanup for in6addr_any Kuniyuki Iwashima
2023-03-27 23:54 ` [PATCH v2 net-next 1/2] ipv6: Remove in6addr_any alternatives Kuniyuki Iwashima
@ 2023-03-27 23:54 ` Kuniyuki Iwashima
2023-03-28 6:27 ` Mark Bloch
2023-03-29 8:00 ` [PATCH v2 net-next 0/2] ipv6: Random cleanup for in6addr_any patchwork-bot+netdevbpf
2 siblings, 1 reply; 8+ messages in thread
From: Kuniyuki Iwashima @ 2023-03-27 23:54 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
We'll call memset(&tmp, 0, sizeof(tmp)) later.
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
net/6lowpan/iphc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index 52fad5dad9f7..e116d308a8df 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -848,7 +848,7 @@ static u8 lowpan_compress_ctx_addr(u8 **hc_ptr, const struct net_device *dev,
const struct lowpan_iphc_ctx *ctx,
const unsigned char *lladdr, bool sam)
{
- struct in6_addr tmp = {};
+ struct in6_addr tmp;
u8 dam;
switch (lowpan_dev(dev)->lltype) {
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 net-next 2/2] 6lowpan: Remove redundant initialisation.
2023-03-27 23:54 ` [PATCH v2 net-next 2/2] 6lowpan: Remove redundant initialisation Kuniyuki Iwashima
@ 2023-03-28 6:27 ` Mark Bloch
2023-03-28 19:00 ` Kuniyuki Iwashima
0 siblings, 1 reply; 8+ messages in thread
From: Mark Bloch @ 2023-03-28 6:27 UTC (permalink / raw)
To: Kuniyuki Iwashima, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, netdev
On 28/03/2023 2:54, Kuniyuki Iwashima wrote:
> We'll call memset(&tmp, 0, sizeof(tmp)) later.
Why not just remove the first memset() then?
Mark
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
> net/6lowpan/iphc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
> index 52fad5dad9f7..e116d308a8df 100644
> --- a/net/6lowpan/iphc.c
> +++ b/net/6lowpan/iphc.c
> @@ -848,7 +848,7 @@ static u8 lowpan_compress_ctx_addr(u8 **hc_ptr, const struct net_device *dev,
> const struct lowpan_iphc_ctx *ctx,
> const unsigned char *lladdr, bool sam)
> {
> - struct in6_addr tmp = {};
> + struct in6_addr tmp;
> u8 dam;
>
> switch (lowpan_dev(dev)->lltype) {
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 net-next 1/2] ipv6: Remove in6addr_any alternatives.
2023-03-27 23:54 ` [PATCH v2 net-next 1/2] ipv6: Remove in6addr_any alternatives Kuniyuki Iwashima
@ 2023-03-28 6:27 ` Mark Bloch
2023-03-28 14:32 ` David Ahern
1 sibling, 0 replies; 8+ messages in thread
From: Mark Bloch @ 2023-03-28 6:27 UTC (permalink / raw)
To: Kuniyuki Iwashima, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, netdev
On 28/03/2023 2:54, Kuniyuki Iwashima wrote:
> 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: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
> .../net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 5 ++---
> include/net/ip6_fib.h | 9 +++------
> include/trace/events/fib.h | 5 ++---
> include/trace/events/fib6.h | 5 +----
> net/ethtool/ioctl.c | 10 +++++-----
> net/ipv4/inet_hashtables.c | 11 ++++-------
> 6 files changed, 17 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
> index a108e73c9f66..20c2d2ecaf93 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
> @@ -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
> diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
> index 6268963d9599..6f21d37a07c3 100644
> --- a/include/net/ip6_fib.h
> +++ b/include/net/ip6_fib.h
> @@ -472,13 +472,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();
> }
> diff --git a/include/trace/events/fib.h b/include/trace/events/fib.h
> index c2300c407f58..76297ecd4935 100644
> --- a/include/trace/events/fib.h
> +++ b/include/trace/events/fib.h
> @@ -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;
> }
> ),
>
> diff --git a/include/trace/events/fib6.h b/include/trace/events/fib6.h
> index 6e821eb79450..4d3e607b3cde 100644
> --- a/include/trace/events/fib6.h
> +++ b/include/trace/events/fib6.h
> @@ -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;
> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
> index 646b3e490c71..59adc4e6e9ee 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -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] =
> diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
> index 6edae3886885..e7391bf310a7 100644
> --- a/net/ipv4/inet_hashtables.c
> +++ b/net/ipv4/inet_hashtables.c
> @@ -826,13 +826,11 @@ bool inet_bind2_bucket_match_addr_any(const struct inet_bind2_bucket *tb, const
> unsigned short port, int l3mdev, const struct sock *sk)
> {
> #if IS_ENABLED(CONFIG_IPV6)
> - struct in6_addr addr_any = {};
> -
> if (sk->sk_family != tb->family) {
> if (sk->sk_family == AF_INET)
> return net_eq(ib2_net(tb), net) && tb->port == port &&
> tb->l3mdev == l3mdev &&
> - ipv6_addr_equal(&tb->v6_rcv_saddr, &addr_any);
> + ipv6_addr_any(&tb->v6_rcv_saddr);
>
> return false;
> }
> @@ -840,7 +838,7 @@ bool inet_bind2_bucket_match_addr_any(const struct inet_bind2_bucket *tb, const
> if (sk->sk_family == AF_INET6)
> return net_eq(ib2_net(tb), net) && tb->port == port &&
> tb->l3mdev == l3mdev &&
> - ipv6_addr_equal(&tb->v6_rcv_saddr, &addr_any);
> + ipv6_addr_any(&tb->v6_rcv_saddr);
> else
> #endif
> 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
> {
> struct inet_hashinfo *hinfo = tcp_or_dccp_get_hashinfo(sk);
> u32 hash;
> -#if IS_ENABLED(CONFIG_IPV6)
> - struct in6_addr addr_any = {};
>
> +#if IS_ENABLED(CONFIG_IPV6)
> if (sk->sk_family == AF_INET6)
> - hash = ipv6_portaddr_hash(net, &addr_any, port);
> + hash = ipv6_portaddr_hash(net, &in6addr_any, port);
> else
> #endif
> hash = ipv4_portaddr_hash(net, 0, port);
Thanks,
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 net-next 1/2] ipv6: Remove in6addr_any alternatives.
2023-03-27 23:54 ` [PATCH v2 net-next 1/2] ipv6: Remove in6addr_any alternatives Kuniyuki Iwashima
2023-03-28 6:27 ` Mark Bloch
@ 2023-03-28 14:32 ` David Ahern
1 sibling, 0 replies; 8+ messages in thread
From: David Ahern @ 2023-03-28 14:32 UTC (permalink / raw)
To: Kuniyuki Iwashima, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Kuniyuki Iwashima, netdev
On 3/27/23 5:54 PM, Kuniyuki Iwashima wrote:
> 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: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
> .../net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 5 ++---
> include/net/ip6_fib.h | 9 +++------
> include/trace/events/fib.h | 5 ++---
> include/trace/events/fib6.h | 5 +----
> net/ethtool/ioctl.c | 10 +++++-----
> net/ipv4/inet_hashtables.c | 11 ++++-------
> 6 files changed, 17 insertions(+), 28 deletions(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 net-next 2/2] 6lowpan: Remove redundant initialisation.
2023-03-28 6:27 ` Mark Bloch
@ 2023-03-28 19:00 ` Kuniyuki Iwashima
0 siblings, 0 replies; 8+ messages in thread
From: Kuniyuki Iwashima @ 2023-03-28 19:00 UTC (permalink / raw)
To: mbloch; +Cc: davem, dsahern, edumazet, kuba, kuni1840, kuniyu, netdev, pabeni
From: Mark Bloch <mbloch@nvidia.com>
Date: Tue, 28 Mar 2023 09:27:43 +0300
> On 28/03/2023 2:54, Kuniyuki Iwashima wrote:
> > We'll call memset(&tmp, 0, sizeof(tmp)) later.
>
> Why not just remove the first memset() then?
The same pattern (memset(), init, compare) is repeated twice, and
I thought it's cleaner. I don't have no strong preference though.
Also, we need not init it if we hit 'goto out' in the first switch.
---8<---
static u8 lowpan_compress_ctx_addr(u8 **hc_ptr, const struct net_device *dev,
const struct in6_addr *ipaddr,
const struct lowpan_iphc_ctx *ctx,
const unsigned char *lladdr, bool sam)
{
struct in6_addr tmp;
u8 dam;
switch (lowpan_dev(dev)->lltype) {
case LOWPAN_LLTYPE_IEEE802154:
if (lowpan_iphc_compress_ctx_802154_lladdr(ipaddr, ctx,
lladdr)) {
dam = LOWPAN_IPHC_DAM_11;
goto out;
}
break;
default:
if (lowpan_iphc_addr_equal(dev, ctx, ipaddr, lladdr)) {
dam = LOWPAN_IPHC_DAM_11;
goto out;
}
break;
}
memset(&tmp, 0, sizeof(tmp));
/* check for SAM/DAM = 10 */
tmp.s6_addr[11] = 0xFF;
tmp.s6_addr[12] = 0xFE;
memcpy(&tmp.s6_addr[14], &ipaddr->s6_addr[14], 2);
/* context information are always used */
ipv6_addr_prefix_copy(&tmp, &ctx->pfx, ctx->plen);
if (ipv6_addr_equal(&tmp, ipaddr)) {
lowpan_push_hc_data(hc_ptr, &ipaddr->s6_addr[14], 2);
dam = LOWPAN_IPHC_DAM_10;
goto out;
}
memset(&tmp, 0, sizeof(tmp));
/* check for SAM/DAM = 01, should always match */
memcpy(&tmp.s6_addr[8], &ipaddr->s6_addr[8], 8);
/* context information are always used */
ipv6_addr_prefix_copy(&tmp, &ctx->pfx, ctx->plen);
if (ipv6_addr_equal(&tmp, ipaddr)) {
lowpan_push_hc_data(hc_ptr, &ipaddr->s6_addr[8], 8);
dam = LOWPAN_IPHC_DAM_01;
goto out;
}
...
}
---8<---
>
> Mark
>
> >
> > Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> > ---
> > net/6lowpan/iphc.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
> > index 52fad5dad9f7..e116d308a8df 100644
> > --- a/net/6lowpan/iphc.c
> > +++ b/net/6lowpan/iphc.c
> > @@ -848,7 +848,7 @@ static u8 lowpan_compress_ctx_addr(u8 **hc_ptr, const struct net_device *dev,
> > const struct lowpan_iphc_ctx *ctx,
> > const unsigned char *lladdr, bool sam)
> > {
> > - struct in6_addr tmp = {};
> > + struct in6_addr tmp;
> > u8 dam;
> >
> > switch (lowpan_dev(dev)->lltype) {
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 net-next 0/2] ipv6: Random cleanup for in6addr_any.
2023-03-27 23:54 [PATCH v2 net-next 0/2] ipv6: Random cleanup for in6addr_any Kuniyuki Iwashima
2023-03-27 23:54 ` [PATCH v2 net-next 1/2] ipv6: Remove in6addr_any alternatives Kuniyuki Iwashima
2023-03-27 23:54 ` [PATCH v2 net-next 2/2] 6lowpan: Remove redundant initialisation Kuniyuki Iwashima
@ 2023-03-29 8:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-29 8:00 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: davem, edumazet, kuba, pabeni, dsahern, kuni1840, netdev
Hello:
This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Mon, 27 Mar 2023 16:54:53 -0700 you wrote:
> 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)
>
> [...]
Here is the summary with links:
- [v2,net-next,1/2] ipv6: Remove in6addr_any alternatives.
https://git.kernel.org/netdev/net-next/c/8cdc3223e78c
- [v2,net-next,2/2] 6lowpan: Remove redundant initialisation.
https://git.kernel.org/netdev/net-next/c/be689c719eb6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-03-29 8:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 23:54 [PATCH v2 net-next 0/2] ipv6: Random cleanup for in6addr_any Kuniyuki Iwashima
2023-03-27 23:54 ` [PATCH v2 net-next 1/2] ipv6: Remove in6addr_any alternatives Kuniyuki Iwashima
2023-03-28 6:27 ` Mark Bloch
2023-03-28 14:32 ` David Ahern
2023-03-27 23:54 ` [PATCH v2 net-next 2/2] 6lowpan: Remove redundant initialisation Kuniyuki Iwashima
2023-03-28 6:27 ` Mark Bloch
2023-03-28 19:00 ` Kuniyuki Iwashima
2023-03-29 8:00 ` [PATCH v2 net-next 0/2] ipv6: Random cleanup for in6addr_any patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.