All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Ralf Lici <ralf@mandelbit.com>
Cc: netdev@vger.kernel.org, Antonio Quartulli <antonio@openvpn.net>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net v2 3/3] ovpn: use datagram_poll_queue for socket readiness in TCP
Date: Mon, 20 Oct 2025 12:17:01 +0200	[thread overview]
Message-ID: <aPYMHdIX68S1Yk-l@krikkit> (raw)
In-Reply-To: <20251020073731.76589-4-ralf@mandelbit.com>

2025-10-20, 09:37:31 +0200, Ralf Lici wrote:
> diff --git a/drivers/net/ovpn/tcp.c b/drivers/net/ovpn/tcp.c
> index 289f62c5d2c7..308fdbb75cea 100644
> --- a/drivers/net/ovpn/tcp.c
> +++ b/drivers/net/ovpn/tcp.c
> @@ -560,16 +560,34 @@ static void ovpn_tcp_close(struct sock *sk, long timeout)
>  static __poll_t ovpn_tcp_poll(struct file *file, struct socket *sock,
>  			      poll_table *wait)
>  {
> -	__poll_t mask = datagram_poll(file, sock, wait);
> +	struct sk_buff_head *queue = &sock->sk->sk_receive_queue;
>  	struct ovpn_socket *ovpn_sock;
> +	struct ovpn_peer *peer = NULL;
> +	__poll_t mask;
>  
>  	rcu_read_lock();
>  	ovpn_sock = rcu_dereference_sk_user_data(sock->sk);
> -	if (ovpn_sock && ovpn_sock->peer &&
> -	    !skb_queue_empty(&ovpn_sock->peer->tcp.user_queue))
> -		mask |= EPOLLIN | EPOLLRDNORM;
> +	/* if we landed in this callback, we expect to have a
> +	 * meaningful state. The ovpn_socket lifecycle would
> +	 * prevent it otherwise.
> +	 */
> +	if (WARN_ON(!ovpn_sock || !ovpn_sock->peer)) {
> +		rcu_read_unlock();
> +		pr_err_ratelimited("ovpn: null state in ovpn_tcp_poll!\n");

nit: the extra print is not really necessary once we've done a full
WARN. But if you want the custom message alongside the WARN, maybe:

if (WARN(!ovpn_sock || !ovpn_sock->peer, "ovpn: null state in ovpn_tcp_poll!")) {
	...
}

(you can find examples of the "if (WARN(cond, msg))" pattern in
net/core/skbuff.c:
drop_reasons_register_subsys/drop_reasons_unregister_subsys
and other places)

Other than that, the patch looks good, thanks.

> +		return 0;
> +	}

-- 
Sabrina

  reply	other threads:[~2025-10-20 10:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-20  7:37 [PATCH net v2 0/3] fix poll behaviour for TCP-based tunnel protocols Ralf Lici
2025-10-20  7:37 ` [PATCH net v2 1/3] net: datagram: introduce datagram_poll_queue for custom receive queues Ralf Lici
2025-10-20 10:17   ` Sabrina Dubroca
2025-10-20 12:22     ` Ralf Lici
2025-10-20  7:37 ` [PATCH net v2 2/3] espintcp: use datagram_poll_queue for socket readiness Ralf Lici
2025-10-20  7:37 ` [PATCH net v2 3/3] ovpn: use datagram_poll_queue for socket readiness in TCP Ralf Lici
2025-10-20 10:17   ` Sabrina Dubroca [this message]
2025-10-20 12:22     ` Ralf Lici

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=aPYMHdIX68S1Yk-l@krikkit \
    --to=sd@queasysnail.net \
    --cc=andrew+netdev@lunn.ch \
    --cc=antonio@openvpn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ralf@mandelbit.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.