Skip to content

Commit

Permalink
Merge branch 'tcp_delack_max'
Browse files Browse the repository at this point in the history
Eric Dumazet says:

====================
tcp: add tcp_delack_max()

First patches are adding const qualifiers to four existing helpers.

Third patch adds a much needed companion feature to RTAX_RTO_MIN.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Oct 1, 2023
2 parents 236f387 + bbf80d7 commit 66ac08a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -2141,14 +2141,14 @@ static inline bool sk_rethink_txhash(struct sock *sk)
}

static inline struct dst_entry *
__sk_dst_get(struct sock *sk)
__sk_dst_get(const struct sock *sk)
{
return rcu_dereference_check(sk->sk_dst_cache,
lockdep_sock_is_held(sk));
}

static inline struct dst_entry *
sk_dst_get(struct sock *sk)
sk_dst_get(const struct sock *sk)
{
struct dst_entry *dst;

Expand Down
6 changes: 4 additions & 2 deletions include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,10 @@ static inline void tcp_fast_path_check(struct sock *sk)
tcp_fast_path_on(tp);
}

u32 tcp_delack_max(const struct sock *sk);

/* Compute the actual rto_min value */
static inline u32 tcp_rto_min(struct sock *sk)
static inline u32 tcp_rto_min(const struct sock *sk)
{
const struct dst_entry *dst = __sk_dst_get(sk);
u32 rto_min = inet_csk(sk)->icsk_rto_min;
Expand All @@ -729,7 +731,7 @@ static inline u32 tcp_rto_min(struct sock *sk)
return rto_min;
}

static inline u32 tcp_rto_min_us(struct sock *sk)
static inline u32 tcp_rto_min_us(const struct sock *sk)
{
return jiffies_to_usecs(tcp_rto_min(sk));
}
Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3762,7 +3762,8 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
info->tcpi_options |= TCPI_OPT_SYN_DATA;

info->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto);
info->tcpi_ato = jiffies_to_usecs(icsk->icsk_ack.ato);
info->tcpi_ato = jiffies_to_usecs(min(icsk->icsk_ack.ato,
tcp_delack_max(sk)));
info->tcpi_snd_mss = tp->mss_cache;
info->tcpi_rcv_mss = icsk->icsk_ack.rcv_mss;

Expand Down
16 changes: 15 additions & 1 deletion net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -3977,6 +3977,20 @@ int tcp_connect(struct sock *sk)
}
EXPORT_SYMBOL(tcp_connect);

u32 tcp_delack_max(const struct sock *sk)
{
const struct dst_entry *dst = __sk_dst_get(sk);
u32 delack_max = inet_csk(sk)->icsk_delack_max;

if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) {
u32 rto_min = dst_metric_rtt(dst, RTAX_RTO_MIN);
u32 delack_from_rto_min = max_t(int, 1, rto_min - 1);

delack_max = min_t(u32, delack_max, delack_from_rto_min);
}
return delack_max;
}

/* Send out a delayed ack, the caller does the policy checking
* to see if we should even be here. See tcp_input.c:tcp_ack_snd_check()
* for details.
Expand Down Expand Up @@ -4012,7 +4026,7 @@ void tcp_send_delayed_ack(struct sock *sk)
ato = min(ato, max_ato);
}

ato = min_t(u32, ato, inet_csk(sk)->icsk_delack_max);
ato = min_t(u32, ato, tcp_delack_max(sk));

/* Stay within the limit we were given */
timeout = jiffies + ato;
Expand Down

0 comments on commit 66ac08a

Please sign in to comment.