Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[TCP]: cubic - eliminate use of receive time stamp

Remove use of received timestamp option value from RTT calculation in Cubic.
A hostile receiver may be returning a larger timestamp option than the original
value. This would cause the sender to believe the malevolent receiver had
a larger RTT and because Cubic tries to provide some RTT friendliness, the
sender would then favor the liar.

Instead, use the jiffie resolutionRTT value already computed and
passed back after ack.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Stephen Hemminger and committed by
David S. Miller
e7d0c885 30cfd0ba

+18 -28
+18 -28
net/ipv4/tcp_cubic.c
··· 246 246 ca->cnt = 1; 247 247 } 248 248 249 - 250 - /* Keep track of minimum rtt */ 251 - static inline void measure_delay(struct sock *sk) 252 - { 253 - const struct tcp_sock *tp = tcp_sk(sk); 254 - struct bictcp *ca = inet_csk_ca(sk); 255 - u32 delay; 256 - 257 - /* No time stamp */ 258 - if (!(tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr) || 259 - /* Discard delay samples right after fast recovery */ 260 - (s32)(tcp_time_stamp - ca->epoch_start) < HZ) 261 - return; 262 - 263 - delay = (tcp_time_stamp - tp->rx_opt.rcv_tsecr)<<3; 264 - if (delay == 0) 265 - delay = 1; 266 - 267 - /* first time call or link delay decreases */ 268 - if (ca->delay_min == 0 || ca->delay_min > delay) 269 - ca->delay_min = delay; 270 - } 271 - 272 249 static void bictcp_cong_avoid(struct sock *sk, u32 ack, 273 250 u32 in_flight, int data_acked) 274 251 { 275 252 struct tcp_sock *tp = tcp_sk(sk); 276 253 struct bictcp *ca = inet_csk_ca(sk); 277 - 278 - if (data_acked) 279 - measure_delay(sk); 280 254 281 255 if (!tcp_is_cwnd_limited(sk, in_flight)) 282 256 return; ··· 311 337 static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us) 312 338 { 313 339 const struct inet_connection_sock *icsk = inet_csk(sk); 340 + struct bictcp *ca = inet_csk_ca(sk); 341 + u32 delay; 314 342 315 343 if (cnt > 0 && icsk->icsk_ca_state == TCP_CA_Open) { 316 - struct bictcp *ca = inet_csk_ca(sk); 317 344 cnt -= ca->delayed_ack >> ACK_RATIO_SHIFT; 318 345 ca->delayed_ack += cnt; 319 346 } 320 - } 321 347 348 + /* Some calls are for duplicates without timetamps */ 349 + if (rtt_us < 0) 350 + return; 351 + 352 + /* Discard delay samples right after fast recovery */ 353 + if ((s32)(tcp_time_stamp - ca->epoch_start) < HZ) 354 + return; 355 + 356 + delay = usecs_to_jiffies(rtt_us) << 3; 357 + if (delay == 0) 358 + delay = 1; 359 + 360 + /* first time call or link delay decreases */ 361 + if (ca->delay_min == 0 || ca->delay_min > delay) 362 + ca->delay_min = delay; 363 + } 322 364 323 365 static struct tcp_congestion_ops cubictcp = { 324 366 .init = bictcp_init,