Skip to content

Commit

Permalink
net-tcp_bbr: v2: factor out tx.in_flight setting into tcp_set_tx_in_f…
Browse files Browse the repository at this point in the history
…light()

Factor out the code to set an skb's tx.in_flight field into its own
function, so that this code can be used for the TCP_REPAIR "fake send"
code path that inserts skbs into the rtx queue without sending
them. This is in preparation for the following patch, which fixes an
issue with TCP_REPAIR and tx.in_flight.

Tested: See last patch in series for sponge link.

Effort: net-tcp_bbr
Origin-9xx-SHA1: e880fc907d06ea7354333f60f712748ebce9497b
Change-Id: I4fbd4a6e18a51ab06d50ab1c9ad820ce5bea89af
  • Loading branch information
nealcardwell authored and xanmod committed Jun 28, 2021
1 parent 9d5d2ca commit 7682178
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions include/net/tcp.h
Expand Up @@ -1163,6 +1163,7 @@ static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event)
}

/* From tcp_rate.c */
void tcp_set_tx_in_flight(struct sock *sk, struct sk_buff *skb);
void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb);
void tcp_rate_skb_delivered(struct sock *sk, struct sk_buff *skb,
struct rate_sample *rs);
Expand Down
32 changes: 19 additions & 13 deletions net/ipv4/tcp_rate.c
Expand Up @@ -34,13 +34,30 @@
* ready to send in the write queue.
*/

void tcp_set_tx_in_flight(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
u32 in_flight;

/* Check, sanitize, and record packets in flight after skb was sent. */
in_flight = tcp_packets_in_flight(tp) + tcp_skb_pcount(skb);
if (WARN_ONCE(in_flight > TCPCB_IN_FLIGHT_MAX,
"insane in_flight %u cc %s mss %u "
"cwnd %u pif %u %u %u %u\n",
in_flight, inet_csk(sk)->icsk_ca_ops->name,
tp->mss_cache, tp->snd_cwnd,
tp->packets_out, tp->retrans_out,
tp->sacked_out, tp->lost_out))
in_flight = TCPCB_IN_FLIGHT_MAX;
TCP_SKB_CB(skb)->tx.in_flight = in_flight;
}

/* Snapshot the current delivery information in the skb, to generate
* a rate sample later when the skb is (s)acked in tcp_rate_skb_delivered().
*/
void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
u32 in_flight;

/* In general we need to start delivery rate samples from the
* time we received the most recent ACK, to ensure we include
Expand Down Expand Up @@ -69,18 +86,7 @@ void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb)
TCP_SKB_CB(skb)->tx.delivered_ce = tp->delivered_ce;
TCP_SKB_CB(skb)->tx.lost = tp->lost;
TCP_SKB_CB(skb)->tx.is_app_limited = tp->app_limited ? 1 : 0;

/* Check, sanitize, and record packets in flight after skb was sent. */
in_flight = tcp_packets_in_flight(tp) + tcp_skb_pcount(skb);
WARN_ONCE(in_flight > TCPCB_IN_FLIGHT_MAX,
"insane in_flight %u cc %s mss %u "
"cwnd %u pif %u %u %u %u\n",
in_flight, inet_csk(sk)->icsk_ca_ops->name,
tp->mss_cache, tp->snd_cwnd,
tp->packets_out, tp->retrans_out,
tp->sacked_out, tp->lost_out);
in_flight = min(in_flight, TCPCB_IN_FLIGHT_MAX);
TCP_SKB_CB(skb)->tx.in_flight = in_flight;
tcp_set_tx_in_flight(sk, skb);
}

/* When an skb is sacked or acked, we fill in the rate sample with the (prior)
Expand Down

0 comments on commit 7682178

Please sign in to comment.