From patchwork Mon Sep 22 11:06:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Mietus X-Patchwork-Id: 4433 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:c08a:b0:72f:f16c:e055 with SMTP id jr10csp113461mab; Mon, 22 Sep 2025 04:08:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUCfhzvuVreLQznffzDkCQiFjm054XQwjAjTN+tfNT63Edqf9BsvFrxmMi4KtMleEfX5RLqzJoJZLA=@openvpn.net X-Google-Smtp-Source: AGHT+IEr/QqTSoAubKHnxiq2kPd0UL/wzMqTbIK/YQAexIg5MYgfTJekGZgwJS3DhHrhHfbga8nA X-Received: by 2002:a05:6808:140a:b0:43b:252e:f7a4 with SMTP id 5614622812f47-43d6c11294emr6263562b6e.1.1758539290256; Mon, 22 Sep 2025 04:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1758539290; cv=none; d=google.com; s=arc-20240605; b=Iy8VLZ2HxcyaczsFSwPDsVD4OIw48k8b6EF8j72ahWPz9ZqqDMYyqVSbEFlxnqrJGL Rr+f1OL9Cg7Sdx+rEu217eMd4qJMlusayK3LVBsAJVPReS+fkJFPA2+YlqtcxsajwRFG Ya6H7lu6tnMPt1hfJHVoU096u65h60sMqauYbOf70cIJNfSmVWRAdrx3uRPXISyMfyZi EZtCrpqCQDXfDAu+JcCx+k5OJps/I6jdy/TsKwdTcXXOVsB/35h73VxnAgTx3uPab1mJ pYS/L3kkCquxqeTKdDr1TummXP/VhRbLx/QQiYLqFmLWSDzY4+tvMLoIld9SVTEUpvck HtAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:cc:reply-to:from:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=MtKjsnr6bi2tCiGewfNKqcLrBQ1TFE1OsNDhc3TqkVQ=; fh=6EbcJF2Br7Ckqvxmbzy/aBW5ZDkZ8Oeawieh63Sh7bg=; b=hjmzOf6zloQYnt8CTMlZ+Cvyal4HdiaN+RJTq5RtWEcR2Rsw+rKLck91WYgXItaTPI Ipv3ognEUim5/uowui3a+9VCPjMrCDhC2N0EGdAL6UqdyaZI93KAA3GT27NV1UU/4Nce ifsN5YQWo4eUnCoNRloBKleK48wGca00PvJ3Us9qi43SzpTN/Og8T2sMlvaYhghMuVyD 3OrG+sfNunkPrlomGo0t0PhK/+YfrrsDZiNSP+Gw6rO900I8DLgjSDe3C86l08ZMqAod Cg2IQ1AN3HwKyK2+BrxD179OcuqC+of3h8GezjEEVUWlBltE645ASiVCw6rJtuNoMSmG EWqg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=WaameL0i; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=kT9XwTNr; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=R5kxxHDA; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=tdN1AnvE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5614622812f47-43f2664af8bsi6904b6e.47.2025.09.22.04.08.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Sep 2025 04:08:10 -0700 (PDT) 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=WaameL0i; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=kT9XwTNr; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=R5kxxHDA; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=tdN1AnvE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-ID:Date:To:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MtKjsnr6bi2tCiGewfNKqcLrBQ1TFE1OsNDhc3TqkVQ=; b=WaameL0iExLO+FBD1hQ4XeqVwF Lk5heKtHJd3MT33YZ7NlyMQX1NevsYGV4PdfhSLKxd5Dt1fKTVNiC8FeApjVPAoMiZsxmiIpeTY0q n+3zNgoa5uJyQ8YyrqhZ4bKIyfvwJdg0msLqZE76gkmdlVbBhTJxndEwGswu2S+CEIJ0=; 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.95) (envelope-from ) id 1v0eOt-0001E6-2W; Mon, 22 Sep 2025 11:08:07 +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.95) (envelope-from ) id 1v0eOr-0001Dq-3T for openvpn-devel@lists.sourceforge.net; Mon, 22 Sep 2025 11:08:05 +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:Cc:To:From:Sender:Reply-To: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-Subscribe:List-Post:List-Owner:List-Archive; bh=JfrMVsjRzPVWbBC1MsCrURXDxbMuSWEYSeJAeOyrtZQ=; b=kT9XwTNr6AV5MZ8+Kcz1GP4ymA dHtNonDsUeZkbIVH6ji39gdHQxkZ6cq5enZlzRZDB1QFSJbEeN8GOrqBaG17BAk9jcBr9htfPX8nR muiGeVinZMz3uFSxL8eNwe7gtKHDnPSQbKjZt5f/4C56PtjNJDByppyyOhD2Vr9BjQ8w=; 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:Cc:To:From:Sender:Reply-To: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-Subscribe: List-Post:List-Owner:List-Archive; bh=JfrMVsjRzPVWbBC1MsCrURXDxbMuSWEYSeJAeOyrtZQ=; b=R5kxxHDAte4/1Q2bkQtdiGHV4i RG8QFX5ylH4Ixdo2a/at+wAzVAEE0MDr8VcDu5t5Wx1gE+piaTsJsRgFAxaJarU6OklvjC+J+7KAZ 0c7VUJVuC+XaaozDBxFw6rlOSMmBaxiBDpGEtsJ9uYT72/balxA/n79xgH6g/xwZiGtc=; Received: from sonic302-21.consmr.mail.ne1.yahoo.com ([66.163.186.147]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1v0eOq-00052Z-Gg for openvpn-devel@lists.sourceforge.net; Mon, 22 Sep 2025 11:08:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1758539278; bh=JfrMVsjRzPVWbBC1MsCrURXDxbMuSWEYSeJAeOyrtZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=tdN1AnvELX5tOdPTSYndSRydwsE3qDFfC8CzKP8jGBx7rQwCG9vPGQkHlWKIhKrDo/rydkg1zSoqk3G8JCK4ejpj8D5IIaBySQVrBM9ak/JSHgUKIW5aqLoib71VEEdwo8nNDY1YD2ymHUnc58x5IiFWpT/iB82M4VhUY1WpM0T7F9qZzD16EIZ+UGaDJ8vp6QDYitn09mh+mPyCqGYYQJ4xPeccNIvj4lOdSgRvhErd7T13KHaMMFfIgCbxUPCXAtszbPPnb3viDATe20BVPHd+qqLzSjH5VDhylqMqhaokV6BwkTReqKkj+zsZGF7jc5QHiVrP5P3bzFMKyrIC6g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1758539278; bh=lys70/mYbBBkDgTMA5h6AoQtrdq5ew+VAylAWw7YKDS=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Hq8HTFJRgFf7ZJ3v0Y/H4Xn4s3ClyohCRcYTwyUnOlDvq9pmZmVLKv/HSeUNDrXBNBJNHP9Wa7h3PCHaB88XSNlYvWL+KROk73r1MXq7TdrefYNh0tum1nZta/WeDyOVi0R5KodVxz/REsJFXl78p4jrFHF5wmepZHyX3C0gwGOOSk/m0QmW+WWYdasZ7qmGDHr33hVifXD3UXmt/gBAAe2Qr8HqPdegYgE+bz06Hes7u9x3aKgxfdIur8FkbKJZYGouq+ayNzgL5enO7aa044Q2S0HL0+opcl8xEl+VXEaxYaZt/MFINRAxn+T+uYiKVoudKl4es+1Wn0XuPmcMFQ== X-YMail-OSG: zEHXE4kVM1nFQa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MeGS8DLLxSXFDQf9i838ef0rNCAJTVr4TsnS_vplruj8d8j8UqEc. QBo1q8IRG7JIN52otlXWTYI1YWYT3AywUtFz.gQ9aqUpa31ua8w-- X-Sonic-MF: X-Sonic-ID: c8c88a48-395a-4e8a-a1ed-b394fd7b7f43 Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ne1.yahoo.com with HTTP; Mon, 22 Sep 2025 11:07:58 +0000 Received: by hermes--production-ir2-74585cff4f-4sjhz (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID ca5bfbd718d89396be3325d48d68935b; Mon, 22 Sep 2025 11:07:53 +0000 (UTC) To: netdev@vger.kernel.org, sd@queasysnail.net, antonio@openvpn.net Date: Mon, 22 Sep 2025 13:06:22 +0200 Message-ID: <20250922110622.10368-4-mmietus97@yahoo.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250922110622.10368-1-mmietus97@yahoo.com> References: <20250922110622.10368-1-mmietus97@yahoo.com> MIME-Version: 1.0 Content-Length: 2742 X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.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_udp{4, 6}_output unnecessarily references the dst_entry from the dst_cache. Reduce this overhead by using the newly implemented udp_tunnel{, 6}_xmit_skb_noref function and dst_cache helpers. These changes are safe as both ipv4 and ip6 support noref xmit under RCU which is already the case for ovpn. Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [mmietus97(at)yahoo.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [mmietus97(at)yahoo.com] 0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [66.163.186.147 listed in wl.mailspike.net] X-Headers-End: 1v0eOq-00052Z-Gg Subject: [Openvpn-devel] [PATCH net-next v3 3/3] net: ovpn: use new noref xmit flow in ovpn_udp{4, 6}_output 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: , X-Patchwork-Original-From: Marek Mietus via Openvpn-devel From: Marek Mietus Reply-To: Marek Mietus Cc: openvpn-devel@lists.sourceforge.net Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1843962095058442904?= X-GMAIL-MSGID: =?utf-8?q?1843962095058442904?= ovpn_udp{4,6}_output unnecessarily references the dst_entry from the dst_cache. Reduce this overhead by using the newly implemented udp_tunnel{,6}_xmit_skb_noref function and dst_cache helpers. These changes are safe as both ipv4 and ip6 support noref xmit under RCU which is already the case for ovpn. Signed-off-by: Marek Mietus --- drivers/net/ovpn/udp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/ovpn/udp.c b/drivers/net/ovpn/udp.c index d6a0f7a0b75d..917cd308a7f4 100644 --- a/drivers/net/ovpn/udp.c +++ b/drivers/net/ovpn/udp.c @@ -158,7 +158,7 @@ static int ovpn_udp4_output(struct ovpn_peer *peer, struct ovpn_bind *bind, int ret; local_bh_disable(); - rt = dst_cache_get_ip4(cache, &fl.saddr); + rt = dst_cache_get_ip4_rcu(cache, &fl.saddr); if (rt) goto transmit; @@ -194,12 +194,12 @@ static int ovpn_udp4_output(struct ovpn_peer *peer, struct ovpn_bind *bind, ret); goto err; } - dst_cache_set_ip4(cache, &rt->dst, fl.saddr); + dst_cache_steal_ip4(cache, &rt->dst, fl.saddr); transmit: - udp_tunnel_xmit_skb(rt, sk, skb, fl.saddr, fl.daddr, 0, - ip4_dst_hoplimit(&rt->dst), 0, fl.fl4_sport, - fl.fl4_dport, false, sk->sk_no_check_tx, 0); + udp_tunnel_xmit_skb_noref(rt, sk, skb, fl.saddr, fl.daddr, 0, + ip4_dst_hoplimit(&rt->dst), 0, fl.fl4_sport, + fl.fl4_dport, false, sk->sk_no_check_tx, 0); ret = 0; err: local_bh_enable(); @@ -235,7 +235,7 @@ static int ovpn_udp6_output(struct ovpn_peer *peer, struct ovpn_bind *bind, }; local_bh_disable(); - dst = dst_cache_get_ip6(cache, &fl.saddr); + dst = dst_cache_get_ip6_rcu(cache, &fl.saddr); if (dst) goto transmit; @@ -259,7 +259,7 @@ static int ovpn_udp6_output(struct ovpn_peer *peer, struct ovpn_bind *bind, &bind->remote.in6, ret); goto err; } - dst_cache_set_ip6(cache, dst, &fl.saddr); + dst_cache_steal_ip6(cache, dst, &fl.saddr); transmit: /* user IPv6 packets may be larger than the transport interface @@ -269,12 +269,12 @@ static int ovpn_udp6_output(struct ovpn_peer *peer, struct ovpn_bind *bind, * fragment packets if needed. * * NOTE: this is not needed for IPv4 because we pass df=0 to - * udp_tunnel_xmit_skb() + * udp_tunnel_xmit_skb_noref() */ skb->ignore_df = 1; - udp_tunnel6_xmit_skb(dst, sk, skb, skb->dev, &fl.saddr, &fl.daddr, 0, - ip6_dst_hoplimit(dst), 0, fl.fl6_sport, - fl.fl6_dport, udp_get_no_check6_tx(sk), 0); + udp_tunnel6_xmit_skb_noref(dst, sk, skb, skb->dev, &fl.saddr, &fl.daddr, 0, + ip6_dst_hoplimit(dst), 0, fl.fl6_sport, + fl.fl6_dport, udp_get_no_check6_tx(sk), 0); ret = 0; err: local_bh_enable();