mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
ipv6: lockless IPV6_RECVERR_RFC4884 implementation
Move np->recverr_rfc4884 to an atomic flag 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
273784d3c5
commit
dcae74622c
@ -256,7 +256,6 @@ struct ipv6_pinfo {
|
||||
autoflowlabel:1,
|
||||
autoflowlabel_set:1,
|
||||
mc_all:1,
|
||||
recverr_rfc4884:1,
|
||||
rtalert_isolate:1;
|
||||
__u8 min_hopcount;
|
||||
__u8 tclass;
|
||||
|
@ -269,6 +269,7 @@ enum {
|
||||
INET_FLAGS_BIND_ADDRESS_NO_PORT = 18,
|
||||
INET_FLAGS_DEFER_CONNECT = 19,
|
||||
INET_FLAGS_MC6_LOOP = 20,
|
||||
INET_FLAGS_RECVERR6_RFC4884 = 21,
|
||||
};
|
||||
|
||||
/* cmsg flags for inet */
|
||||
|
@ -332,7 +332,7 @@ void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
|
||||
|
||||
__skb_pull(skb, payload - skb->data);
|
||||
|
||||
if (inet6_sk(sk)->recverr_rfc4884)
|
||||
if (inet6_test_bit(RECVERR6_RFC4884, sk))
|
||||
ipv6_icmp_error_rfc4884(skb, &serr->ee.ee_rfc4884);
|
||||
|
||||
skb_reset_transport_header(skb);
|
||||
|
@ -462,6 +462,13 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
|
||||
*/
|
||||
WRITE_ONCE(np->min_hopcount, val);
|
||||
return 0;
|
||||
case IPV6_RECVERR_RFC4884:
|
||||
if (optlen < sizeof(int))
|
||||
return -EINVAL;
|
||||
if (val < 0 || val > 1)
|
||||
return -EINVAL;
|
||||
inet6_assign_bit(RECVERR6_RFC4884, sk, valbool);
|
||||
return 0;
|
||||
}
|
||||
if (needs_rtnl)
|
||||
rtnl_lock();
|
||||
@ -974,14 +981,6 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
|
||||
np->rxopt.bits.recvfragsize = valbool;
|
||||
retv = 0;
|
||||
break;
|
||||
case IPV6_RECVERR_RFC4884:
|
||||
if (optlen < sizeof(int))
|
||||
goto e_inval;
|
||||
if (val < 0 || val > 1)
|
||||
goto e_inval;
|
||||
np->recverr_rfc4884 = valbool;
|
||||
retv = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
unlock:
|
||||
@ -1462,7 +1461,7 @@ int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
|
||||
break;
|
||||
|
||||
case IPV6_RECVERR_RFC4884:
|
||||
val = np->recverr_rfc4884;
|
||||
val = inet6_test_bit(RECVERR6_RFC4884, sk);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user