Subject: Re: [PATCH net-next 3/3] tcp: derive delack_max from rto_min

From: David Ahern <[email-masked]>
Date: Wed, 20 Sep 2023 15:57:09 -0600

On 9/20/23 11:29 AM, Eric Dumazet wrote:
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 1fc1f879cfd6c28cd655bb8f02eff6624eec2ffc..2d1e4b5ac1ca41ff3db8dc58458d4e922a2c4999 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -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);

`u32` type with max_t type set as `int`

> +
> +		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.
> @@ -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));

and then here ato is an `int`.
>  
>  	/* Stay within the limit we were given */
>  	timeout = jiffies + ato;