Skip to contentSkip to conversation

pull request: ovpn for net 2025-07-16

PATCH Applied Antonio Quartulli 2 participants 5 messages Jul 16, 2025 – Jul 17, 2025

Subsystems (4)
lore
Share & tools
lore

Antonio Quartulli

author maintainer
#0 lore raw

cover pull request: ovpn for net 2025-07-16

Hi netdev-team,
[2025-07-16: patch 2 reworked to use attribute subsets in yaml spec]

In this batch you can find the following bug fixes:

Patch 1: make sure to propagate any socket FW mark set by userspace (via SO_MARK) to skbs being sent over that socket.

Patch 2: reject unexpected netlink attributes in user requests. This was partly open-coded and partly implemented via ovpn.yaml spec.

Patch 3: reset the skb's GSO state when moving a packet from transport to tunnel layer.

Please pull or let me know of any issue!

Thanks a lot.
Antonio,

The following changes since commit dae7f9cbd1909de2b0bccc30afef95c23f93e477:

Merge branch 'mptcp-fix-fallback-related-races' (2025-07-15 17:31:30 -0700)

are available in the Git repository at:

https://github.com/OpenVPN/ovpn-net-next tags/ovpn-net-20250716

for you to fetch changes up to 2022d704014d7a5b19dfe0a1ae5c67be0498e37c:

ovpn: reset GSO metadata after decapsulation (2025-07-16 11:53:19 +0200)

----------------------------------------------------------------
This bugfix batch includes the following changes:
* properly propagate sk mark to skb->mark field
* reject unexpected incoming netlink attributes
* reset GSO state when moving skb from transport to tunnel layer

----------------------------------------------------------------
Antonio Quartulli (1):
ovpn: reject unexpected netlink attributes

Ralf Lici (2):
ovpn: propagate socket mark to skb in UDP
ovpn: reset GSO metadata after decapsulation

 Documentation/netlink/specs/ovpn.yaml | 153 ++++++++++++++++++++++++++++++++--
 drivers/net/ovpn/io.c                 |   7 ++
 drivers/net/ovpn/netlink-gen.c        |  61 ++++++++++++--
 drivers/net/ovpn/netlink-gen.h        |   6 ++
 drivers/net/ovpn/netlink.c            |  51 ++++++++++--
 drivers/net/ovpn/udp.c                |   1 +
 6 files changed, 259 insertions(+), 20 deletions(-)
author maintainer
#1 lore raw

PATCH 1/3 ovpn: propagate socket mark to skb in UDP

From: Ralf Lici <[email protected]>

OpenVPN allows users to configure a FW mark on sockets used to communicate with other peers. The mark is set by means of the SO_MARK Linux socket option.

However, in the ovpn UDP code path, the socket's sk_mark value is currently ignored and it is not propagated to outgoing skbs.

This commit ensures proper inheritance of the field by setting skb->mark to sk->sk_mark before handing the skb to the network stack for transmission.

---
 drivers/net/ovpn/udp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ovpn/udp.c +1 -0
index bff00946eae2..60435a21f29c 100644
@@ -344,6 +344,7 @@ void ovpn_udp_send_skb(struct ovpn_peer *peer, struct sock *sk,
 	int ret;
 
 	skb->dev = peer->ovpn->dev;
+	skb->mark = READ_ONCE(sk->sk_mark);
 	/* no checksum performed at this layer */
 	skb->ip_summed = CHECKSUM_NONE;
 
Signature · 1 line
2.49.1
#2 lore raw

Re: [PATCH net 1/3] ovpn: propagate socket mark to skb in UDP

This series was applied to netdev/net.git (main) by Antonio Quartulli <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Antonio Quartulli <[email protected]>:

Quoted 10 lines · On Wed, 16 Jul 2025 13:54:41 +0200 you wrote:

From: Ralf Lici <[email protected]>

OpenVPN allows users to configure a FW mark on sockets used to communicate with other peers. The mark is set by means of the SO_MARK Linux socket option.

However, in the ovpn UDP code path, the socket's sk_mark value is currently ignored and it is not propagated to outgoing skbs.

[...]

Here is the summary with links:
- [net,1/3] ovpn: propagate socket mark to skb in UDP

    https://git.kernel.org/netdev/net/c/4c88cfcc6738
  - [net,2/3] ovpn: reject unexpected netlink attributes
    https://git.kernel.org/netdev/net/c/af52020fc599
  - [net,3/3] ovpn: reset GSO metadata after decapsulation
    https://git.kernel.org/netdev/net/c/2022d704014d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
author maintainer
#3 lore raw

PATCH 2/3 ovpn: reject unexpected netlink attributes

In reply to Antonio Quartulli

Netlink ops do not expect all attributes to be always set, however this condition is not explicitly coded any where, leading the user to believe that all sent attributes are somewhat processed.

Fix this behaviour by introducing explicit checks.

For CMD_OVPN_PEER_GET and CMD_OVPN_KEY_GET directly open-code the needed condition in the related ops handlers.
While for all other ops use attribute subsets in the ovpn.yaml spec file.

Fixes b7a63391aa98 ("ovpn: add basic netlink support")
---
 Documentation/netlink/specs/ovpn.yaml | 153 +++++++++++++++++++++++++-
 drivers/net/ovpn/netlink-gen.c        |  61 +++++++++-
 drivers/net/ovpn/netlink-gen.h        |   6 +
 drivers/net/ovpn/netlink.c            |  51 +++++++--
 4 files changed, 251 insertions(+), 20 deletions(-)
Documentation/netlink/specs/ovpn.yaml +147 -6
index 096c51f0c69a..ba76426a542d 100644
@@ -160,6 +160,66 @@ attribute-sets:
         name: link-tx-packets
         type: uint
         doc: Number of packets transmitted at the transport level
+  -
+    name: peer-new-input
+    subset-of: peer
+    attributes:
+      -
+        name: id
+      -
+        name: remote-ipv4
+      -
+        name: remote-ipv6
+      -
+        name: remote-ipv6-scope-id
+      -
+        name: remote-port
+      -
+        name: socket
+      -
+        name: vpn-ipv4
+      -
+        name: vpn-ipv6
+      -
+        name: local-ipv4
+      -
+        name: local-ipv6
+      -
+        name: keepalive-interval
+      -
+        name: keepalive-timeout
+  -
+    name: peer-set-input
+    subset-of: peer
+    attributes:
+      -
+        name: id
+      -
+        name: remote-ipv4
+      -
+        name: remote-ipv6
+      -
+        name: remote-ipv6-scope-id
+      -
+        name: remote-port
+      -
+        name: vpn-ipv4
+      -
+        name: vpn-ipv6
+      -
+        name: local-ipv4
+      -
+        name: local-ipv6
+      -
+        name: keepalive-interval
+      -
+        name: keepalive-timeout
+  -
+    name: peer-del-input
+    subset-of: peer
+    attributes:
+      -
+        name: id
   -
     name: keyconf
     attributes:
@@ -216,6 +276,33 @@ attribute-sets:
           obtain the actual cipher IV
         checks:
           exact-len: nonce-tail-size
+
+  -
+    name: keyconf-get
+    subset-of: keyconf
+    attributes:
+      -
+        name: peer-id
+      -
+        name: slot
+      -
+        name: key-id
+      -
+        name: cipher-alg
+  -
+    name: keyconf-swap-input
+    subset-of: keyconf
+    attributes:
+      -
+        name: peer-id
+  -
+    name: keyconf-del-input
+    subset-of: keyconf
+    attributes:
+      -
+        name: peer-id
+      -
+        name: slot
   -
     name: ovpn
     attributes:
@@ -235,12 +322,66 @@ attribute-sets:
         type: nest
         doc: Peer specific cipher configuration
         nested-attributes: keyconf
+  -
+    name: ovpn-peer-new-input
+    subset-of: ovpn
+    attributes:
+      -
+        name: ifindex
+      -
+        name: peer
+        nested-attributes: peer-new-input
+  -
+    name: ovpn-peer-set-input
+    subset-of: ovpn
+    attributes:
+      -
+        name: ifindex
+      -
+        name: peer
+        nested-attributes: peer-set-input
+  -
+    name: ovpn-peer-del-input
+    subset-of: ovpn
+    attributes:
+      -
+        name: ifindex
+      -
+        name: peer
+        nested-attributes: peer-del-input
+  -
+    name: ovpn-keyconf-get
+    subset-of: ovpn
+    attributes:
+      -
+        name: ifindex
+      -
+        name: keyconf
+        nested-attributes: keyconf-get
+  -
+    name: ovpn-keyconf-swap-input
+    subset-of: ovpn
+    attributes:
+      -
+        name: ifindex
+      -
+        name: keyconf
+        nested-attributes: keyconf-swap-input
+  -
+    name: ovpn-keyconf-del-input
+    subset-of: ovpn
+    attributes:
+      -
+        name: ifindex
+      -
+        name: keyconf
+        nested-attributes: keyconf-del-input
 
 operations:
   list:
     -
       name: peer-new
-      attribute-set: ovpn
+      attribute-set: ovpn-peer-new-input
       flags: [ admin-perm ]
       doc: Add a remote peer
       do:
@@ -252,7 +393,7 @@ operations:
             - peer
     -
       name: peer-set
-      attribute-set: ovpn
+      attribute-set: ovpn-peer-set-input
       flags: [ admin-perm ]
       doc: modify a remote peer
       do:
@@ -286,7 +427,7 @@ operations:
             - peer
     -
       name: peer-del
-      attribute-set: ovpn
+      attribute-set: ovpn-peer-del-input
       flags: [ admin-perm ]
       doc: Delete existing remote peer
       do:
@@ -316,7 +457,7 @@ operations:
             - keyconf
     -
       name: key-get
-      attribute-set: ovpn
+      attribute-set: ovpn-keyconf-get
       flags: [ admin-perm ]
       doc: Retrieve non-sensitive data about peer key and cipher
       do:
@@ -331,7 +472,7 @@ operations:
             - keyconf
     -
       name: key-swap
-      attribute-set: ovpn
+      attribute-set: ovpn-keyconf-swap-input
       flags: [ admin-perm ]
       doc: Swap primary and secondary session keys for a specific peer
       do:
@@ -350,7 +491,7 @@ operations:
       mcgrp: peers
     -
       name: key-del
-      attribute-set: ovpn
+      attribute-set: ovpn-keyconf-del-input
       flags: [ admin-perm ]
       doc: Delete cipher key for a specific peer
       do:
drivers/net/ovpn/netlink-gen.c +55 -6

103 lines not on this page · raw message

drivers/net/ovpn/netlink-gen.h +6 -0
index 66a4e4a0a055..220b5b2fdd4f 100644
@@ -13,8 +13,14 @@
 
 /* Common nested types */
 extern const struct nla_policy ovpn_keyconf_nl_policy[OVPN_A_KEYCONF_DECRYPT_DIR + 1];
+extern const struct nla_policy ovpn_keyconf_del_input_nl_policy[OVPN_A_KEYCONF_SLOT + 1];
+extern const struct nla_policy ovpn_keyconf_get_nl_policy[OVPN_A_KEYCONF_CIPHER_ALG + 1];
+extern const struct nla_policy ovpn_keyconf_swap_input_nl_policy[OVPN_A_KEYCONF_PEER_ID + 1];
 extern const struct nla_policy ovpn_keydir_nl_policy[OVPN_A_KEYDIR_NONCE_TAIL + 1];
 extern const struct nla_policy ovpn_peer_nl_policy[OVPN_A_PEER_LINK_TX_PACKETS + 1];
+extern const struct nla_policy ovpn_peer_del_input_nl_policy[OVPN_A_PEER_ID + 1];
+extern const struct nla_policy ovpn_peer_new_input_nl_policy[OVPN_A_PEER_KEEPALIVE_TIMEOUT + 1];
+extern const struct nla_policy ovpn_peer_set_input_nl_policy[OVPN_A_PEER_KEEPALIVE_TIMEOUT + 1];
 
 int ovpn_nl_pre_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
 		     struct genl_info *info);
drivers/net/ovpn/netlink.c +43 -8

111 lines not on this page · raw message

Signature · 1 line
2.49.1
author maintainer
#4 lore raw

PATCH 3/3 ovpn: reset GSO metadata after decapsulation

In reply to Antonio Quartulli

From: Ralf Lici <[email protected]>

The ovpn_netdev_write() function is responsible for injecting decapsulated and decrypted packets back into the local network stack.

Prior to this patch, the skb could retain GSO metadata from the outer, encrypted tunnel packet. This original GSO metadata, relevant to the sender's transport context, becomes invalid and misleading for the tunnel/data path once the inner packet is exposed.

Leaving this stale metadata intact causes internal GSO validation checks further down the kernel's network stack (validate_xmit_skb()) to fail, leading to packet drops. The reasons for these failures vary by protocol, for example:
- for ICMP, no offload handler is registered;
- for TCP and UDP, the respective offload handlers return errors when comparing skb->len to the outdated skb_shinfo(skb)->gso_size.

By calling skb_gso_reset(skb) we ensure the inner packet is presented to gro_cells_receive() with a clean state, correctly indicating it is an individual packet from the perspective of the local stack.

This change eliminates the "Driver has suspect GRO implementation, TCP performance may be compromised" warning and improves overall TCP performance by allowing GSO/GRO to function as intended on the decapsulated traffic.

---
 drivers/net/ovpn/io.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/ovpn/io.c +7 -0
index ebf1e849506b..3e9e7f8444b3 100644
@@ -62,6 +62,13 @@ static void ovpn_netdev_write(struct ovpn_peer *peer, struct sk_buff *skb)
 	unsigned int pkt_len;
 	int ret;
 
+	/*
+	 * GSO state from the transport layer is not valid for the tunnel/data
+	 * path. Reset all GSO fields to prevent any further GSO processing
+	 * from entering an inconsistent state.
+	 */
+	skb_gso_reset(skb);
+
 	/* we can't guarantee the packet wasn't corrupted before entering the
 	 * VPN, therefore we give other layers a chance to check that
 	 */
Signature · 1 line
2.49.1