From: Paolo Abeni <pabeni@redhat.com>
To: Dmitry Safonov <dima@arista.com>,
David Ahern <dsahern@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org,
Dmitry Safonov <0x7f454c46@gmail.com>,
Francesco Ruggeri <fruggeri05@gmail.com>,
Salam Noureddine <noureddine@arista.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org
Subject: Re: [PATCH v2 6/7] net/tcp: Add sne_lock to access SNEs
Date: Mon, 27 Nov 2023 12:41:57 +0100 [thread overview]
Message-ID: <1c769b1a72c5a7f6e19010dfccc78b2502484cf3.camel@redhat.com> (raw)
In-Reply-To: <20231124002720.102537-7-dima@arista.com>
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@arista.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.
I think you can use a plain spinlock here, as both read and write
appears to be in the fastpath (?!?)
> @@ -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.
Cheers,
Paolo
next prev parent reply other threads:[~2023-11-27 11:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 0:27 [PATCH v2 0/7] TCP-AO fixes Dmitry Safonov
2023-11-24 0:27 ` [PATCH v2 1/7] Documentation/tcp: Fix an obvious typo Dmitry Safonov
2023-11-24 0:27 ` [PATCH v2 2/7] net/tcp: Consistently align TCP-AO option in the header Dmitry Safonov
2023-11-24 0:27 ` [PATCH v2 3/7] net/tcp: Limit TCP_AO_REPAIR to non-listen sockets Dmitry Safonov
2023-11-24 0:27 ` [PATCH v2 4/7] net/tcp: Allow removing current/rnext TCP-AO keys on TCP_LISTEN sockets Dmitry Safonov
2023-11-24 0:27 ` [PATCH v2 5/7] net/tcp: Don't add key with non-matching VRF on connected sockets Dmitry Safonov
2023-11-24 0:27 ` [PATCH v2 6/7] net/tcp: Add sne_lock to access SNEs Dmitry Safonov
2023-11-27 11:41 ` Paolo Abeni [this message]
2023-11-27 14:42 ` Dmitry Safonov
2023-11-24 0:27 ` [PATCH v2 7/7] net/tcp: Don't store TCP-AO maclen on reqsk Dmitry Safonov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c769b1a72c5a7f6e19010dfccc78b2502484cf3.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=0x7f454c46@gmail.com \
--cc=davem@davemloft.net \
--cc=dima@arista.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=fruggeri05@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=noureddine@arista.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®