From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: David Ahern <dsahern@kernel.org>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next 07/14] ipv6: lockless IPV6_MULTICAST_ALL implementation
Date: Tue, 12 Sep 2023 16:02:05 +0000 [thread overview]
Message-ID: <20230912160212.3467976-8-edumazet@google.com> (raw)
In-Reply-To: <20230912160212.3467976-1-edumazet@google.com>
Move np->mc_all to an atomic flags to fix data-races.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/linux/ipv6.h | 1 -
include/net/inet_sock.h | 1 +
net/ipv6/af_inet6.c | 2 +-
net/ipv6/ipv6_sockglue.c | 14 ++++++--------
net/ipv6/mcast.c | 2 +-
5 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 0d2b0a1b2daeaee51a03624adab5a385cc852cc7..d88e91b7f0a319a816488025ef213c4fb90ed359 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -255,7 +255,6 @@ struct ipv6_pinfo {
dontfrag:1,
autoflowlabel:1,
autoflowlabel_set:1,
- mc_all:1,
rtalert_isolate:1;
__u8 min_hopcount;
__u8 tclass;
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 8cf1f7b442348bef83cc3d9648521a01667efae7..97e70a97dae888e6ab93c6446f4f3ba58cd8583e 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -270,6 +270,7 @@ enum {
INET_FLAGS_DEFER_CONNECT = 19,
INET_FLAGS_MC6_LOOP = 20,
INET_FLAGS_RECVERR6_RFC4884 = 21,
+ INET_FLAGS_MC6_ALL = 22,
};
/* cmsg flags for inet */
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index bbd4aa1b96d09d346c521dab2194045123e7a5a6..372fb7b9112c8dfed09b6ddfdb37016a1a668494 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -218,7 +218,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
np->hop_limit = -1;
np->mcast_hops = IPV6_DEFAULT_MCASTHOPS;
inet6_set_bit(MC6_LOOP, sk);
- np->mc_all = 1;
+ inet6_set_bit(MC6_ALL, sk);
np->pmtudisc = IPV6_PMTUDISC_WANT;
np->repflow = net->ipv6.sysctl.flowlabel_reflect & FLOWLABEL_REFLECT_ESTABLISHED;
sk->sk_ipv6only = net->ipv6.sysctl.bindv6only;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index b65e73ac2ccdee79aa293948d3ba9853966e1e2d..7a181831f226c67813446145f8f58fa58908e3ae 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -469,6 +469,11 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
return -EINVAL;
inet6_assign_bit(RECVERR6_RFC4884, sk, valbool);
return 0;
+ case IPV6_MULTICAST_ALL:
+ if (optlen < sizeof(int))
+ return -EINVAL;
+ inet6_assign_bit(MC6_ALL, sk, valbool);
+ return 0;
}
if (needs_rtnl)
rtnl_lock();
@@ -890,13 +895,6 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
retv = ipv6_sock_ac_drop(sk, mreq.ipv6mr_ifindex, &mreq.ipv6mr_acaddr);
break;
}
- case IPV6_MULTICAST_ALL:
- if (optlen < sizeof(int))
- goto e_inval;
- np->mc_all = valbool;
- retv = 0;
- break;
-
case MCAST_JOIN_GROUP:
case MCAST_LEAVE_GROUP:
if (in_compat_syscall())
@@ -1372,7 +1370,7 @@ int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
break;
case IPV6_MULTICAST_ALL:
- val = np->mc_all;
+ val = inet6_test_bit(MC6_ALL, sk);
break;
case IPV6_UNICAST_IF:
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 6a33a50687bcf7201e75574f03e619fe89636068..483f797ae44d538009184b5e53ad7755d73bab4a 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -642,7 +642,7 @@ bool inet6_mc_check(const struct sock *sk, const struct in6_addr *mc_addr,
}
if (!mc) {
rcu_read_unlock();
- return np->mc_all;
+ return inet6_test_bit(MC6_ALL, sk);
}
psl = rcu_dereference(mc->sflist);
if (!psl) {
--
2.42.0.283.g2d96d420d3-goog
next prev parent reply other threads:[~2023-09-12 16:02 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 16:01 [PATCH net-next 00/14] ipv6: round of data-races fixes Eric Dumazet
2023-09-12 16:01 ` [PATCH net-next 01/14] ipv6: lockless IPV6_UNICAST_HOPS implementation Eric Dumazet
2023-09-14 14:51 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 02/14] ipv6: lockless IPV6_MULTICAST_LOOP implementation Eric Dumazet
2023-09-14 14:54 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 03/14] ipv6: lockless IPV6_MULTICAST_HOPS implementation Eric Dumazet
2023-09-14 14:55 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 04/14] ipv6: lockless IPV6_MTU implementation Eric Dumazet
2023-09-14 14:58 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 05/14] ipv6: lockless IPV6_MINHOPCOUNT implementation Eric Dumazet
2023-09-14 15:01 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 06/14] ipv6: lockless IPV6_RECVERR_RFC4884 implementation Eric Dumazet
2023-09-14 15:02 ` David Ahern
2023-09-12 16:02 ` Eric Dumazet [this message]
2023-09-14 15:03 ` [PATCH net-next 07/14] ipv6: lockless IPV6_MULTICAST_ALL implementation David Ahern
2023-09-12 16:02 ` [PATCH net-next 08/14] ipv6: lockless IPV6_AUTOFLOWLABEL implementation Eric Dumazet
2023-09-14 15:04 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 09/14] ipv6: lockless IPV6_DONTFRAG implementation Eric Dumazet
2023-09-14 15:05 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 10/14] ipv6: lockless IPV6_RECVERR implemetation Eric Dumazet
2023-09-14 15:06 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 11/14] ipv6: move np->repflow to atomic flags Eric Dumazet
2023-09-14 15:07 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 12/14] ipv6: lockless IPV6_ROUTER_ALERT_ISOLATE implementation Eric Dumazet
2023-09-14 15:08 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 13/14] ipv6: lockless IPV6_MTU_DISCOVER implementation Eric Dumazet
2023-09-14 15:10 ` David Ahern
2023-09-12 16:02 ` [PATCH net-next 14/14] ipv6: lockless IPV6_FLOWINFO_SEND implementation Eric Dumazet
2023-09-14 15:11 ` David Ahern
2023-09-14 10:25 ` [PATCH net-next 00/14] ipv6: round of data-races fixes Simon Horman
2023-09-15 9:40 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230912160212.3467976-8-edumazet@google.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).