linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Antonio Quartulli <antonio@openvpn.net>
Cc: netdev@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Donald Hunter <donald.hunter@gmail.com>,
	Shuah Khan <shuah@kernel.org>,
	ryazanov.s.a@gmail.com, Andrew Lunn <andrew+netdev@lunn.ch>,
	Simon Horman <horms@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Xiao Liang <shaw.leon@gmail.com>
Subject: Re: [PATCH net-next v24 18/23] ovpn: implement peer add/get/dump/delete via netlink
Date: Tue, 25 Mar 2025 11:56:54 +0100	[thread overview]
Message-ID: <Z-KL9jKHNayqDLi2@krikkit> (raw)
In-Reply-To: <86fea40c-6b8b-4ac3-bb14-4a24c63cf167@openvpn.net>

2025-03-25, 00:15:48 +0100, Antonio Quartulli wrote:
> On 24/03/2025 11:48, Sabrina Dubroca wrote:
> > Hello Antonio,
> > 
> > A few questions wrt the API:
> > 
> > 2025-03-18, 02:40:53 +0100, Antonio Quartulli wrote:
> > > +static bool ovpn_nl_attr_sockaddr_remote(struct nlattr **attrs,
> > > +					 struct sockaddr_storage *ss)
> > > +{
> > > +	struct sockaddr_in6 *sin6;
> > > +	struct sockaddr_in *sin;
> > > +	struct in6_addr *in6;
> > > +	__be16 port = 0;
> > > +	__be32 *in;
> > > +
> > > +	ss->ss_family = AF_UNSPEC;
> > > +
> > > +	if (attrs[OVPN_A_PEER_REMOTE_PORT])
> > > +		port = nla_get_be16(attrs[OVPN_A_PEER_REMOTE_PORT]);
> > 
> > What's the expected behavior if REMOTE_PORT isn't provided? We'll send
> > packets do port 0 (which I'm guessing will get dropped on the other
> > side) until we get a message from the peer and float sets the correct
> > port/address?
> 
> I have never seen a packet going out with port 0 :)

It will if you hack into ovpn-cli to skip OVPN_A_PEER_REMOTE_PORT.
I don't know how networks/admins react to such packets.

> But being dropped is most likely what's going to happen.
> 
> I'd say this is not something that we expect the user to do:
> if the remote address if specified, the user should specify a non-zero port
> too.
> 
> We could add a check to ensure that a port is always specified if the remote
> address is there too, just to avoid the user to shoot himself in the foot.
> But we expect the user to pass an addr:port where the peer is listening to
> (and that can't be a 0 port).

If we expect that (even if a well-behaved userspace would never do
it), I have a preference for enforcing that expectation. Since there's
already a policy rejecting OVPN_A_PEER_REMOTE_PORT == 0, this would be
more consistent IMO.

An alternative would be to select a default (non-zero) port if none is
provided.

> > 
> > 
> > > +static int ovpn_nl_peer_modify(struct ovpn_peer *peer, struct genl_info *info,
> > > +			       struct nlattr **attrs)
> > > +{
> > [...]
> > > +	/* when setting the keepalive, both parameters have to be configured */
> > > +	if (attrs[OVPN_A_PEER_KEEPALIVE_INTERVAL] &&
> > > +	    attrs[OVPN_A_PEER_KEEPALIVE_TIMEOUT]) {
> > > +		interv = nla_get_u32(attrs[OVPN_A_PEER_KEEPALIVE_INTERVAL]);
> > > +		timeout = nla_get_u32(attrs[OVPN_A_PEER_KEEPALIVE_TIMEOUT]);
> > > +		ovpn_peer_keepalive_set(peer, interv, timeout);
> > 
> > Should we interpret OVPN_A_PEER_KEEPALIVE_INTERVAL = 0 &&
> > OVPN_A_PEER_KEEPALIVE_TIMEOUT == 0 as "disable keepalive/timeout" on
> > an active peer?  And maybe "one set to 0, the other set to some
> > non-zero value" as invalid?  Setting either value to 0 doesn't seem
> > very useful (timeout = 0 will probably kill the peer immediately, and
> > I suspect interval = 0 would be quite spammy).
> > 
> 
> Considering "0" as "disable keepalive" is the current intention.
> 
> In ovpn_peer_keepalive_work_single() you can see that if either one if 0, we
> just skip the peer:
> 
> 1217         /* we expect both timers to be configured at the same time,
> 1218          * therefore bail out if either is not set
> 1219          */
> 1220         if (!peer->keepalive_timeout || !peer->keepalive_interval) {
> 1221                 spin_unlock_bh(&peer->lock);
> 1222                 return 0;
> 1223         }
> 
> does it make sense?

Ah, true. Sorry, I forgot about that.  So after _NEW/_SET we'll run
the work once, and that peer will be ignored. And if there's no other
peer requiring keepalive, next_run will be 0 and we don't
reschedule. That's good, thanks.

-- 
Sabrina

  reply	other threads:[~2025-03-25 10:56 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18  1:40 [PATCH net-next v24 00/23] Introducing OpenVPN Data Channel Offload Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 01/23] net: introduce OpenVPN Data Channel Offload (ovpn) Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 02/23] ovpn: add basic netlink support Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 03/23] ovpn: add basic interface creation/destruction/management routines Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 04/23] ovpn: keep carrier always on for MP interfaces Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 05/23] ovpn: introduce the ovpn_peer object Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 06/23] ovpn: introduce the ovpn_socket object Antonio Quartulli
2025-04-01 13:05   ` Sabrina Dubroca
2025-04-02 23:37     ` Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 07/23] ovpn: implement basic TX path (UDP) Antonio Quartulli
2025-04-01 13:49   ` Sabrina Dubroca
2025-04-02 12:01     ` Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 08/23] ovpn: implement basic RX " Antonio Quartulli
2025-04-01  9:47   ` Sabrina Dubroca
2025-04-02 12:04     ` Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 09/23] ovpn: implement packet processing Antonio Quartulli
2025-03-24 11:02   ` Sabrina Dubroca
2025-03-24 20:53     ` Antonio Quartulli
2025-03-25  9:40       ` Sabrina Dubroca
2025-03-25  2:07   ` Qingfang Deng
2025-03-26  9:41     ` Antonio Quartulli
2025-03-26 10:03       ` Qingfang Deng
2025-03-26 10:22         ` Antonio Quartulli
2025-03-26 12:43           ` Qingfang Deng
2025-03-26 13:54             ` Antonio Quartulli
2025-04-01  9:59   ` Sabrina Dubroca
2025-04-02 12:08     ` Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 10/23] ovpn: store tunnel and transport statistics Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 11/23] ovpn: implement TCP transport Antonio Quartulli
2025-04-01 10:02   ` Sabrina Dubroca
2025-04-02 12:09     ` Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 12/23] skb: implement skb_send_sock_locked_with_flags() Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 13/23] ovpn: add support for MSG_NOSIGNAL in tcp_sendmsg Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 14/23] ovpn: implement multi-peer support Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 15/23] ovpn: implement peer lookup logic Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 16/23] ovpn: implement keepalive mechanism Antonio Quartulli
2025-04-01 12:51   ` Sabrina Dubroca
2025-04-02 12:11     ` Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 17/23] ovpn: add support for updating local or remote UDP endpoint Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 18/23] ovpn: implement peer add/get/dump/delete via netlink Antonio Quartulli
2025-03-24 10:48   ` Sabrina Dubroca
2025-03-24 23:15     ` Antonio Quartulli
2025-03-25 10:56       ` Sabrina Dubroca [this message]
2025-03-26  0:41         ` Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 19/23] ovpn: implement key add/get/del/swap " Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 20/23] ovpn: kill key and notify userspace in case of IV exhaustion Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 21/23] ovpn: notify userspace when a peer is deleted Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 22/23] ovpn: add basic ethtool support Antonio Quartulli
2025-03-18  1:40 ` [PATCH net-next v24 23/23] testing/selftests: add test tool and scripts for ovpn module Antonio Quartulli
2025-03-28  9:14 ` [PATCH net-next v24 00/23] Introducing OpenVPN Data Channel Offload Antonio Quartulli
2025-03-31 14:47   ` Sabrina Dubroca

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=Z-KL9jKHNayqDLi2@krikkit \
    --to=sd@queasysnail.net \
    --cc=andrew+netdev@lunn.ch \
    --cc=antonio@openvpn.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ryazanov.s.a@gmail.com \
    --cc=shaw.leon@gmail.com \
    --cc=shuah@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).