netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@openvpn.net>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	Sergey Ryazanov <ryazanov.s.a@gmail.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH net-next v2 03/22] ovpn: add basic netlink support
Date: Tue, 5 Mar 2024 16:47:09 +0100	[thread overview]
Message-ID: <f546e063-a69d-4c77-81d2-045acf7e6e4f@openvpn.net> (raw)
In-Reply-To: <e0375bdb-8ef8-4a46-a5cf-351d77840874@lunn.ch>

On 04/03/2024 22:20, Andrew Lunn wrote:
> On Mon, Mar 04, 2024 at 04:08:54PM +0100, Antonio Quartulli wrote:
>> This commit introduces basic netlink support with
>> registration/unregistration functionalities and stub pre/post-doit.
>>
>> More importantly it introduces the UAPI header file that contains
>> the attributes that are inteded to be used by the netlink API
> 
> intended.
> 
>> implementation.
>>
>> For convience, packet.h is also added containing some macros about
>> the OpenVPN packet format.
>>
>> +/** KEYDIR policy. Can be used for configuring an encryption and a decryption key */
>> +static const struct nla_policy ovpn_nl_policy_keydir[NUM_OVPN_A_KEYDIR] = {
>> +	[OVPN_A_KEYDIR_CIPHER_KEY] = NLA_POLICY_MAX_LEN(U8_MAX),
> 
> I don't know netlink that well. Is this saying keys are limited to 256
> bytes? How future proof is that? I'm not a crypto person, but
> symmetric algorithms, e.g. AES, seem to have reasonably short keys, 32
> bytes, so this seems O.K, to me.

256 bytes should be reasonably large. I don't see anything beyond this 
size appearing anytime soon or at all.

> 
>> +	[OVPN_A_KEYDIR_NONCE_TAIL] = NLA_POLICY_EXACT_LEN(NONCE_TAIL_SIZE),
>> +};
>> +
>> +/** KEYCONF policy */
>> +static const struct nla_policy ovpn_nl_policy_keyconf[NUM_OVPN_A_KEYCONF] = {
>> +	[OVPN_A_KEYCONF_SLOT] = NLA_POLICY_RANGE(NLA_U8, __OVPN_KEY_SLOT_FIRST,
>> +						 NUM_OVPN_KEY_SLOT - 1),
>> +	[OVPN_A_KEYCONF_KEY_ID] = { .type = NLA_U8 },
> 
> Is that 256 keys globally, or just associated to one session?

This is specific to one peer, however, the OpenVPN protocol uses IDs up 
7, therefore U8 is just the smallest unit I could use to fit those few 
values.

> 
>> +	[OVPN_A_KEYCONF_CIPHER_ALG] = { .type = NLA_U16 },
>> +	[OVPN_A_KEYCONF_ENCRYPT_DIR] = NLA_POLICY_NESTED(ovpn_nl_policy_keydir),
>> +	[OVPN_A_KEYCONF_DECRYPT_DIR] = NLA_POLICY_NESTED(ovpn_nl_policy_keydir),
>> +};
>> +
> 
>> +/** Generic message container policy */
>> +static const struct nla_policy ovpn_nl_policy[NUM_OVPN_A] = {
>> +	[OVPN_A_IFINDEX] = { .type = NLA_U32 },
>> +	[OVPN_A_IFNAME] = NLA_POLICY_MAX_LEN(IFNAMSIZ),
> 
> Generally, ifnames are not passed around, only ifindex. An interface
> can have multiple names:
> 
> 12: enlr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq master br0 state DOWN group default qlen 1000
>      link/ether 3c:ec:ef:7e:0a:90 brd ff:ff:ff:ff:ff:ff
>      altname enp183s0f2
>      altname eno7
> 
> It is better to let userspace figure out the name from the index,
> since the name is mostly a user space concept.

This is strictly related to your next question.
Please see my answer below.

> 
>> +	[OVPN_A_MODE] = NLA_POLICY_RANGE(NLA_U8, __OVPN_MODE_FIRST,
>> +					 NUM_OVPN_MODE - 1),
>> +	[OVPN_A_PEER] = NLA_POLICY_NESTED(ovpn_nl_policy_peer),
>> +};
> 
>> +static int ovpn_pre_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
>> +			 struct genl_info *info)
>> +{
>> +	struct net *net = genl_info_net(info);
>> +	struct net_device *dev;
>> +
>> +	/* the OVPN_CMD_NEW_IFACE command is different from the rest as it
>> +	 * just expects an IFNAME, while all the others expect an IFINDEX
>> +	 */
> 
> Could you explain that some more. In general, the name should not
> matter to the kernel, udev/systemd might rename it soon after creation
> etc. If it gets moved into a network namespace it might need renaming
> etc.

In a previous discussion it was agreed that we should create ovpn 
interfaces via GENL and not via RTNL.

For this reason ovpn needs userspace to send the name to give the 
interface upon creation. This name is just passed to the networking 
stack upon creation/registration, but it is not stored anywhere else.

Subsequent netlink calls are then all performed by passing an ifindex.

Hence, OVPN_CMD_NEW_IFACE is the only GENL command that required the 
IFNAME to be specified.

Does it make sense?


> 
>> +enum ovpn_nl_peer_attrs {
>> +	OVPN_A_PEER_UNSPEC = 0,
>> +	OVPN_A_PEER_ID,
>> +	OVPN_A_PEER_RX_STATS,
>> +	OVPN_A_PEER_TX_STATS,
> 
> Probably answered later in the patch series: What sort of statistics
> do you expect here. Don't overlap any of the normal network statistics
> with this here, please use the existing kAPIs for those. Anything you
> return here need to be very specific to ovpn.

Actually you found a leftover from an old approach.
OVPN_A_PEER_RX_STATS and OVPN_A_PEER_TX_STATS shall be removed.

The actual stats we store are those below:

> 
>> +	OVPN_A_PEER_VPN_RX_BYTES,
>> +	OVPN_A_PEER_VPN_TX_BYTES,
>> +	OVPN_A_PEER_VPN_RX_PACKETS,
>> +	OVPN_A_PEER_VPN_TX_PACKETS,
>> +	OVPN_A_PEER_LINK_RX_BYTES,
>> +	OVPN_A_PEER_LINK_TX_BYTES,
>> +	OVPN_A_PEER_LINK_RX_PACKETS,
>> +	OVPN_A_PEER_LINK_TX_PACKETS,
> 
> How do these differ to standard network statistics? e.g. what is in
> /sys/class/net/*/statistics/ ?

The first difference is that these stats are per-peer and not 
per-device. Behind each device there might be multiple peers connected.

This way ovpn is able to tell how much data was sent/received by every 
single connected peer.

LINK and VPN store different values.
LINK stats are recorded at the transport layer (before decapsulation or 
after encapsulation), while VPN stats are recorded at the tunnel layer 
(after decapsulation or before encapsulation).

I didn't see how to convey the same information using the standard 
statistics.

Regards,


-- 
Antonio Quartulli
OpenVPN Inc.

  reply	other threads:[~2024-03-05 15:46 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 15:08 [PATCH net-next v2 00/22] Introducing OpenVPN Data Channel Offload Antonio Quartulli
2024-03-04 15:08 ` [PATCH net-next v2 01/22] netlink: add NLA_POLICY_MAX_LEN macro Antonio Quartulli
2024-03-04 15:08 ` [PATCH net-next v2 02/22] net: introduce OpenVPN Data Channel Offload (ovpn) Antonio Quartulli
2024-03-04 20:47   ` Andrew Lunn
2024-03-04 21:30     ` Antonio Quartulli
2024-03-04 22:46       ` Andrew Lunn
2024-03-05 12:29         ` Antonio Quartulli
2024-03-06 15:51     ` Antonio Quartulli
2024-03-04 15:08 ` [PATCH net-next v2 03/22] ovpn: add basic netlink support Antonio Quartulli
2024-03-04 21:20   ` Andrew Lunn
2024-03-05 15:47     ` Antonio Quartulli [this message]
2024-03-05 16:23       ` Andrew Lunn
2024-03-05 19:39         ` Jakub Kicinski
2024-03-06 14:46           ` Antonio Quartulli
2024-03-06 19:10             ` Andrew Lunn
2024-03-08  0:01               ` Antonio Quartulli
2024-03-05 10:49   ` kernel test robot
2024-03-26 11:43   ` Esben Haabendal
2024-03-26 21:39     ` Antonio Quartulli
2024-03-04 15:08 ` [PATCH net-next v2 04/22] ovpn: add basic interface creation/destruction/management routines Antonio Quartulli
2024-03-04 21:33   ` Andrew Lunn
2024-03-05 15:51     ` Antonio Quartulli
2024-03-05 16:27       ` Andrew Lunn
2024-03-06 14:49         ` Antonio Quartulli
2024-03-06 19:31           ` Andrew Lunn
2024-03-08  0:08             ` Antonio Quartulli
2024-03-08 13:13               ` Andrew Lunn
2024-03-08 14:21                 ` Antonio Quartulli
2024-03-05 19:40   ` Jakub Kicinski
2024-03-06 14:59     ` Antonio Quartulli
2024-03-04 15:08 ` [PATCH net-next v2 05/22] ovpn: implement interface creation/destruction via netlink Antonio Quartulli
2024-03-05 14:51   ` Simon Horman
2024-03-06 15:01     ` Antonio Quartulli
2024-03-25 15:01   ` Esben Haabendal
2024-03-26 21:44     ` Antonio Quartulli
2024-04-02  6:48       ` Esben Haabendal
2024-03-04 15:08 ` [PATCH net-next v2 06/22] ovpn: introduce the ovpn_peer object Antonio Quartulli
2024-03-04 21:52   ` Andrew Lunn
2024-03-05 15:52     ` Antonio Quartulli
2024-03-04 22:56   ` Andrew Lunn
2024-03-06 16:03     ` Antonio Quartulli
2024-03-06 19:23       ` Andrew Lunn
2024-03-08  0:12         ` Antonio Quartulli
2024-03-08  2:04   ` Andrew Lunn
2024-03-08 11:00     ` Antonio Quartulli
2024-03-26 10:34   ` Esben Haabendal
2024-03-26 21:45     ` Antonio Quartulli
2024-03-04 15:08 ` [PATCH net-next v2 07/22] ovpn: introduce the ovpn_socket object Antonio Quartulli
2024-03-05 14:59   ` Simon Horman
2024-03-06 15:08     ` Antonio Quartulli
2024-03-04 15:08 ` [PATCH net-next v2 08/22] ovpn: implement basic TX path (UDP) Antonio Quartulli
2024-03-05 19:47   ` Jakub Kicinski
2024-03-06 15:18     ` Antonio Quartulli
2024-03-08 15:31   ` Toke Høiland-Jørgensen
2024-03-08 15:44     ` Antonio Quartulli
2024-03-11 15:19       ` Toke Høiland-Jørgensen
2024-03-11 16:28         ` Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 09/22] ovpn: implement basic RX " Antonio Quartulli
2024-03-05 15:04   ` Simon Horman
2024-03-06 15:29     ` Antonio Quartulli
2024-03-08  2:17   ` Andrew Lunn
2024-03-08 11:07     ` Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 10/22] ovpn: implement packet processing Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 11/22] ovpn: store tunnel and transport statistics Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 12/22] ovpn: implement TCP transport Antonio Quartulli
2024-03-05 15:12   ` Simon Horman
2024-03-06 15:31     ` Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 13/22] ovpn: implement multi-peer support Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 14/22] ovpn: implement peer lookup logic Antonio Quartulli
2024-03-05 15:16   ` Simon Horman
2024-03-06 15:33     ` Antonio Quartulli
2024-03-06  0:11   ` kernel test robot
2024-03-09 10:16   ` kernel test robot
2024-03-04 15:09 ` [PATCH net-next v2 15/22] ovpn: implement keepalive mechanism Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 16/22] ovpn: add support for updating local UDP endpoint Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 17/22] ovpn: add support for peer floating Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 18/22] ovpn: implement peer add/dump/delete via netlink Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 19/22] ovpn: implement key add/del/swap " Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 20/22] ovpn: kill key and notify userspace in case of IV exhaustion Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 21/22] ovpn: notify userspace when a peer is deleted Antonio Quartulli
2024-03-04 15:09 ` [PATCH net-next v2 22/22] ovpn: add basic ethtool support Antonio Quartulli
2024-03-04 23:04   ` Andrew Lunn
2024-03-06 15:42     ` Antonio Quartulli
2024-03-06 19:40       ` Andrew Lunn
2024-03-08  0:21         ` Antonio Quartulli
2024-03-04 21:07 ` [PATCH net-next v2 00/22] Introducing OpenVPN Data Channel Offload Sergey Ryazanov
2024-03-05 19:30 ` Jakub Kicinski
2024-03-06 15:44   ` Antonio Quartulli
2024-03-06 16:13     ` Jakub Kicinski
2024-03-08  0:21       ` Antonio Quartulli

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=f546e063-a69d-4c77-81d2-045acf7e6e4f@openvpn.net \
    --to=antonio@openvpn.net \
    --cc=andrew@lunn.ch \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ryazanov.s.a@gmail.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;
as well as URLs for NNTP newsgroup(s).