From 0a3374ad36a7f217089e0a090645d02061860a36 Mon Sep 17 00:00:00 2001 From: Flavio Leitner Date: Mon, 26 Apr 2010 18:33:27 +0000 Subject: [PATCH] --- yaml --- r: 194539 b: refs/heads/master c: 6c37e5de456987f5bc80879afde05aa120784095 h: refs/heads/master i: 194537: 3f8135a3fb4a4ee926133658ed2301db113e3455 194535: 6d721364e4f7e3c3d3f07184cb7f88727db68071 v: v3 --- [refs] | 2 +- trunk/include/net/tcp.h | 8 ++++++++ trunk/net/ipv4/tcp.c | 2 +- trunk/net/ipv4/tcp_timer.c | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index ccbc0e11ec57..d245e3b9996a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: dcdca2c49bb6328bbc7cd8d73434c308b5dd0df2 +refs/heads/master: 6c37e5de456987f5bc80879afde05aa120784095 diff --git a/trunk/include/net/tcp.h b/trunk/include/net/tcp.h index 3f87fd87bc9c..fb5c66b2ab81 100644 --- a/trunk/include/net/tcp.h +++ b/trunk/include/net/tcp.h @@ -1033,6 +1033,14 @@ static inline int keepalive_probes(const struct tcp_sock *tp) return tp->keepalive_probes ? : sysctl_tcp_keepalive_probes; } +static inline u32 keepalive_time_elapsed(const struct tcp_sock *tp) +{ + const struct inet_connection_sock *icsk = &tp->inet_conn; + + return min_t(u32, tcp_time_stamp - icsk->icsk_ack.lrcvtime, + tcp_time_stamp - tp->rcv_tstamp); +} + static inline int tcp_fin_time(const struct sock *sk) { int fin_timeout = tcp_sk(sk)->linger2 ? : sysctl_tcp_fin_timeout; diff --git a/trunk/net/ipv4/tcp.c b/trunk/net/ipv4/tcp.c index 6689c61cab47..8ce29747ad9b 100644 --- a/trunk/net/ipv4/tcp.c +++ b/trunk/net/ipv4/tcp.c @@ -2298,7 +2298,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, if (sock_flag(sk, SOCK_KEEPOPEN) && !((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) { - __u32 elapsed = tcp_time_stamp - tp->rcv_tstamp; + u32 elapsed = keepalive_time_elapsed(tp); if (tp->keepalive_time > elapsed) elapsed = tp->keepalive_time - elapsed; else diff --git a/trunk/net/ipv4/tcp_timer.c b/trunk/net/ipv4/tcp_timer.c index c732be00606b..440a5c6004f6 100644 --- a/trunk/net/ipv4/tcp_timer.c +++ b/trunk/net/ipv4/tcp_timer.c @@ -517,7 +517,7 @@ static void tcp_keepalive_timer (unsigned long data) struct sock *sk = (struct sock *) data; struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); - __u32 elapsed; + u32 elapsed; /* Only process if socket is not in use. */ bh_lock_sock(sk); @@ -554,7 +554,7 @@ static void tcp_keepalive_timer (unsigned long data) if (tp->packets_out || tcp_send_head(sk)) goto resched; - elapsed = tcp_time_stamp - tp->rcv_tstamp; + elapsed = keepalive_time_elapsed(tp); if (elapsed >= keepalive_time_when(tp)) { if (icsk->icsk_probes_out >= keepalive_probes(tp)) {