Skip to content

Commit 66ac08a

Browse files
committed
Merge branch 'tcp_delack_max'
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>
2 parents 236f387 + bbf80d7 commit 66ac08a

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

include/net/sock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,14 +2141,14 @@ static inline bool sk_rethink_txhash(struct sock *sk)
21412141
}
21422142

21432143
static inline struct dst_entry *
2144-
__sk_dst_get(struct sock *sk)
2144+
__sk_dst_get(const struct sock *sk)
21452145
{
21462146
return rcu_dereference_check(sk->sk_dst_cache,
21472147
lockdep_sock_is_held(sk));
21482148
}
21492149

21502150
static inline struct dst_entry *
2151-
sk_dst_get(struct sock *sk)
2151+
sk_dst_get(const struct sock *sk)
21522152
{
21532153
struct dst_entry *dst;
21542154

include/net/tcp.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,10 @@ static inline void tcp_fast_path_check(struct sock *sk)
718718
tcp_fast_path_on(tp);
719719
}
720720

721+
u32 tcp_delack_max(const struct sock *sk);
722+
721723
/* Compute the actual rto_min value */
722-
static inline u32 tcp_rto_min(struct sock *sk)
724+
static inline u32 tcp_rto_min(const struct sock *sk)
723725
{
724726
const struct dst_entry *dst = __sk_dst_get(sk);
725727
u32 rto_min = inet_csk(sk)->icsk_rto_min;
@@ -729,7 +731,7 @@ static inline u32 tcp_rto_min(struct sock *sk)
729731
return rto_min;
730732
}
731733

732-
static inline u32 tcp_rto_min_us(struct sock *sk)
734+
static inline u32 tcp_rto_min_us(const struct sock *sk)
733735
{
734736
return jiffies_to_usecs(tcp_rto_min(sk));
735737
}

net/ipv4/tcp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3762,7 +3762,8 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
37623762
info->tcpi_options |= TCPI_OPT_SYN_DATA;
37633763

37643764
info->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto);
3765-
info->tcpi_ato = jiffies_to_usecs(icsk->icsk_ack.ato);
3765+
info->tcpi_ato = jiffies_to_usecs(min(icsk->icsk_ack.ato,
3766+
tcp_delack_max(sk)));
37663767
info->tcpi_snd_mss = tp->mss_cache;
37673768
info->tcpi_rcv_mss = icsk->icsk_ack.rcv_mss;
37683769

net/ipv4/tcp_output.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3977,6 +3977,20 @@ int tcp_connect(struct sock *sk)
39773977
}
39783978
EXPORT_SYMBOL(tcp_connect);
39793979

3980+
u32 tcp_delack_max(const struct sock *sk)
3981+
{
3982+
const struct dst_entry *dst = __sk_dst_get(sk);
3983+
u32 delack_max = inet_csk(sk)->icsk_delack_max;
3984+
3985+
if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) {
3986+
u32 rto_min = dst_metric_rtt(dst, RTAX_RTO_MIN);
3987+
u32 delack_from_rto_min = max_t(int, 1, rto_min - 1);
3988+
3989+
delack_max = min_t(u32, delack_max, delack_from_rto_min);
3990+
}
3991+
return delack_max;
3992+
}
3993+
39803994
/* Send out a delayed ack, the caller does the policy checking
39813995
* to see if we should even be here. See tcp_input.c:tcp_ack_snd_check()
39823996
* for details.
@@ -4012,7 +4026,7 @@ void tcp_send_delayed_ack(struct sock *sk)
40124026
ato = min(ato, max_ato);
40134027
}
40144028

4015-
ato = min_t(u32, ato, inet_csk(sk)->icsk_delack_max);
4029+
ato = min_t(u32, ato, tcp_delack_max(sk));
40164030

40174031
/* Stay within the limit we were given */
40184032
timeout = jiffies + ato;

0 commit comments

Comments
 (0)