Skip to content

Commit 0b6a05c

Browse files
ij1davem330
authored andcommitted
tcp: fix ssthresh u16 leftover
It was once upon time so that snd_sthresh was a 16-bit quantity. ...That has not been true for long period of time. I run across some ancient compares which still seem to trust such legacy. Put all that magic into a single place, I hopefully found all of them. Compile tested, though linking of allyesconfig is ridiculous nowadays it seems. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 036d6a6 commit 0b6a05c

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

include/net/tcp.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,13 @@ static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp)
793793
return tp->packets_out - tcp_left_out(tp) + tp->retrans_out;
794794
}
795795

796+
#define TCP_INFINITE_SSTHRESH 0x7fffffff
797+
798+
static inline bool tcp_in_initial_slowstart(const struct tcp_sock *tp)
799+
{
800+
return tp->snd_ssthresh >= TCP_INFINITE_SSTHRESH;
801+
}
802+
796803
/* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd.
797804
* The exception is rate halving phase, when cwnd is decreasing towards
798805
* ssthresh.

net/ipv4/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ int tcp_disconnect(struct sock *sk, int flags)
20122012
tp->snd_cwnd = 2;
20132013
icsk->icsk_probes_out = 0;
20142014
tp->packets_out = 0;
2015-
tp->snd_ssthresh = 0x7fffffff;
2015+
tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
20162016
tp->snd_cwnd_cnt = 0;
20172017
tp->bytes_acked = 0;
20182018
tcp_set_ca_state(sk, TCP_CA_Open);

net/ipv4/tcp_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ void tcp_update_metrics(struct sock *sk)
761761
set_dst_metric_rtt(dst, RTAX_RTTVAR, var);
762762
}
763763

764-
if (tp->snd_ssthresh >= 0xFFFF) {
764+
if (tcp_in_initial_slowstart(tp)) {
765765
/* Slow start still did not finish. */
766766
if (dst_metric(dst, RTAX_SSTHRESH) &&
767767
!dst_metric_locked(dst, RTAX_SSTHRESH) &&

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ static int tcp_v4_init_sock(struct sock *sk)
18081808
/* See draft-stevens-tcpca-spec-01 for discussion of the
18091809
* initialization of these values.
18101810
*/
1811-
tp->snd_ssthresh = 0x7fffffff; /* Infinity */
1811+
tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
18121812
tp->snd_cwnd_clamp = ~0;
18131813
tp->mss_cache = 536;
18141814

@@ -2284,7 +2284,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
22842284
jiffies_to_clock_t(icsk->icsk_ack.ato),
22852285
(icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong,
22862286
tp->snd_cwnd,
2287-
tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh,
2287+
tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh,
22882288
len);
22892289
}
22902290

net/ipv4/tcp_minisocks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
410410
newtp->retrans_out = 0;
411411
newtp->sacked_out = 0;
412412
newtp->fackets_out = 0;
413-
newtp->snd_ssthresh = 0x7fffffff;
413+
newtp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
414414

415415
/* So many TCP implementations out there (incorrectly) count the
416416
* initial SYN frame in their delayed-ACK and congestion control

net/ipv6/tcp_ipv6.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,7 @@ static int tcp_v6_init_sock(struct sock *sk)
18461846
/* See draft-stevens-tcpca-spec-01 for discussion of the
18471847
* initialization of these values.
18481848
*/
1849-
tp->snd_ssthresh = 0x7fffffff;
1849+
tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
18501850
tp->snd_cwnd_clamp = ~0;
18511851
tp->mss_cache = 536;
18521852

@@ -1969,7 +1969,8 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
19691969
jiffies_to_clock_t(icsk->icsk_rto),
19701970
jiffies_to_clock_t(icsk->icsk_ack.ato),
19711971
(icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong,
1972-
tp->snd_cwnd, tp->snd_ssthresh>=0xFFFF?-1:tp->snd_ssthresh
1972+
tp->snd_cwnd,
1973+
tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh
19731974
);
19741975
}
19751976

0 commit comments

Comments
 (0)