Commit df19a626 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

tcp: keepalive cleanups

Introduce keepalive_probes(tp) helper, and use it, like 
keepalive_time_when(tp) and keepalive_intvl_when(tp)
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5e9b2dbf
...@@ -1007,6 +1007,11 @@ static inline int keepalive_time_when(const struct tcp_sock *tp) ...@@ -1007,6 +1007,11 @@ static inline int keepalive_time_when(const struct tcp_sock *tp)
return tp->keepalive_time ? : sysctl_tcp_keepalive_time; return tp->keepalive_time ? : sysctl_tcp_keepalive_time;
} }
static inline int keepalive_probes(const struct tcp_sock *tp)
{
return tp->keepalive_probes ? : sysctl_tcp_keepalive_probes;
}
static inline int tcp_fin_time(const struct sock *sk) static inline int tcp_fin_time(const struct sock *sk)
{ {
int fin_timeout = tcp_sk(sk)->linger2 ? : sysctl_tcp_fin_timeout; int fin_timeout = tcp_sk(sk)->linger2 ? : sysctl_tcp_fin_timeout;
......
...@@ -2336,13 +2336,13 @@ static int do_tcp_getsockopt(struct sock *sk, int level, ...@@ -2336,13 +2336,13 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
val = !!(tp->nonagle&TCP_NAGLE_CORK); val = !!(tp->nonagle&TCP_NAGLE_CORK);
break; break;
case TCP_KEEPIDLE: case TCP_KEEPIDLE:
val = (tp->keepalive_time ? : sysctl_tcp_keepalive_time) / HZ; val = keepalive_time_when(tp) / HZ;
break; break;
case TCP_KEEPINTVL: case TCP_KEEPINTVL:
val = (tp->keepalive_intvl ? : sysctl_tcp_keepalive_intvl) / HZ; val = keepalive_intvl_when(tp) / HZ;
break; break;
case TCP_KEEPCNT: case TCP_KEEPCNT:
val = tp->keepalive_probes ? : sysctl_tcp_keepalive_probes; val = keepalive_probes(tp);
break; break;
case TCP_SYNCNT: case TCP_SYNCNT:
val = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries; val = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries;
......
...@@ -499,8 +499,7 @@ static void tcp_keepalive_timer (unsigned long data) ...@@ -499,8 +499,7 @@ static void tcp_keepalive_timer (unsigned long data)
elapsed = tcp_time_stamp - tp->rcv_tstamp; elapsed = tcp_time_stamp - tp->rcv_tstamp;
if (elapsed >= keepalive_time_when(tp)) { if (elapsed >= keepalive_time_when(tp)) {
if ((!tp->keepalive_probes && icsk->icsk_probes_out >= sysctl_tcp_keepalive_probes) || if (icsk->icsk_probes_out >= keepalive_probes(tp)) {
(tp->keepalive_probes && icsk->icsk_probes_out >= tp->keepalive_probes)) {
tcp_send_active_reset(sk, GFP_ATOMIC); tcp_send_active_reset(sk, GFP_ATOMIC);
tcp_write_err(sk); tcp_write_err(sk);
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment