tcp_timer.c (58169ec9c40309541509181e068177eab72e6caa) tcp_timer.c (5691276b39daf90294c6a81fb6d62d667f634c92)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * INET An implementation of the TCP/IP protocol suite for the LINUX
4 * operating system. INET is implemented using the BSD Socket
5 * interface as the means of communication with the user level.
6 *
7 * Implementation of the Transmission Control Protocol(TCP).
8 *

--- 8 unchanged lines hidden (view full) ---

17 * Matthew Dillon, <dillon@apollo.west.oic.com>
18 * Arnt Gulbrandsen, <agulbra@nvg.unit.no>
19 * Jorge Cwik, <jorge@laser.satlink.net>
20 */
21
22#include <linux/module.h>
23#include <linux/gfp.h>
24#include <net/tcp.h>
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * INET An implementation of the TCP/IP protocol suite for the LINUX
4 * operating system. INET is implemented using the BSD Socket
5 * interface as the means of communication with the user level.
6 *
7 * Implementation of the Transmission Control Protocol(TCP).
8 *

--- 8 unchanged lines hidden (view full) ---

17 * Matthew Dillon, <dillon@apollo.west.oic.com>
18 * Arnt Gulbrandsen, <agulbra@nvg.unit.no>
19 * Jorge Cwik, <jorge@laser.satlink.net>
20 */
21
22#include <linux/module.h>
23#include <linux/gfp.h>
24#include <net/tcp.h>
25#include <net/rstreason.h>
25
26static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk)
27{
28 const struct inet_connection_sock *icsk = inet_csk(sk);
29 const struct tcp_sock *tp = tcp_sk(sk);
30 u32 elapsed, user_timeout;
31 s32 remaining;
32

--- 89 unchanged lines hidden (view full) ---

122 if (tcp_check_oom(sk, shift)) {
123 /* Catch exceptional cases, when connection requires reset.
124 * 1. Last segment was sent recently. */
125 if ((s32)(tcp_jiffies32 - tp->lsndtime) <= TCP_TIMEWAIT_LEN ||
126 /* 2. Window is closed. */
127 (!tp->snd_wnd && !tp->packets_out))
128 do_reset = true;
129 if (do_reset)
26
27static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk)
28{
29 const struct inet_connection_sock *icsk = inet_csk(sk);
30 const struct tcp_sock *tp = tcp_sk(sk);
31 u32 elapsed, user_timeout;
32 s32 remaining;
33

--- 89 unchanged lines hidden (view full) ---

123 if (tcp_check_oom(sk, shift)) {
124 /* Catch exceptional cases, when connection requires reset.
125 * 1. Last segment was sent recently. */
126 if ((s32)(tcp_jiffies32 - tp->lsndtime) <= TCP_TIMEWAIT_LEN ||
127 /* 2. Window is closed. */
128 (!tp->snd_wnd && !tp->packets_out))
129 do_reset = true;
130 if (do_reset)
130 tcp_send_active_reset(sk, GFP_ATOMIC);
131 tcp_send_active_reset(sk, GFP_ATOMIC,
132 SK_RST_REASON_NOT_SPECIFIED);
131 tcp_done(sk);
132 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY);
133 return 1;
134 }
135
136 if (!check_net(sock_net(sk))) {
137 /* Not possible to send reset; just close */
138 tcp_done(sk);

--- 624 unchanged lines hidden (view full) ---

763 if (READ_ONCE(tp->linger2) >= 0) {
764 const int tmo = tcp_fin_time(sk) - TCP_TIMEWAIT_LEN;
765
766 if (tmo > 0) {
767 tcp_time_wait(sk, TCP_FIN_WAIT2, tmo);
768 goto out;
769 }
770 }
133 tcp_done(sk);
134 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY);
135 return 1;
136 }
137
138 if (!check_net(sock_net(sk))) {
139 /* Not possible to send reset; just close */
140 tcp_done(sk);

--- 624 unchanged lines hidden (view full) ---

765 if (READ_ONCE(tp->linger2) >= 0) {
766 const int tmo = tcp_fin_time(sk) - TCP_TIMEWAIT_LEN;
767
768 if (tmo > 0) {
769 tcp_time_wait(sk, TCP_FIN_WAIT2, tmo);
770 goto out;
771 }
772 }
771 tcp_send_active_reset(sk, GFP_ATOMIC);
773 tcp_send_active_reset(sk, GFP_ATOMIC, SK_RST_REASON_NOT_SPECIFIED);
772 goto death;
773 }
774
775 if (!sock_flag(sk, SOCK_KEEPOPEN) ||
776 ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)))
777 goto out;
778
779 elapsed = keepalive_time_when(tp);

--- 10 unchanged lines hidden (view full) ---

790 /* If the TCP_USER_TIMEOUT option is enabled, use that
791 * to determine when to timeout instead.
792 */
793 if ((user_timeout != 0 &&
794 elapsed >= msecs_to_jiffies(user_timeout) &&
795 icsk->icsk_probes_out > 0) ||
796 (user_timeout == 0 &&
797 icsk->icsk_probes_out >= keepalive_probes(tp))) {
774 goto death;
775 }
776
777 if (!sock_flag(sk, SOCK_KEEPOPEN) ||
778 ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)))
779 goto out;
780
781 elapsed = keepalive_time_when(tp);

--- 10 unchanged lines hidden (view full) ---

792 /* If the TCP_USER_TIMEOUT option is enabled, use that
793 * to determine when to timeout instead.
794 */
795 if ((user_timeout != 0 &&
796 elapsed >= msecs_to_jiffies(user_timeout) &&
797 icsk->icsk_probes_out > 0) ||
798 (user_timeout == 0 &&
799 icsk->icsk_probes_out >= keepalive_probes(tp))) {
798 tcp_send_active_reset(sk, GFP_ATOMIC);
800 tcp_send_active_reset(sk, GFP_ATOMIC,
801 SK_RST_REASON_NOT_SPECIFIED);
799 tcp_write_err(sk);
800 goto out;
801 }
802 if (tcp_write_wakeup(sk, LINUX_MIB_TCPKEEPALIVE) <= 0) {
803 icsk->icsk_probes_out++;
804 elapsed = keepalive_intvl_when(tp);
805 } else {
806 /* If keepalive was lost due to local congestion,

--- 60 unchanged lines hidden ---
802 tcp_write_err(sk);
803 goto out;
804 }
805 if (tcp_write_wakeup(sk, LINUX_MIB_TCPKEEPALIVE) <= 0) {
806 icsk->icsk_probes_out++;
807 elapsed = keepalive_intvl_when(tp);
808 } else {
809 /* If keepalive was lost due to local congestion,

--- 60 unchanged lines hidden ---