[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d3d942c0-ceed-484f-8f2a-28abbdd132aa@redhat.com>
Date: Tue, 3 Dec 2024 15:58:19 +0100
From: Paolo Abeni <pabeni@...hat.com>
To: Antonio Quartulli <antonio@...nvpn.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Donald Hunter <donald.hunter@...il.com>, Shuah Khan <shuah@...nel.org>,
sd@...asysnail.net, ryazanov.s.a@...il.com, Andrew Lunn <andrew@...n.ch>
Cc: Simon Horman <horms@...nel.org>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH net-next v12 09/22] ovpn: implement packet processing
On 12/2/24 16:07, Antonio Quartulli wrote:
> @@ -286,6 +292,31 @@ struct ovpn_peer *ovpn_peer_get_by_dst(struct ovpn_priv *ovpn,
> return peer;
> }
>
> +/**
> + * ovpn_peer_check_by_src - check that skb source is routed via peer
> + * @ovpn: the openvpn instance to search
> + * @skb: the packet to extract source address from
> + * @peer: the peer to check against the source address
> + *
> + * Return: true if the peer is matching or false otherwise
> + */
> +bool ovpn_peer_check_by_src(struct ovpn_priv *ovpn, struct sk_buff *skb,
> + struct ovpn_peer *peer)
> +{
> + bool match = false;
> +
> + if (ovpn->mode == OVPN_MODE_P2P) {
> + /* in P2P mode, no matter the destination, packets are always
> + * sent to the single peer listening on the other side
> + */
> + rcu_read_lock();
> + match = (peer == rcu_dereference(ovpn->peer));
> + rcu_read_unlock();
Here you are not dereferencing ovpn->peer, so you can use
rcu_access_pointer() instead and avoid the rcu_read_lock/unlock() pair.
/P
Powered by blists - more mailing lists