Skip to content

Commit 77bfc17

Browse files
yuchungchengdavem330
authored andcommitted
tcp: allow congestion control to expand send buffer differently
Currently the TCP send buffer expands to twice cwnd, in order to allow limited transmits in the CA_Recovery state. This assumes that cwnd does not increase in the CA_Recovery. For some congestion control algorithms, like the upcoming BBR module, if the losses in recovery do not indicate congestion then we may continue to raise cwnd multiplicatively in recovery. In such cases the current multiplier will falsely limit the sending rate, much as if it were limited by the application. This commit adds an optional congestion control callback to use a different multiplier to expand the TCP send buffer. For congestion control modules that do not specificy this callback, TCP continues to use the previous default of 2. Signed-off-by: Van Jacobson <[email protected]> Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: Yuchung Cheng <[email protected]> Signed-off-by: Nandita Dukkipati <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Soheil Hassas Yeganeh <[email protected]> Acked-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 556c6b4 commit 77bfc17

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

include/net/tcp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,8 @@ struct tcp_congestion_ops {
917917
void (*pkts_acked)(struct sock *sk, const struct ack_sample *sample);
918918
/* suggest number of segments for each skb to transmit (optional) */
919919
u32 (*tso_segs_goal)(struct sock *sk);
920+
/* returns the multiplier used in tcp_sndbuf_expand (optional) */
921+
u32 (*sndbuf_expand)(struct sock *sk);
920922
/* get info for inet_diag (optional) */
921923
size_t (*get_info)(struct sock *sk, u32 ext, int *attr,
922924
union tcp_cc_info *info);

net/ipv4/tcp_input.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ static bool tcp_ecn_rcv_ecn_echo(const struct tcp_sock *tp, const struct tcphdr
289289
static void tcp_sndbuf_expand(struct sock *sk)
290290
{
291291
const struct tcp_sock *tp = tcp_sk(sk);
292+
const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops;
292293
int sndmem, per_mss;
293294
u32 nr_segs;
294295

@@ -309,7 +310,8 @@ static void tcp_sndbuf_expand(struct sock *sk)
309310
* Cubic needs 1.7 factor, rounded to 2 to include
310311
* extra cushion (application might react slowly to POLLOUT)
311312
*/
312-
sndmem = 2 * nr_segs * per_mss;
313+
sndmem = ca_ops->sndbuf_expand ? ca_ops->sndbuf_expand(sk) : 2;
314+
sndmem *= nr_segs * per_mss;
313315

314316
if (sk->sk_sndbuf < sndmem)
315317
sk->sk_sndbuf = min(sndmem, sysctl_tcp_wmem[2]);

0 commit comments

Comments
 (0)