inet: move inet->recverr to inet->inet_flags
IP_RECVERR socket option can now be set/get without locking the socket. This patch potentially avoid data-races around inet->recverr. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
b4d84bce4c
commit
6b5f43ea08
@@ -203,8 +203,9 @@ static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)
|
||||
struct inet_sock *inet = inet_sk(sk);
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
int err = 0;
|
||||
int harderr = 0;
|
||||
bool recverr;
|
||||
int err = 0;
|
||||
|
||||
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED)
|
||||
ipv4_sk_update_pmtu(skb, sk, info);
|
||||
@@ -218,7 +219,8 @@ static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)
|
||||
2. Socket is connected (otherwise the error indication
|
||||
is useless without ip_recverr and error is hard.
|
||||
*/
|
||||
if (!inet->recverr && sk->sk_state != TCP_ESTABLISHED)
|
||||
recverr = inet_test_bit(RECVERR, sk);
|
||||
if (!recverr && sk->sk_state != TCP_ESTABLISHED)
|
||||
return;
|
||||
|
||||
switch (type) {
|
||||
@@ -245,7 +247,7 @@ static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)
|
||||
}
|
||||
}
|
||||
|
||||
if (inet->recverr) {
|
||||
if (recverr) {
|
||||
const struct iphdr *iph = (const struct iphdr *)skb->data;
|
||||
u8 *payload = skb->data + (iph->ihl << 2);
|
||||
|
||||
@@ -254,7 +256,7 @@ static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)
|
||||
ip_icmp_error(sk, skb, err, 0, info, payload);
|
||||
}
|
||||
|
||||
if (inet->recverr || harderr) {
|
||||
if (recverr || harderr) {
|
||||
sk->sk_err = err;
|
||||
sk_error_report(sk);
|
||||
}
|
||||
@@ -413,7 +415,7 @@ error_free:
|
||||
kfree_skb(skb);
|
||||
error:
|
||||
IP_INC_STATS(net, IPSTATS_MIB_OUTDISCARDS);
|
||||
if (err == -ENOBUFS && !inet->recverr)
|
||||
if (err == -ENOBUFS && !inet_test_bit(RECVERR, sk))
|
||||
err = 0;
|
||||
return err;
|
||||
}
|
||||
@@ -645,7 +647,7 @@ back_from_confirm:
|
||||
ip_flush_pending_frames(sk);
|
||||
else if (!(msg->msg_flags & MSG_MORE)) {
|
||||
err = ip_push_pending_frames(sk, &fl4);
|
||||
if (err == -ENOBUFS && !inet->recverr)
|
||||
if (err == -ENOBUFS && !inet_test_bit(RECVERR, sk))
|
||||
err = 0;
|
||||
}
|
||||
release_sock(sk);
|
||||
|
||||
Reference in New Issue
Block a user