mbox series

[net-next,v3,00/24] Introducing OpenVPN Data Channel Offload

Message ID 20240506011637.27272-1-antonio@openvpn.net (mailing list archive)
Headers show
Series Introducing OpenVPN Data Channel Offload | expand

Message

Antonio Quartulli May 6, 2024, 1:16 a.m. UTC
Hi all!

I am finally back with version 3 of the ovpn patchset.
It took a while to address all comments I have received on v2, but I
am happy to say that I addressed 99% of the feedback I collected.

The 1% I did not make yet is using BQL for handling the packets queue.

Although such change looks pretty simple in terms of code, I need to
spend some more time understanding the concept behind and therefore
I decided to postpone this change to the (near) future in order to not
slow down the whole review/merge process.

Major changes from v2 are:
* added YAML documentation for the netlink uAPI
** uapi/linnu/ovpn.h, driners/net/ovpn/netlink-gen.{c,h} are now self
   generated by the tools/net/ynl/ynl-regen.sh script
* the first patch now also modifies the ynl script to account for the
  new MAX_LEN() policy macro
* added more doxygen documentation
* added kselftest unit for ovpn in tools/testing/selftest/ovpn with
  some basic tests
* fixed various typ0s in documentation
* moved includes of local headers last
* wrapped code at 80 chars
* rearranged includes a bit to reduce double inclusions
* set default ifname to ovpn%d and allowed users to not specify any
* now sending reply to NEW_IFACE NL command containing actual new ifname
* used GENL_REQ_ATTR_CHECK() when possible
* turned carrier off in iface create function
* turned carrier on in open function and clearly explain why we keep it
  always on (new patch)
* left ethtool info ->version empty
* removed internal driver version
* checked return value of alloc_netdev
* renamed _lookup() functions to _get()
* removed memset-zero from init function as netdev is already zero'd
* added missing TCP component initialization in ovpn_init
* .. included various small fixes as requested by reviewers

The latest code can also be found at:

https://github.com/OpenVPN/linux-kernel-ovpn

Thanks to the new kunitest component, it is now pssible to run
basic ovpn tests. Peers are emulated by using multiple network
namespaces which are interconnected by means of veth pairs.

Please note that patches have been split for easier review, but if
required, I can send a long 1/1 with all courses and dishes in one go :)

Thanks so far!


Below is the original description posted with the first patchest:
===================================================================

`ovpn` is essentialy a device driver that allows creating a virtual
network interface to handle the OpenVPN data channel. Any traffic
entering the interface is encrypted, encapsulated and sent to the
appropriate destination.

`ovpn` requires OpenVPN in userspace
to run along its side in order to be properly configured and maintained
during its life cycle.

The `ovpn` interface can be created/destroyed and then
configured via Netlink API.

Specifically OpenVPN in userspace will:
* create the `ovpn` interface
* establish the connection with one or more peers
* perform TLS handshake and negotiate any protocol parameter
* configure the `ovpn` interface with peer data (ip/port, keys, etc.)
* handle any subsequent control channel communication

I'd like to point out the control channel is fully handles in userspace.
The idea is to keep the `ovpn` kernel module as simple as possible and
let userspace handle all the non-data (non-fast-path) features.

NOTE: some of you may already know `ovpn-dco` the out-of-tree predecessor
of `ovpn`. However, be aware that the two are not API compatible and
therefore OpenVPN 2.6 will not work with this new `ovpn` module.
More adjustments are required.

For more technical details please refer to the actual patches.

Any comment, concern or statement will be appreciated!
Thanks a lot!!

Best Regards,

Antonio Quartulli
OpenVPN Inc.

======================

Antonio Quartulli (24):
  netlink: add NLA_POLICY_MAX_LEN macro
  net: introduce OpenVPN Data Channel Offload (ovpn)
  ovpn: add basic netlink support
  ovpn: add basic interface creation/destruction/management routines
  ovpn: implement interface creation/destruction via netlink
  ovpn: keep carrier always on
  ovpn: introduce the ovpn_peer object
  ovpn: introduce the ovpn_socket object
  ovpn: implement basic TX path (UDP)
  ovpn: implement basic RX path (UDP)
  ovpn: implement packet processing
  ovpn: store tunnel and transport statistics
  ovpn: implement TCP transport
  ovpn: implement multi-peer support
  ovpn: implement peer lookup logic
  ovpn: implement keepalive mechanism
  ovpn: add support for updating local UDP endpoint
  ovpn: add support for peer floating
  ovpn: implement peer add/dump/delete via netlink
  ovpn: implement key add/del/swap via netlink
  ovpn: kill key and notify userspace in case of IV exhaustion
  ovpn: notify userspace when a peer is deleted
  ovpn: add basic ethtool support
  testing/selftest: add test tool and scripts for ovpn module

 Documentation/netlink/specs/ovpn.yaml      |  331 ++++
 MAINTAINERS                                |    8 +
 drivers/net/Kconfig                        |   13 +
 drivers/net/Makefile                       |    1 +
 drivers/net/ovpn/Makefile                  |   22 +
 drivers/net/ovpn/bind.c                    |   61 +
 drivers/net/ovpn/bind.h                    |  130 ++
 drivers/net/ovpn/crypto.c                  |  162 ++
 drivers/net/ovpn/crypto.h                  |  138 ++
 drivers/net/ovpn/crypto_aead.c             |  378 +++++
 drivers/net/ovpn/crypto_aead.h             |   30 +
 drivers/net/ovpn/io.c                      |  566 +++++++
 drivers/net/ovpn/io.h                      |   35 +
 drivers/net/ovpn/main.c                    |  320 ++++
 drivers/net/ovpn/main.h                    |   56 +
 drivers/net/ovpn/netlink-gen.c             |  206 +++
 drivers/net/ovpn/netlink-gen.h             |   41 +
 drivers/net/ovpn/netlink.c                 |  993 ++++++++++++
 drivers/net/ovpn/netlink.h                 |   46 +
 drivers/net/ovpn/ovpnstruct.h              |   48 +
 drivers/net/ovpn/packet.h                  |   40 +
 drivers/net/ovpn/peer.c                    | 1077 +++++++++++++
 drivers/net/ovpn/peer.h                    |  303 ++++
 drivers/net/ovpn/pktid.c                   |  132 ++
 drivers/net/ovpn/pktid.h                   |   85 +
 drivers/net/ovpn/proto.h                   |  115 ++
 drivers/net/ovpn/skb.h                     |   51 +
 drivers/net/ovpn/socket.c                  |  150 ++
 drivers/net/ovpn/socket.h                  |   81 +
 drivers/net/ovpn/stats.c                   |   21 +
 drivers/net/ovpn/stats.h                   |   52 +
 drivers/net/ovpn/tcp.c                     |  511 ++++++
 drivers/net/ovpn/tcp.h                     |   42 +
 drivers/net/ovpn/udp.c                     |  393 +++++
 drivers/net/ovpn/udp.h                     |   47 +
 include/net/netlink.h                      |    1 +
 include/uapi/linux/ovpn.h                  |  109 ++
 include/uapi/linux/udp.h                   |    1 +
 tools/net/ynl/ynl-gen-c.py                 |    2 +
 tools/testing/selftests/Makefile           |    1 +
 tools/testing/selftests/ovpn/Makefile      |   15 +
 tools/testing/selftests/ovpn/config        |    8 +
 tools/testing/selftests/ovpn/data64.key    |    5 +
 tools/testing/selftests/ovpn/float-test.sh |  113 ++
 tools/testing/selftests/ovpn/netns-test.sh |  118 ++
 tools/testing/selftests/ovpn/ovpn-cli.c    | 1640 ++++++++++++++++++++
 tools/testing/selftests/ovpn/run.sh        |   12 +
 tools/testing/selftests/ovpn/tcp_peers.txt |    1 +
 tools/testing/selftests/ovpn/udp_peers.txt |    5 +
 49 files changed, 8716 insertions(+)
 create mode 100644 Documentation/netlink/specs/ovpn.yaml
 create mode 100644 drivers/net/ovpn/Makefile
 create mode 100644 drivers/net/ovpn/bind.c
 create mode 100644 drivers/net/ovpn/bind.h
 create mode 100644 drivers/net/ovpn/crypto.c
 create mode 100644 drivers/net/ovpn/crypto.h
 create mode 100644 drivers/net/ovpn/crypto_aead.c
 create mode 100644 drivers/net/ovpn/crypto_aead.h
 create mode 100644 drivers/net/ovpn/io.c
 create mode 100644 drivers/net/ovpn/io.h
 create mode 100644 drivers/net/ovpn/main.c
 create mode 100644 drivers/net/ovpn/main.h
 create mode 100644 drivers/net/ovpn/netlink-gen.c
 create mode 100644 drivers/net/ovpn/netlink-gen.h
 create mode 100644 drivers/net/ovpn/netlink.c
 create mode 100644 drivers/net/ovpn/netlink.h
 create mode 100644 drivers/net/ovpn/ovpnstruct.h
 create mode 100644 drivers/net/ovpn/packet.h
 create mode 100644 drivers/net/ovpn/peer.c
 create mode 100644 drivers/net/ovpn/peer.h
 create mode 100644 drivers/net/ovpn/pktid.c
 create mode 100644 drivers/net/ovpn/pktid.h
 create mode 100644 drivers/net/ovpn/proto.h
 create mode 100644 drivers/net/ovpn/skb.h
 create mode 100644 drivers/net/ovpn/socket.c
 create mode 100644 drivers/net/ovpn/socket.h
 create mode 100644 drivers/net/ovpn/stats.c
 create mode 100644 drivers/net/ovpn/stats.h
 create mode 100644 drivers/net/ovpn/tcp.c
 create mode 100644 drivers/net/ovpn/tcp.h
 create mode 100644 drivers/net/ovpn/udp.c
 create mode 100644 drivers/net/ovpn/udp.h
 create mode 100644 include/uapi/linux/ovpn.h
 create mode 100644 tools/testing/selftests/ovpn/Makefile
 create mode 100644 tools/testing/selftests/ovpn/config
 create mode 100644 tools/testing/selftests/ovpn/data64.key
 create mode 100644 tools/testing/selftests/ovpn/float-test.sh
 create mode 100644 tools/testing/selftests/ovpn/netns-test.sh
 create mode 100644 tools/testing/selftests/ovpn/ovpn-cli.c
 create mode 100644 tools/testing/selftests/ovpn/run.sh
 create mode 100644 tools/testing/selftests/ovpn/tcp_peers.txt
 create mode 100644 tools/testing/selftests/ovpn/udp_peers.txt

Comments

Jakub Kicinski May 7, 2024, 11:48 p.m. UTC | #1
On Mon,  6 May 2024 03:16:13 +0200 Antonio Quartulli wrote:
> I am finally back with version 3 of the ovpn patchset.
> It took a while to address all comments I have received on v2, but I
> am happy to say that I addressed 99% of the feedback I collected.

Nice, one more check / warning that pops up is missing kdoc.
W=1 build only catches kdoc problems in C sources, for headers
try running something like:

./scripts/kernel-doc -none -Wall $new_files
Antonio Quartulli May 8, 2024, 9:56 a.m. UTC | #2
On 08/05/2024 01:48, Jakub Kicinski wrote:
> On Mon,  6 May 2024 03:16:13 +0200 Antonio Quartulli wrote:
>> I am finally back with version 3 of the ovpn patchset.
>> It took a while to address all comments I have received on v2, but I
>> am happy to say that I addressed 99% of the feedback I collected.
> 
> Nice, one more check / warning that pops up is missing kdoc.
> W=1 build only catches kdoc problems in C sources, for headers
> try running something like:
> 
> ./scripts/kernel-doc -none -Wall $new_files

I see there is one warning to fix due to a typ0 (eventS_wq vs event_wq), 
but I also get more warnings like this:

drivers/net/ovpn/peer.h:119: warning: Function parameter or struct 
member 'vpn_addrs' not described in 'ovpn_peer'

However vpn_addrs is an anonymous struct within struct ovpn_peer.
I have already documented all its members using the form:

@vpn_addrs.ipv4
@vpn_addrs.ipv6

Am I expected to document the vpn_addrs as well?
Or is this a false positive?

Regards,
Jakub Kicinski May 9, 2024, 12:53 a.m. UTC | #3
On Wed, 8 May 2024 11:56:45 +0200 Antonio Quartulli wrote:
> I see there is one warning to fix due to a typ0 (eventS_wq vs event_wq), 
> but I also get more warnings like this:
> 
> drivers/net/ovpn/peer.h:119: warning: Function parameter or struct 
> member 'vpn_addrs' not described in 'ovpn_peer'
> 
> However vpn_addrs is an anonymous struct within struct ovpn_peer.
> I have already documented all its members using the form:
> 
> @vpn_addrs.ipv4
> @vpn_addrs.ipv6
> 
> Am I expected to document the vpn_addrs as well?
> Or is this a false positive?

I think we need to trust the script on what's expected. 
The expectations around documenting anonymous structs may have 
changed recently, I remember fixing this in my code, too.

BTW make sure you use -Wall, people started sending trivial
patches to fix those :S Would be best not to add new ones.
Antonio Quartulli May 9, 2024, 8:41 a.m. UTC | #4
On 09/05/2024 02:53, Jakub Kicinski wrote:
> On Wed, 8 May 2024 11:56:45 +0200 Antonio Quartulli wrote:
>> I see there is one warning to fix due to a typ0 (eventS_wq vs event_wq),
>> but I also get more warnings like this:
>>
>> drivers/net/ovpn/peer.h:119: warning: Function parameter or struct
>> member 'vpn_addrs' not described in 'ovpn_peer'
>>
>> However vpn_addrs is an anonymous struct within struct ovpn_peer.
>> I have already documented all its members using the form:
>>
>> @vpn_addrs.ipv4
>> @vpn_addrs.ipv6
>>
>> Am I expected to document the vpn_addrs as well?
>> Or is this a false positive?
> 
> I think we need to trust the script on what's expected.
> The expectations around documenting anonymous structs may have
> changed recently, I remember fixing this in my code, too.

Alright, I will document those structs too then.

> 
> BTW make sure you use -Wall, people started sending trivial
> patches to fix those :S Would be best not to add new ones.

eheh, rebase -exec is my friend :-)
No warning shall pass!

Thanks a lot,