mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-17 02:15:57 +00:00
ipv6: lockless IPV6_MULTICAST_ALL implementation
Move np->mc_all to an atomic flags to fix data-races. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
dcae74622c
commit
6559c0ff3b
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -218,7 +218,7 @@ lookup_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;
|
||||
|
@ -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 @@ done:
|
||||
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:
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user