Re: [PATCH net 1/2] tcp_metrics: set maximum cwnd from the dst entry

From: Paolo Abeni
Date: Thu Jun 19 2025 - 04:22:57 EST


On 6/18/25 7:01 PM, Petr Tesarik wrote:
> On Tue, 17 Jun 2025 13:39:35 +0200 Petr Tesarik <ptesarik@xxxxxxxx> wrote:
>> On Tue, 17 Jun 2025 13:00:53 +0200 Paolo Abeni <pabeni@xxxxxxxxxx> wrote:
>>> On 6/13/25 12:20 PM, Petr Tesarik wrote:
>>>> diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
>>>> index 4251670e328c8..dd8f3457bd72e 100644
>>>> --- a/net/ipv4/tcp_metrics.c
>>>> +++ b/net/ipv4/tcp_metrics.c
>>>> @@ -477,6 +477,9 @@ void tcp_init_metrics(struct sock *sk)
>>>> if (!dst)
>>>> goto reset;
>>>>
>>>> + if (dst_metric_locked(dst, RTAX_CWND))
>>>> + tp->snd_cwnd_clamp = dst_metric(dst, RTAX_CWND);
>>>> +
>>>> rcu_read_lock();
>>>> tm = tcp_get_metrics(sk, dst, false);
>>>> if (!tm) {
>>>> @@ -484,9 +487,6 @@ void tcp_init_metrics(struct sock *sk)
>>>> goto reset;
>>>> }
>>>>
>>>> - if (tcp_metric_locked(tm, TCP_METRIC_CWND))
>>>> - tp->snd_cwnd_clamp = tcp_metric_get(tm, TCP_METRIC_CWND);
>>>> -
>>>> val = READ_ONCE(net->ipv4.sysctl_tcp_no_ssthresh_metrics_save) ?
>>>> 0 : tcp_metric_get(tm, TCP_METRIC_SSTHRESH);
>>>> if (val) {
>>>
>>> It's unclear to me why you drop the tcp_metric_get() here. It looks like
>>> the above will cause a functional regression, with unlocked cached
>>> metrics no longer taking effects?
>>
>> Unlocked cached TCP_METRIC_CWND has never taken effects. As you can
>> see, tcp_metric_get() was executed only if the metric was locked.

Uhm... the locking propagation from dst to tcp storage was not so
straight forward to me, I missed it. Please be a little more verbose
about this part in the commit message.

Thanks,

Paolo