Skip to content

Commit 5152fc7

Browse files
Damian Lukowskidavem330
authored andcommitted
RTO connection timeout: coding style fixes and comments
This patch affects the retransmits_timed_out() function. Changes: 1) Variables have more meaningful names 2) retransmits_timed_out() has an introductionary comment. 3) Small coding style changes. Signed-off-by: Damian Lukowski <damian@tvk.rwth-aachen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 72c6068 commit 5152fc7

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

include/net/tcp.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,22 +1252,27 @@ static inline struct sk_buff *tcp_write_queue_prev(struct sock *sk, struct sk_bu
12521252
#define tcp_for_write_queue_from_safe(skb, tmp, sk) \
12531253
skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp)
12541254

1255+
/* This function calculates a "timeout" which is equivalent to the timeout of a
1256+
* TCP connection after "boundary" unsucessful, exponentially backed-off
1257+
* retransmissions with an initial RTO of TCP_RTO_MIN.
1258+
*/
12551259
static inline bool retransmits_timed_out(const struct sock *sk,
12561260
unsigned int boundary)
12571261
{
1258-
int limit, K;
1262+
unsigned int timeout, linear_backoff_thresh;
1263+
12591264
if (!inet_csk(sk)->icsk_retransmits)
12601265
return false;
12611266

1262-
K = ilog2(TCP_RTO_MAX/TCP_RTO_MIN);
1267+
linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN);
12631268

1264-
if (boundary <= K)
1265-
limit = ((2 << boundary) - 1) * TCP_RTO_MIN;
1269+
if (boundary <= linear_backoff_thresh)
1270+
timeout = ((2 << boundary) - 1) * TCP_RTO_MIN;
12661271
else
1267-
limit = ((2 << K) - 1) * TCP_RTO_MIN +
1268-
(boundary - K) * TCP_RTO_MAX;
1272+
timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN +
1273+
(boundary - linear_backoff_thresh) * TCP_RTO_MAX;
12691274

1270-
return (tcp_time_stamp - tcp_sk(sk)->retrans_stamp) >= limit;
1275+
return (tcp_time_stamp - tcp_sk(sk)->retrans_stamp) >= timeout;
12711276
}
12721277

12731278
static inline struct sk_buff *tcp_send_head(struct sock *sk)

0 commit comments

Comments
 (0)