Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: antonio@openvpn.net
Cc: netdev@vger.kernel.org, ralf@mandelbit.com, sd@queasysnail.net,
	kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, stable@vger.kernel.org
Subject: Re: [PATCH net 5/7] ovpn: fix UDP TX byte accounting
Date: Fri, 23 Oct 2026 12:17:27 +0000	[thread overview]
Message-ID: <179275784775.3134.7765670827133808012@kernel.org> (raw)
In-Reply-To: <20261022121606.732029-6-antonio@openvpn.net>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] After this patch, the ovpn netdev's rx_bytes and tx_bytes
  measure different layers.

--

ovpn: fix UDP TX byte accounting

This commit resets the inner network header in ovpn_udp_send_skb() before
the skb is handed to the UDP tunnel helpers. The goal is for the ovpn
netdev TX byte counter to include the OpenVPN data-channel header and the
authentication tag.

> diff --git a/drivers/net/ovpn/udp.c b/drivers/net/ovpn/udp.c
> index 7672094a67668..05e10a2ed1791 100644
> --- a/drivers/net/ovpn/udp.c
> +++ b/drivers/net/ovpn/udp.c
> @@ -495,6 +495,9 @@ int ovpn_udp_send_skb(struct ovpn_peer *peer, struct sock *sk,
>  		return -EADDRNOTAVAIL;
>  	}
>  
> +	/* the encrypted openvpn packet is the UDP tunnel payload */
> +	skb_reset_inner_network_header(skb);
> +

[Severity: Medium]
With this change, do rx_bytes and tx_bytes on the ovpn netdev now measure
different layers?

UDP and TCP share the same RX path, and it counts the decrypted plaintext
length:

drivers/net/ovpn/io.c:ovpn_netdev_write() {
    ...
	pkt_len = skb->len;
    ...
	if (likely(ret == NET_RX_SUCCESS)) {
		/* update RX stats with the size of decrypted packet */
		ovpn_peer_stats_increment_rx(&peer->vpn_stats, pkt_len);
		dev_dstats_rx_add(peer->ovpn->dev, pkt_len);
	}
    ...
}

UDP TX goes through iptunnel_xmit() / ip6tunnel_xmit(), which compute:

	int pkt_len = skb->len - skb_inner_network_offset(skb);

The inner network header now sits at the start of the encrypted packet.
So TX counts the opcode/peer-id (4 bytes), the packet-id (4 bytes), the
auth tag (16 bytes) and the ciphertext. That is about 24 bytes per packet
that TX counts and RX does not.

In effect, netdev TX now follows the per-peer link_stats semantics, while
netdev RX follows vpn_stats.

TCP TX uses yet another convention. ovpn_tcp_send_sock() calls
dev_dstats_tx_add(peer->ovpn->dev, skb->len) after ovpn_tcp_send_skb() has
pushed the 2-byte length prefix:

	*(__be16 *)__skb_push(skb, sizeof(u16)) = htons(len);

Other users of the same UDP tunnel stats helper do the opposite. WireGuard
sets the inner network header before it pushes its own header, so that
header is not counted:

drivers/net/wireguard/send.c:encrypt_packet() {
    ...
	skb_set_inner_network_header(skb, 0);
	header = (struct message_data *)skb_push(skb, sizeof(*header));
    ...
}

Take the case the commit message calls an undercount, where the inner
header still points at the plaintext. Before this patch, UDP TX counted the
ciphertext length there. Since the tag sits in front, that equals the
plaintext length, so it matched RX.

Is TX meant to include protocol overhead when RX does not? If so, could
the commit message explain why? If not, should RX and TCP TX be changed
to use the same convention?

The mismatch is still there at the end of the series. "ovpn: fix TCP TX
accounting for locally dropped packets" leaves both the TCP TX
dev_dstats_tx_add(skb->len) call and the RX accounting unchanged.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261022121606.732029-2-antonio%40openvpn.net

  reply	other threads:[~2026-10-23 12:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 12:15 [PATCH net 0/7] pull request: fixes for ovpn 2026-10-22 Antonio Quartulli
2026-10-22 12:15 ` [PATCH net 1/7] ovpn: avoid sending UDP packets with source port 0 Antonio Quartulli
2026-10-22 12:23   ` netdev-bot+sinfo
2026-10-22 12:31     ` Antonio Quartulli
2026-10-22 12:15 ` [PATCH net 2/7] ovpn: validate sockets before attaching peer transports Antonio Quartulli
2026-10-22 12:15 ` [PATCH net 3/7] ovpn: reject UDP remotes incompatible with socket family Antonio Quartulli
2026-10-23 12:17   ` netdev-bot+sashiko
2026-10-22 12:15 ` [PATCH net 4/7] ovpn: recheck UDP socket family before transmit Antonio Quartulli
2026-10-22 12:15 ` [PATCH net 5/7] ovpn: fix UDP TX byte accounting Antonio Quartulli
2026-10-23 12:17   ` netdev-bot+sashiko [this message]
2026-10-23 14:10     ` Antonio Quartulli
2026-10-22 12:15 ` [PATCH net 6/7] ovpn: fix TCP TX accounting for locally dropped packets Antonio Quartulli
2026-10-23 12:17   ` netdev-bot+sashiko
2026-10-22 12:15 ` [PATCH net 7/7] selftests: ovpn: avoid calling freeaddrinfo() on NULL Antonio Quartulli
2026-10-23 12:17   ` netdev-bot+sashiko

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=179275784775.3134.7765670827133808012@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --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 \
    --cc=sd@queasysnail.net \
    --cc=stable@vger.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