Skip to content

Commit

Permalink
tcp: tracepoint: only call trace_tcp_send_reset with full socket
Browse files Browse the repository at this point in the history
tracepoint tcp_send_reset requires a full socket to work. However, it
may be called when in TCP_TIME_WAIT:

        case TCP_TW_RST:
                tcp_v6_send_reset(sk, skb);
                inet_twsk_deschedule_put(inet_twsk(sk));
                goto discard_it;

To avoid this problem, this patch checks the socket with sk_fullsock()
before calling trace_tcp_send_reset().

Fixes: c24b14c ("tcp: add tracepoint trace_tcp_send_reset")
Signed-off-by: Song Liu <[email protected]>
Reviewed-by: Lawrence Brakmo <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
liu-song-6 authored and davem330 committed Feb 8, 2018
1 parent 043e337 commit 5c487bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion net/ipv4/tcp_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb)
*/
if (sk) {
arg.bound_dev_if = sk->sk_bound_dev_if;
trace_tcp_send_reset(sk, skb);
if (sk_fullsock(sk))
trace_tcp_send_reset(sk, skb);
}

BUILD_BUG_ON(offsetof(struct sock, sk_bound_dev_if) !=
Expand Down
3 changes: 2 additions & 1 deletion net/ipv6/tcp_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,8 @@ static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb)

if (sk) {
oif = sk->sk_bound_dev_if;
trace_tcp_send_reset(sk, skb);
if (sk_fullsock(sk))
trace_tcp_send_reset(sk, skb);
}

tcp_v6_send_response(sk, skb, seq, ack_seq, 0, 0, 0, oif, key, 1, 0, 0);
Expand Down

0 comments on commit 5c487bb

Please sign in to comment.