Skip to content

Commit

Permalink
Revert "tcp: defer shutdown(SEND_SHUTDOWN) for TCP_SYN_RECV sockets"
Browse files Browse the repository at this point in the history
This reverts commit 426be5e.

Dan writes:

> This backport is wrong. In the code Colin was patching, then tskb
> couldn't be NULL but in the 4.14 it can. This patch was pulled in to
> make a different fix easier to backport. See my back port attached.

Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Vegard Nossum <[email protected]>
  • Loading branch information
vegard committed Aug 8, 2024
1 parent 037ba8c commit 378cd84
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
4 changes: 2 additions & 2 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ void tcp_shutdown(struct sock *sk, int how)
/* If we've already sent a FIN, or it's a closed state, skip this. */
if ((1 << sk->sk_state) &
(TCPF_ESTABLISHED | TCPF_SYN_SENT |
TCPF_CLOSE_WAIT)) {
TCPF_SYN_RECV | TCPF_CLOSE_WAIT)) {
/* Clear out any half completed packets. FIN if needed. */
if (tcp_close_state(sk))
tcp_send_fin(sk);
Expand Down Expand Up @@ -2202,7 +2202,7 @@ void tcp_close(struct sock *sk, long timeout)
* machine. State transitions:
*
* TCP_ESTABLISHED -> TCP_FIN_WAIT1
* TCP_SYN_RECV -> TCP_FIN_WAIT1 (it is difficult)
* TCP_SYN_RECV -> TCP_FIN_WAIT1 (forget it, it's impossible)
* TCP_CLOSE_WAIT -> TCP_LAST_ACK
*
* are legal only when FIN has been sent (i.e. in window),
Expand Down
2 changes: 0 additions & 2 deletions net/ipv4/tcp_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -6109,8 +6109,6 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)

tcp_initialize_rcv_mss(sk);
tcp_fast_path_on(tp);
if (sk->sk_shutdown & SEND_SHUTDOWN)
tcp_shutdown(sk, SEND_SHUTDOWN);
break;

case TCP_FIN_WAIT1: {
Expand Down
4 changes: 1 addition & 3 deletions net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -3141,9 +3141,7 @@ void tcp_send_fin(struct sock *sk)
return;
}
} else {
skb = alloc_skb_fclone(MAX_TCP_HEADER,
sk_gfp_mask(sk, GFP_ATOMIC |
__GFP_NOWARN));
skb = alloc_skb_fclone(MAX_TCP_HEADER, sk->sk_allocation);
if (unlikely(!skb))
return;

Expand Down

0 comments on commit 378cd84

Please sign in to comment.