[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <90de4882-7683-4c7b-95bc-a5eb363912a2@arista.com>
Date: Mon, 27 Nov 2023 14:42:35 +0000
From: Dmitry Safonov <dima@...sta.com>
To: Paolo Abeni <pabeni@...hat.com>
Cc: linux-kernel@...r.kernel.org, Dmitry Safonov <0x7f454c46@...il.com>,
Francesco Ruggeri <fruggeri05@...il.com>,
Salam Noureddine <noureddine@...sta.com>, Simon Horman <horms@...nel.org>,
netdev@...r.kernel.org, David Ahern <dsahern@...nel.org>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH v2 6/7] net/tcp: Add sne_lock to access SNEs
On 11/27/23 11:41, Paolo Abeni wrote:
> On Fri, 2023-11-24 at 00:27 +0000, Dmitry Safonov wrote:
>> RFC 5925 (6.2):
>>> TCP-AO emulates a 64-bit sequence number space by inferring when to
>>> increment the high-order 32-bit portion (the SNE) based on
>>> transitions in the low-order portion (the TCP sequence number).
>>
>> snd_sne and rcv_sne are the upper 4 bytes of extended SEQ number.
>> Unfortunately, reading two 4-bytes pointers can't be performed
>> atomically (without synchronization).
>>
>> Let's keep it KISS and add an rwlock - that shouldn't create much
>> contention as SNE are updated every 4Gb of traffic and the atomic region
>> is quite small.
>>
>> Fixes: 64382c71a557 ("net/tcp: Add TCP-AO SNE support")
>> Signed-off-by: Dmitry Safonov <dima@...sta.com>
>> ---
>> include/net/tcp_ao.h | 2 +-
>> net/ipv4/tcp_ao.c | 34 +++++++++++++++++++++-------------
>> net/ipv4/tcp_input.c | 16 ++++++++++++++--
>> 3 files changed, 36 insertions(+), 16 deletions(-)
>>
>> diff --git a/include/net/tcp_ao.h b/include/net/tcp_ao.h
>> index 647781080613..beea3e6b39e2 100644
>> --- a/include/net/tcp_ao.h
>> +++ b/include/net/tcp_ao.h
>> @@ -123,6 +123,7 @@ struct tcp_ao_info {
>> */
>> u32 snd_sne;
>> u32 rcv_sne;
>> + rwlock_t sne_lock;
>
> RW lock are problematic in the networking code, see commit
> dbca1596bbb08318f5e3b3b99f8ca0a0d3830a65.
Thanks, was not aware of this pitfall.
> I think you can use a plain spinlock here, as both read and write
> appears to be in the fastpath (?!?)
Yeah, I wanted to avoid to RX concurrency here as writing happens only
once in 4Gb. I'll take another attempt to prevent that in v3.
>> @@ -781,8 +780,10 @@ int tcp_ao_prepare_reset(const struct sock *sk, struct sk_buff *skb,
>> *traffic_key = snd_other_key(*key);
>> rnext_key = READ_ONCE(ao_info->rnext_key);
>> *keyid = rnext_key->rcvid;
>> - *sne = tcp_ao_compute_sne(READ_ONCE(ao_info->snd_sne),
>> - snd_basis, seq);
>> + read_lock_irqsave(&ao_info->sne_lock, flags);
>> + *sne = tcp_ao_compute_sne(ao_info->snd_sne,
>> + READ_ONCE(*snd_basis), seq);
>> + read_unlock_irqrestore(&ao_info->sne_lock, flags);
>
> Why are you using the irqsave variant? bh should suffice.
It should, yes :)
>
> Cheers,
>
> Paolo
>
Thanks,
Dmitry
Powered by blists - more mailing lists