aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ipv4/tcp_westwood.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/net/ipv4/tcp_westwood.c b/net/ipv4/tcp_westwood.c
index edf2ee19a8ba..4247da1384bf 100644
--- a/net/ipv4/tcp_westwood.c
+++ b/net/ipv4/tcp_westwood.c
@@ -40,6 +40,7 @@ struct westwood {
40 u32 rtt; 40 u32 rtt;
41 u32 rtt_min; /* minimum observed RTT */ 41 u32 rtt_min; /* minimum observed RTT */
42 u8 first_ack; /* flag which infers that this is the first ack */ 42 u8 first_ack; /* flag which infers that this is the first ack */
43 u8 reset_rtt_min; /* Reset RTT min to next RTT sample*/
43}; 44};
44 45
45 46
@@ -67,6 +68,7 @@ static void tcp_westwood_init(struct sock *sk)
67 w->bw_est = 0; 68 w->bw_est = 0;
68 w->accounted = 0; 69 w->accounted = 0;
69 w->cumul_ack = 0; 70 w->cumul_ack = 0;
71 w->reset_rtt_min = 1;
70 w->rtt_min = w->rtt = TCP_WESTWOOD_INIT_RTT; 72 w->rtt_min = w->rtt = TCP_WESTWOOD_INIT_RTT;
71 w->rtt_win_sx = tcp_time_stamp; 73 w->rtt_win_sx = tcp_time_stamp;
72 w->snd_una = tcp_sk(sk)->snd_una; 74 w->snd_una = tcp_sk(sk)->snd_una;
@@ -142,6 +144,16 @@ static void westwood_update_window(struct sock *sk)
142 } 144 }
143} 145}
144 146
147static inline void update_rtt_min(struct westwood *w)
148{
149 if (w->reset_rtt_min) {
150 w->rtt_min = w->rtt;
151 w->reset_rtt_min = 0;
152 } else
153 w->rtt_min = min(w->rtt, w->rtt_min);
154}
155
156
145/* 157/*
146 * @westwood_fast_bw 158 * @westwood_fast_bw
147 * It is called when we are in fast path. In particular it is called when 159 * It is called when we are in fast path. In particular it is called when
@@ -157,7 +169,7 @@ static inline void westwood_fast_bw(struct sock *sk)
157 169
158 w->bk += tp->snd_una - w->snd_una; 170 w->bk += tp->snd_una - w->snd_una;
159 w->snd_una = tp->snd_una; 171 w->snd_una = tp->snd_una;
160 w->rtt_min = min(w->rtt, w->rtt_min); 172 update_rtt_min(w);
161} 173}
162 174
163/* 175/*
@@ -226,12 +238,14 @@ static void tcp_westwood_event(struct sock *sk, enum tcp_ca_event event)
226 238
227 case CA_EVENT_FRTO: 239 case CA_EVENT_FRTO:
228 tp->snd_ssthresh = tcp_westwood_bw_rttmin(sk); 240 tp->snd_ssthresh = tcp_westwood_bw_rttmin(sk);
241 /* Update RTT_min when next ack arrives */
242 w->reset_rtt_min = 1;
229 break; 243 break;
230 244
231 case CA_EVENT_SLOW_ACK: 245 case CA_EVENT_SLOW_ACK:
232 westwood_update_window(sk); 246 westwood_update_window(sk);
233 w->bk += westwood_acked_count(sk); 247 w->bk += westwood_acked_count(sk);
234 w->rtt_min = min(w->rtt, w->rtt_min); 248 update_rtt_min(w);
235 break; 249 break;
236 250
237 default: 251 default: