From patchwork Mon Nov 9 15:08:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Lici X-Patchwork-Id: 5629 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:63cb:10b0:11a:a05e:cb97 with SMTP id w11-n1csp802989lat; Mon, 9 Nov 2026 07:09:35 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErG/rh5rrYEHwQR2L55oKm9tmiqOyGmjh5cZvV7MbC7/a4I78bfguAa7NwLFBgm3FN5vGdTYY+c4hPI=@openvpn.net X-Received: by 2002:a05:7301:4184:b0:369:d8e1:7bb6 with SMTP id 5a478bee46e88-3725dd5b724mr9764737eec.25.1794236975120; Mon, 09 Nov 2026 07:09:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794236975; cv=none; d=google.com; s=arc-20260327; b=J1fZSMBaNDvgxl+DSw+fi/aqgezUSaUKdqOpalIJ3gposWuWjwiVhbBK8VuKa83Fkd /s/z1pmCZGcXkYqgTS+nQFD0O4jvDfQcPSRZqPkzQCBurkNs8k7AVUnz8ByCbI3P54ij zKIHGtM+p+gezCjghp63265OXbqrRj6YG1jgcjyHFGecWgeYvwI8oXNCtwyFvhqpExGe CDsoonUZdYhFvRMarPJFNHxX/slgHLj/Sw6bvYWPvUXHtFEzh96IBYW9/cBCPglwnc2J +ThChQL2uLXUd+zJ+gr7I7ZQmtuZcx7ZFb0pe5Y0l1wOdfZnrOTCqMFpMN5zKj10M0+u h7mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=SIXYczPTdIitmzjlXxErsLSQ2Mo3GUzDqiadpVUYBOk=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=V/e3F2AAlh+y7bpLpljr98wi4+tnxfm+1nT/thHk4fyWU4wnklGzUlxSzdQ/RXcas/ OuUXo811q5ELJPw7QlbR/dydSeV3Zp4NG0mNMwhS650HUGzSrZ3sMl8UNSAVmCNCadDw gNsLHiaVSYWN2yRuUqRq+/3o7Sh/dTAWo/TkPmfWp+qImr2OBQubThjtCBZYozDKjrP2 e8l/fsBvbjWH+CoCyfWFNo3ut7EFUkMuKDx5IvWpRV/TkZd9+Sb3Qgqn0HTlz2Kb5wsb loYfBT7OtaJO3ehoVgap/N4IvPwSQhyNb+X2PcYPTaNEbzssWrqlhmv9ySRKzleSN4dH oydw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=ex+i+MS6; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="DS/dw1M/"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="b7Ew/dl8"; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=gAh1skH3; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-372662e5030si15832462eec.62.2026.11.09.07.09.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2026 07:09:35 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=ex+i+MS6; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="DS/dw1M/"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="b7Ew/dl8"; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=gAh1skH3; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=SIXYczPTdIitmzjlXxErsLSQ2Mo3GUzDqiadpVUYBOk=; b=ex+i+MS6L2h106 xYoQdSTEMwq4ukaysyfCmPiFz1TxuC4E4mWYo4wPTtqdjKsx9T/oF/pFRjpxDnXFiiHVuGLjunzeI AqCdwrViwRkWk0vw8TderUUgVn/+dcv2ojp9mNaCH5vPlhluyzdHh7KCvKbbIp4Ty9xCHJy27UBUe 6Ig=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xQR02-0000000077C-00Qg; Mon, 09 Nov 2026 15:09:34 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xQQzx-0000000076n-3yJN for openvpn-devel@lists.sourceforge.net; Mon, 09 Nov 2026 15:09:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=DsUvHiZzA0X3d9MB8xLhFqQ6M0QUsqOo7UhbLt7FMEg=; b=DS/dw1M/dVuNayUnFS2E2CbmW/ F+X4z0Flm3ZT6BsqnGgkSFIRUsdGONpGGCUA2hjBf+hCG3s98Lepa0+6y2TqAtAFh36Nn2lAhCdmx OEOL6+J50UR+3z7ExgJ2VVapJfR4G42E1r2rJnjvaqPCRrd5iWFbXebqHfbXRNbTMXg4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DsUvHiZzA0X3d9MB8xLhFqQ6M0QUsqOo7UhbLt7FMEg=; b=b7Ew/dl82BFliBld9QAI2DXTNf 0opW6a9+T1PfBnA4Ea4s/tF53bPGp4SjZapc3HYEFh2mbD/LDIN3ZblnDov+i+IHj64/bQnmdvJfX hnqJt2x3dYQwDXi3w3lqGWp9t8n5txhpgBxIAswRz7XNUHuKsMiWhoNOUUVpj5JDhaCk=; Received: from mout-b-110.mailbox.org ([195.10.208.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xQQzu-000000000Ec-1TVq for openvpn-devel@lists.sourceforge.net; Mon, 09 Nov 2026 15:09:29 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-110.mailbox.org (Postfix) with ESMTPS id 4jNY8s5c77zNlbJ for ; Mon, 09 Nov 2026 16:09:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1794236958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DsUvHiZzA0X3d9MB8xLhFqQ6M0QUsqOo7UhbLt7FMEg=; b=gAh1skH3XW8ha7BAhbkIBWyC/EyGXTLe+GuGK4usymDAh1GPzKbZVEERfB7FTEeYAYQbMj nMtkGuT46LM2Nh5LDNw1DJOhyDtH6FU4AAnoUEy5ZEeEBGBMg0HsNQxsf40dDfXZxdM9E7 yIHenU7fe4jIE+HvHIK/TJq2Kw7ZE1LK5ffAozKZb7qgL61lZj2rBlLjo12FUZdVrCLXyX 1vNMm9cHZyM3Pj/TF/+tZjpH+aFGLJOblPndN9lF48JEmbjprmn3LfxCPeJjOaKc4/kdw/ y2Hni4RthwYM/MvnOdIU87Krvf0YD4PUiHJ9bX30ksX3WhPQBLQ6Q7r5i90Ljw== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::2 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: openvpn-devel@lists.sourceforge.net Date: Mon, 9 Nov 2026 16:08:59 +0100 Message-ID: <1025ad1b437a4eb410967703dfd784a4ba8c30f5.1794234673.git.ralf@mandelbit.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jNY8s5c77zNlbJ X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: ovpn already advertises software GSO support and segments GSO skbs in its transmit path. However, without checksum offload in the device features, the networking core has to segment GSO packets before [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-Headers-End: 1xQQzu-000000000Ec-1TVq Subject: [Openvpn-devel] [PATCH ovpn net-next v4 1/9] ovpn: advertise checksum offload for GSO packets X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1881393830809521738 X-GMAIL-MSGID: 1881393830809521738 ovpn already advertises software GSO support and segments GSO skbs in its transmit path. However, without checksum offload in the device features, the networking core has to segment GSO packets before they reach ovpn because TCP GSO packets normally carry CHECKSUM_PARTIAL state. Advertise NETIF_F_HW_CSUM so the stack can pass such packets to ovpn. Complete partial checksums after any GSO segmentation and before submitting packets for encryption, since the inner packet checksum can no longer be fixed after the packet has been encrypted. Also pass the ovpn feature set to skb_gso_segment with GSO capabilities masked out: this forces software segmentation, but still lets the segmenter preserve supported non-GSO properties such as non-linear skb data instead of needlessly linearizing. Account peer packet statistics for every segment which survives segmentation rather than once for the original GSO skb. Signed-off-by: Ralf Lici --- No changes since v3 https://lore.kernel.org/openvpn-devel/1025ad1b437a4eb410967703dfd784a4ba8c30f5.1794223133.git.ralf@mandelbit.com/ Changes since v2 https://lore.kernel.org/openvpn-devel/20261102164353.459969-2-ralf@mandelbit.com/ - Account peer packet statistics for every segment which survives GSO segmentation rather than once for the original GSO skb. (Sashiko) No changes since v1 https://lore.kernel.org/openvpn-devel/1bbfde37488ade61928554db3a119525adf7b608.1790843153.git.ralf@mandelbit.com/ drivers/net/ovpn/io.c | 23 ++++++++++++++++++++--- drivers/net/ovpn/main.c | 2 +- drivers/net/ovpn/stats.h | 10 +++++++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/net/ovpn/io.c b/drivers/net/ovpn/io.c index f14eb4e6c46a..3b0c9b30e879 100644 --- a/drivers/net/ovpn/io.c +++ b/drivers/net/ovpn/io.c @@ -356,6 +356,7 @@ netdev_tx_t ovpn_net_xmit(struct sk_buff *skb, struct net_device *dev) struct ovpn_priv *ovpn = netdev_priv(dev); struct sk_buff *segments, *curr, *next; struct sk_buff_head skb_list; + netdev_features_t features; unsigned int tx_bytes = 0; struct ovpn_peer *peer; __be16 proto; @@ -390,8 +391,13 @@ netdev_tx_t ovpn_net_xmit(struct sk_buff *skb, struct net_device *dev) skb_dst_drop(skb); if (skb_is_gso(skb)) { - segments = skb_gso_segment(skb, 0); - if (IS_ERR(segments)) { + /* force software segmentation, but keep ovpn's non-GSO feature + * bits so the generated segments can preserve non-linear skb + * data where possible + */ + features = netif_skb_features(skb); + segments = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); + if (IS_ERR_OR_NULL(segments)) { ret = PTR_ERR(segments); net_err_ratelimited("%s: cannot segment payload packet: %d\n", netdev_name(dev), ret); @@ -416,6 +422,16 @@ netdev_tx_t ovpn_net_xmit(struct sk_buff *skb, struct net_device *dev) continue; } + /* NETIF_F_HW_CSUM requires completing partial checksums */ + if (unlikely(curr->ip_summed == CHECKSUM_PARTIAL && + skb_checksum_help(curr) < 0)) { + net_err_ratelimited("%s: skb_checksum_help failed for payload packet\n", + netdev_name(dev)); + ovpn_dev_dstats_tx_dropped(ovpn->dev); + kfree_skb(curr); + continue; + } + /* only count what we actually send */ tx_bytes += curr->len; __skb_queue_tail(&skb_list, curr); @@ -430,7 +446,8 @@ netdev_tx_t ovpn_net_xmit(struct sk_buff *skb, struct net_device *dev) } skb_list.prev->next = NULL; - ovpn_peer_stats_increment_tx(&peer->vpn_stats, tx_bytes); + ovpn_peer_stats_add_tx(&peer->vpn_stats, tx_bytes, + skb_queue_len(&skb_list)); ovpn_send(ovpn, skb_list.next, peer); return NETDEV_TX_OK; diff --git a/drivers/net/ovpn/main.c b/drivers/net/ovpn/main.c index 0708249e9607..28e1eb06e127 100644 --- a/drivers/net/ovpn/main.c +++ b/drivers/net/ovpn/main.c @@ -157,7 +157,7 @@ static const struct ethtool_ops ovpn_ethtool_ops = { static void ovpn_setup(struct net_device *dev) { - netdev_features_t feat = NETIF_F_SG | NETIF_F_GSO | + netdev_features_t feat = NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_GSO | NETIF_F_GSO_SOFTWARE | NETIF_F_HIGHDMA; dev->needs_free_netdev = true; diff --git a/drivers/net/ovpn/stats.h b/drivers/net/ovpn/stats.h index 3a45b97c0056..9331f5e9179b 100644 --- a/drivers/net/ovpn/stats.h +++ b/drivers/net/ovpn/stats.h @@ -40,10 +40,18 @@ static inline void ovpn_peer_stats_increment_rx(struct ovpn_peer_stats *stats, ovpn_peer_stats_increment(&stats->rx, n); } +static inline void ovpn_peer_stats_add_tx(struct ovpn_peer_stats *stats, + const unsigned int bytes, + unsigned int packets) +{ + atomic64_add(bytes, &stats->tx.bytes); + atomic64_add(packets, &stats->tx.packets); +} + static inline void ovpn_peer_stats_increment_tx(struct ovpn_peer_stats *stats, const unsigned int n) { - ovpn_peer_stats_increment(&stats->tx, n); + ovpn_peer_stats_add_tx(stats, n, 1); } static inline void ovpn_dev_dstats_tx_dropped(struct net_device *dev)