From patchwork Mon Sep 22 11:06:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Mietus X-Patchwork-Id: 4432 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:c08a:b0:72f:f16c:e055 with SMTP id jr10csp113140mab; Mon, 22 Sep 2025 04:07:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUrIsDRf6YAKC3KjL9gbDSR2IIhhMWUXVV4x9b2NwL2AHIaAKfZFyVQoOVa5NiyCfFgLzzkk2C3Dlo=@openvpn.net X-Google-Smtp-Source: AGHT+IF2ogL4kFgZmuyUnHPTqrtGlBDELr0f9yJeA2/Eghon7kKhb+46B2O9WeiCF3bXILYek0VH X-Received: by 2002:a05:6808:4f54:b0:43d:2bbe:bfba with SMTP id 5614622812f47-43d6c2453camr6712547b6e.23.1758539261648; Mon, 22 Sep 2025 04:07:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1758539261; cv=none; d=google.com; s=arc-20240605; b=V3CZ7C8hTUDwYz7E6vbblQcqm5PnL/SWujM1H9m9fe9CsggMT/lqgflwDhSbIOIFtf dwU7/1DSnku315D24vFWMbulD+yGxEi+AFwPl8GBln+fjqiyrKHVkpI9C59PGV0hjcHm oEMbs30m+BCd8chp5XOXGFQEWLmUf3dJF9FyY3CpEuXBPu0KhA2Asnedc1TnlXA/czHd 831LQ13LEcJcvB1XU3rcXK+v787NV5ridJFjSBtBN8tY3BMSi1Rwr2N9hJEjqrIDqile Oo4Etj/nM/R7eVUM7hIYjLLcg7/l6sAzRPlTWTZ1ArZcrPuM+MQaGlEkhomfakLOxLm2 vCFA== 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=np6NcisKpYbaShltEb1tpDmJUGrddQn4joCJefGWsPo=; fh=6EbcJF2Br7Ckqvxmbzy/aBW5ZDkZ8Oeawieh63Sh7bg=; b=DvVq4DnfY9zXB14rUUdpZvrafRfHn3oa6QUoMFav/mZiAM6sFXLwvXd59Drm/iQhUS HjkARqFBRkYWY+NhYVwhcHK/j7sLLyFqbN1lEZ6VqmSk3UWkbroYZxYfGi3LreVNupN9 lf4kiO4zXWJdA3EcpjwYsCZ/O6gfzTQr4vr3+l1I8jeGFo605cjVdz6l6kZ08jPDUHiy q0qBeshbyfxF6wd0CKBKFVubgiisluT1tvvxPDMPydOCx7USDNgtGWz9S52xyG3K5izA 7TlVUPEUubULhPkPcIYu8HZqyDc9c0qE9FK32SyMKLB/IJH0uZRDH/oGZDgSWwXUY2wr Y8wQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=nIEjS0WR; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=HkaoBGsU; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=LEchjKqq; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=QDJUnFGE; 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-43f26644a8dsi6659b6e.85.2025.09.22.04.07.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Sep 2025 04:07:41 -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=nIEjS0WR; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=HkaoBGsU; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=LEchjKqq; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=QDJUnFGE; 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=np6NcisKpYbaShltEb1tpDmJUGrddQn4joCJefGWsPo=; b=nIEjS0WRlL1ziik3cqpBhZ69nt hUNGCxzOIFRwyarERmTP+vPrdzXumOxNXeuv6vQFVoOtRN4h/nETausOBv4T9SVAkFJanWCHjdPnx Sq4rFQJfCIonOHBKHx1KwPqk9MbpikqqpJmBaa1fWlxaERZFT1wr+WHqSFFQqC6V+N5I=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1v0eOQ-0000Mv-8z; Mon, 22 Sep 2025 11:07:39 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1v0eOO-0000Me-LA for openvpn-devel@lists.sourceforge.net; Mon, 22 Sep 2025 11:07:37 +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=hM0Deb59IC+cO6gRLu6B7UyScwoIMYSKWqYo/8GeKRU=; b=HkaoBGsUwdBUINjoYWrNuaSJs9 se3kY2uGWceCWbhH3SJKnlS0LAuZtLOVSeauQ1z7rToBhtWyxmSzo5TnHuCZLE6rmnU6YoG2Wqgnr 8XmJWF5Xc/1aj0lVj3Jkq+KGNTcZPN3IdcHitp4kKc/spZjk3q5IlFPcRYue8TWSugcU=; 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=hM0Deb59IC+cO6gRLu6B7UyScwoIMYSKWqYo/8GeKRU=; b=LEchjKqqOQlloffrwfvlK/os23 FxAIXn6EJzMIq16BHGmTJVLWzVIZqUY+zsNJAWQpgqjDIDj+mt8QVbbqmZfHncc4Y6tOzOSfhjbIU stV8qOjqLFJW4yIQxbza+kOsqN7qSX48FqQYWZ68CCCD3SL3YFesu95aIml5DwCPIHNc=; Received: from sonic315-20.consmr.mail.ne1.yahoo.com ([66.163.190.146]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1v0eON-00050K-JA for openvpn-devel@lists.sourceforge.net; Mon, 22 Sep 2025 11:07:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1758539249; bh=hM0Deb59IC+cO6gRLu6B7UyScwoIMYSKWqYo/8GeKRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=QDJUnFGE9BjYJ2yfd+TocxJdxnaa0FxskOLE5ZRT+fRQWZbJCKUO4e7S6UFhMw9v/ua/9GL4loFqDFWk3qQPID2wf3QtSIqcMSJzYojkznBz0kw9IGYR2Z7+qGI4bMRMVoxXkbxfVIMVQYvr8lTTkdTq1YRUSFjIMObeZQoe5KpZpICyBu7BP+GZkV6YjGiQu/XTYzky76LI4JGMsqs/ChSOzpQtPJUBoTJ05ZxxLpLIA4Gyf3OINDXfFhai9Yo5o+VvfHmvdf7BrYbSmmePHjfAXm+J5RwS42klkc1OUVfotOr1Ln+XPxPuj1+oQY71nDm8ykXzmcKKIfIwtUPjcw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1758539249; bh=cCvLKV/D8v2vWBPa55b/1Wl1nr/qFHWqFwuu1HdrDCh=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=bqYBK8OabtggHZyrI0Am2RJDgOC1a/d+mQsivl0ITiN+BDtGcxj3HgrfdXUT93lq9KscDvh3yOQsHoUuEv6T4fi7WU/oVeswHyyL9pII8765k7ORV7VFTx6ydxEAQiQENvP8om/uQPbANvLL3minxCiPjTXg3EYUe13SzAkPq6Xjimre6QDhY3B3HwItUMm158+8D7FOP7xpthQEwZ40HNNo8JieSjfGQ2IJJ21KuOplDVRJSn+IQrOpQ84s3vGXjZa9dDWA07fIYEnaGlfQpVndceP7b5uliNs2jK84pMf3sCKfmWeHiz1iEJJrrZVHkPaVweDK/cAZL7oK39dHbA== X-YMail-OSG: m69wDWgVM1nCp7ETJA.lsO9F7znnyHraAHOc5En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71uxq6s4Mib5W.9Zg.rHyFnkO5844s7lg-- X-Sonic-MF: X-Sonic-ID: 186ca35c-a907-4a8f-8d36-8f54763c1d8f Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.ne1.yahoo.com with HTTP; Mon, 22 Sep 2025 11:07:29 +0000 Received: by hermes--production-ir2-74585cff4f-4sjhz (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID ca5bfbd718d89396be3325d48d68935b; Mon, 22 Sep 2025 11:07:06 +0000 (UTC) To: netdev@vger.kernel.org, sd@queasysnail.net, antonio@openvpn.net Date: Mon, 22 Sep 2025 13:06:20 +0200 Message-ID: <20250922110622.10368-2-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: 8824 X-Spam-Score: 0.1 (/) 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: Implement RCU variants for existing dst_cache helpers interacting with dst_entry. The new helpers avoid referencing the dst_entry, sparing some unnecessary atomic operations. They should only be used in flows that are already guaranteed to be inside a RCU read-side critical context [...] Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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.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.190.146 listed in wl.mailspike.net] X-Headers-End: 1v0eON-00050K-JA Subject: [Openvpn-devel] [PATCH net-next v3 1/3] net: dst_cache: implement RCU variants for dst_cache helpers 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?1843962064877773464?= X-GMAIL-MSGID: =?utf-8?q?1843962064877773464?= Implement RCU variants for existing dst_cache helpers interacting with dst_entry. The new helpers avoid referencing the dst_entry, sparing some unnecessary atomic operations. They should only be used in flows that are already guaranteed to be inside a RCU read-side critical context. Signed-off-by: Marek Mietus --- include/net/dst_cache.h | 54 ++++++++++++++++++ net/core/dst_cache.c | 119 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 163 insertions(+), 10 deletions(-) diff --git a/include/net/dst_cache.h b/include/net/dst_cache.h index 1961699598e2..2c98451469ef 100644 --- a/include/net/dst_cache.h +++ b/include/net/dst_cache.h @@ -32,6 +32,21 @@ struct dst_entry *dst_cache_get(struct dst_cache *dst_cache); */ struct rtable *dst_cache_get_ip4(struct dst_cache *dst_cache, __be32 *saddr); +/** + * dst_cache_get_ip4_rcu - lookup cache and ipv4 source under RCU + * @dst_cache: the cache + * @saddr: return value for the retrieved source address + * + * Perform cache lookup and fetch ipv4 source without taking a + * reference on the dst. + * Must be called with local BH disabled, and within an rcu read side + * critical section. + * + * Return: Pointer to retrieved rtable if cache is initialized and + * cached dst is valid, NULL otherwise. + */ +struct rtable *dst_cache_get_ip4_rcu(struct dst_cache *dst_cache, __be32 *saddr); + /** * dst_cache_set_ip4 - store the ipv4 dst into the cache * @dst_cache: the cache @@ -43,6 +58,17 @@ struct rtable *dst_cache_get_ip4(struct dst_cache *dst_cache, __be32 *saddr); void dst_cache_set_ip4(struct dst_cache *dst_cache, struct dst_entry *dst, __be32 saddr); +/** + * dst_cache_steal_ip4 - store the ipv4 dst into the cache and steal its + * reference + * @dst_cache: the cache + * @dst: the entry to be cached whose reference will be stolen + * @saddr: the source address to be stored inside the cache + * + * local BH must be disabled + */ +void dst_cache_steal_ip4(struct dst_cache *dst_cache, struct dst_entry *dst, + __be32 saddr); #if IS_ENABLED(CONFIG_IPV6) /** @@ -56,6 +82,18 @@ void dst_cache_set_ip4(struct dst_cache *dst_cache, struct dst_entry *dst, void dst_cache_set_ip6(struct dst_cache *dst_cache, struct dst_entry *dst, const struct in6_addr *saddr); +/** + * dst_cache_steal_ip6 - store the ipv6 dst into the cache and steal its + * reference + * @dst_cache: the cache + * @dst: the entry to be cached whose reference will be stolen + * @saddr: the source address to be stored inside the cache + * + * local BH must be disabled + */ +void dst_cache_steal_ip6(struct dst_cache *dst_cache, struct dst_entry *dst, + const struct in6_addr *saddr); + /** * dst_cache_get_ip6 - perform cache lookup and fetch ipv6 source address * @dst_cache: the cache @@ -65,6 +103,22 @@ void dst_cache_set_ip6(struct dst_cache *dst_cache, struct dst_entry *dst, */ struct dst_entry *dst_cache_get_ip6(struct dst_cache *dst_cache, struct in6_addr *saddr); + +/** + * dst_cache_get_ip6_rcu - lookup cache and ipv6 source under RCU + * @dst_cache: the cache + * @saddr: return value for the retrieved source address + * + * Perform cache lookup and fetch ipv6 source without taking a + * reference on the dst. + * Must be called with local BH disabled, and within an rcu read side + * critical section. + * + * Return: Pointer to retrieved dst_entry if cache is initialized and + * cached dst is valid, NULL otherwise. + */ +struct dst_entry *dst_cache_get_ip6_rcu(struct dst_cache *dst_cache, + struct in6_addr *saddr); #endif /** diff --git a/net/core/dst_cache.c b/net/core/dst_cache.c index 9ab4902324e1..7d00745ac7d3 100644 --- a/net/core/dst_cache.c +++ b/net/core/dst_cache.c @@ -25,20 +25,27 @@ struct dst_cache_pcpu { }; }; -static void dst_cache_per_cpu_dst_set(struct dst_cache_pcpu *dst_cache, - struct dst_entry *dst, u32 cookie) +static void __dst_cache_per_cpu_dst_set(struct dst_cache_pcpu *dst_cache, + struct dst_entry *dst, u32 cookie) { DEBUG_NET_WARN_ON_ONCE(!in_softirq()); dst_release(dst_cache->dst); - if (dst) - dst_hold(dst); dst_cache->cookie = cookie; dst_cache->dst = dst; } -static struct dst_entry *dst_cache_per_cpu_get(struct dst_cache *dst_cache, - struct dst_cache_pcpu *idst) +static void dst_cache_per_cpu_dst_set(struct dst_cache_pcpu *dst_cache, + struct dst_entry *dst, u32 cookie) +{ + if (dst) + dst_hold(dst); + + __dst_cache_per_cpu_dst_set(dst_cache, dst, cookie); +} + +static struct dst_entry *__dst_cache_per_cpu_get(struct dst_cache *dst_cache, + struct dst_cache_pcpu *idst) { struct dst_entry *dst; @@ -47,14 +54,10 @@ static struct dst_entry *dst_cache_per_cpu_get(struct dst_cache *dst_cache, if (!dst) goto fail; - /* the cache already hold a dst reference; it can't go away */ - dst_hold(dst); - if (unlikely(!time_after(idst->refresh_ts, READ_ONCE(dst_cache->reset_ts)) || (READ_ONCE(dst->obsolete) && !dst->ops->check(dst, idst->cookie)))) { dst_cache_per_cpu_dst_set(idst, NULL, 0); - dst_release(dst); goto fail; } return dst; @@ -64,6 +67,18 @@ static struct dst_entry *dst_cache_per_cpu_get(struct dst_cache *dst_cache, return NULL; } +static struct dst_entry *dst_cache_per_cpu_get(struct dst_cache *dst_cache, + struct dst_cache_pcpu *idst) +{ + struct dst_entry *dst; + + dst = __dst_cache_per_cpu_get(dst_cache, idst); + if (dst) + /* the cache already hold a dst reference; it can't go away */ + dst_hold(dst); + return dst; +} + struct dst_entry *dst_cache_get(struct dst_cache *dst_cache) { struct dst_entry *dst; @@ -100,6 +115,28 @@ struct rtable *dst_cache_get_ip4(struct dst_cache *dst_cache, __be32 *saddr) } EXPORT_SYMBOL_GPL(dst_cache_get_ip4); +struct rtable *dst_cache_get_ip4_rcu(struct dst_cache *dst_cache, __be32 *saddr) +{ + struct dst_cache_pcpu *idst; + struct dst_entry *dst; + + if (!dst_cache->cache) + return NULL; + + local_lock_nested_bh(&dst_cache->cache->bh_lock); + idst = this_cpu_ptr(dst_cache->cache); + dst = __dst_cache_per_cpu_get(dst_cache, idst); + if (!dst) { + local_unlock_nested_bh(&dst_cache->cache->bh_lock); + return NULL; + } + + *saddr = idst->in_saddr.s_addr; + local_unlock_nested_bh(&dst_cache->cache->bh_lock); + return dst_rtable(dst); +} +EXPORT_SYMBOL_GPL(dst_cache_get_ip4_rcu); + void dst_cache_set_ip4(struct dst_cache *dst_cache, struct dst_entry *dst, __be32 saddr) { @@ -116,6 +153,24 @@ void dst_cache_set_ip4(struct dst_cache *dst_cache, struct dst_entry *dst, } EXPORT_SYMBOL_GPL(dst_cache_set_ip4); +void dst_cache_steal_ip4(struct dst_cache *dst_cache, struct dst_entry *dst, + __be32 saddr) +{ + struct dst_cache_pcpu *idst; + + if (!dst_cache->cache) { + dst_release(dst); + return; + } + + local_lock_nested_bh(&dst_cache->cache->bh_lock); + idst = this_cpu_ptr(dst_cache->cache); + __dst_cache_per_cpu_dst_set(idst, dst, 0); + idst->in_saddr.s_addr = saddr; + local_unlock_nested_bh(&dst_cache->cache->bh_lock); +} +EXPORT_SYMBOL_GPL(dst_cache_steal_ip4); + #if IS_ENABLED(CONFIG_IPV6) void dst_cache_set_ip6(struct dst_cache *dst_cache, struct dst_entry *dst, const struct in6_addr *saddr) @@ -135,6 +190,26 @@ void dst_cache_set_ip6(struct dst_cache *dst_cache, struct dst_entry *dst, } EXPORT_SYMBOL_GPL(dst_cache_set_ip6); +void dst_cache_steal_ip6(struct dst_cache *dst_cache, struct dst_entry *dst, + const struct in6_addr *saddr) +{ + struct dst_cache_pcpu *idst; + + if (!dst_cache->cache) { + dst_release(dst); + return; + } + + local_lock_nested_bh(&dst_cache->cache->bh_lock); + + idst = this_cpu_ptr(dst_cache->cache); + __dst_cache_per_cpu_dst_set(idst, dst, + rt6_get_cookie(dst_rt6_info(dst))); + idst->in6_saddr = *saddr; + local_unlock_nested_bh(&dst_cache->cache->bh_lock); +} +EXPORT_SYMBOL_GPL(dst_cache_steal_ip6); + struct dst_entry *dst_cache_get_ip6(struct dst_cache *dst_cache, struct in6_addr *saddr) { @@ -158,6 +233,30 @@ struct dst_entry *dst_cache_get_ip6(struct dst_cache *dst_cache, return dst; } EXPORT_SYMBOL_GPL(dst_cache_get_ip6); + +struct dst_entry *dst_cache_get_ip6_rcu(struct dst_cache *dst_cache, + struct in6_addr *saddr) +{ + struct dst_cache_pcpu *idst; + struct dst_entry *dst; + + if (!dst_cache->cache) + return NULL; + + local_lock_nested_bh(&dst_cache->cache->bh_lock); + + idst = this_cpu_ptr(dst_cache->cache); + dst = __dst_cache_per_cpu_get(dst_cache, idst); + if (!dst) { + local_unlock_nested_bh(&dst_cache->cache->bh_lock); + return NULL; + } + + *saddr = idst->in6_saddr; + local_unlock_nested_bh(&dst_cache->cache->bh_lock); + return dst; +} +EXPORT_SYMBOL_GPL(dst_cache_get_ip6_rcu); #endif int dst_cache_init(struct dst_cache *dst_cache, gfp_t gfp) From patchwork Mon Sep 22 11:06:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Mietus X-Patchwork-Id: 4434 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:c08a:b0:72f:f16c:e055 with SMTP id jr10csp113471mab; Mon, 22 Sep 2025 04:08:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUuVHLka2trBYFYIG7aLY8Hh786ZMNZ2JokoCvl/slZ8197YLBmaPY5S3QaHMLKQqaRy/zKLIUsS3k=@openvpn.net X-Google-Smtp-Source: AGHT+IHB/XGkHk4Zdx8iEIU6CuzsPARYE/slwY2jOA/QnPAqxrEiNp0pAS8yeJj90fjFI+3nusXg X-Received: by 2002:a05:6870:d88d:b0:31d:8edc:3d1a with SMTP id 586e51a60fabf-33bb38a30ebmr6068905fac.7.1758539290886; 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=iG0cuorEDJUihnQ8Oa083TghpO9CQoWS6Zcd2ttXDB56mX+RAXEUBmfvedg0r1hrRP 245xgX3my9hvZhZV7XuYtyX8pRvfpNY+YISzS2VP0iCEmRCm8Gmg1PeuBWclu8EvHQ4B wk8bes8Ovt3Ntwoed75203zQonJJ6ZOg+fMN0Iu2bpJmBeXznUl7XRlk2G8E/gCz631l 7ea32NQo9vrdSLx8cgfyVNO/anopYS7NviXM7ZUPuxyTRih9Hz8DCnnwcmPyX91uVPd8 CQy9JLAk5w606q6M4t0nhAqR5ITBoE9V02TV/UbJIrDnjTsP6sMsbsz3QAWjIJbw/hVd q7tw== 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=fcYvj51ZdyG3Kd0rYtpHhuqeKsV+/qwGbXga1+w5kbg=; fh=6EbcJF2Br7Ckqvxmbzy/aBW5ZDkZ8Oeawieh63Sh7bg=; b=TQI1a0Rb502o1trqP7tQBovgypA5lcdK2RwCUGRRp9YXJvxk5QH+TEElpVPye+F7ha UjfldYNMQyoSHw31uIrXBHzfUtMIjbbwf3f4FjqoQdYQh+qtsgMkIMEJiYxtqJwO7ewr Ka1IpR7M7aNw8Q88ox/4S2auSA+FZjEwWuxEj9KTHE07G6AmlBc2lmTXRkKDehx8Geju O6Qbw+IggjP+vw9sTuC25kJhfJui0zfz6aFLHF39DvKuqOpVc2L1iPP0nN18uogbI0FY gXwDz18kjP2XlBA7RMf/DXr1pPJpxLd4PgoTy39+vv9qIDgWMhi1lqDlKZvJM9ctdqrg Hg5A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=dCwIgHVR; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=e6QKZR8x; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=gljc3Zx+; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=NKLP5tE7; 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 586e51a60fabf-336e6799e0esi3976280fac.257.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=dCwIgHVR; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=e6QKZR8x; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=gljc3Zx+; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=NKLP5tE7; 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=fcYvj51ZdyG3Kd0rYtpHhuqeKsV+/qwGbXga1+w5kbg=; b=dCwIgHVRqD/RWQBMc/H8zucZj4 aJQZyAw9MuFyEHiIuLpufeq16N2MFtQN8aETHAnlA/v2qwo4HnV11GMu1rZIq+iGHk2Ja45wp9c8M h5iOJDIxqjJbhPtfo/jNCCiOpvIafPDU0OeZ0Od4Km7BPTENZBB67c/glrqOcQ7H0s2w=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1v0eOu-0004GW-OF; Mon, 22 Sep 2025 11:08:08 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1v0eOr-0004GK-G7 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=F/CrqXPhav1we8hfen578C8Cgg6tKMJWqu5+DcM9bjU=; b=e6QKZR8xLxGPrY5eNqMSb+6eLj hP3PD4GAk1nFaDPlbafgNBkLzKjf2Oy4scaFLKHffhzXcoLMmQ+nfHPOFYL7MN/EfcRFpl1LZcwBK h4TsJFWSSOI/c5JfdnaO+zB9XroqiDAtp1NC8pVBC7LNFne6cYBO6yYOQr1TbQPjwOc4=; 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=F/CrqXPhav1we8hfen578C8Cgg6tKMJWqu5+DcM9bjU=; b=gljc3Zx+li7e5LHAYi+Cze8snz PV7CrUQStMbJ1ehIBjOKvAUCLh4xNv21qDviuF+TndT3C0rNtiaoBOHo0/BkVPLErNQpZlM2XSRwV KM8/pLWTCaEPLMpoyNvCN1X/eNwVJZ7/uypMP+ABy5umkKnB8R3+CI45r1TMOx91OvHY=; Received: from sonic308-56.consmr.mail.ne1.yahoo.com ([66.163.187.31]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1v0eOq-00052a-OS for openvpn-devel@lists.sourceforge.net; Mon, 22 Sep 2025 11:08:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1758539274; bh=F/CrqXPhav1we8hfen578C8Cgg6tKMJWqu5+DcM9bjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=NKLP5tE7E4/uKAWrNk00OhkAUNjlZqMTb/tP/Mh7X6nQOoWdsmL5Gpw50q0ykqfo6dFKh18FaUE18lXolIuhWD6ZBnX+gZXea2/vnXcA4Td2MVqTcAP5TUlCj+RshdeDVmTTQ51JUHN8GvErrrG5Q0MjLX+eYYh2sXRY2HL5aA2GcR26jYjNqufJh7LTJ1EGMaYGr5OElX3XdsOLgg1t/BGyc46p6sITWfVpItZ0xs6bN1X1j849DQkWPx2QWDNH0xW6t4TGJzwBjBVlHK3eYQdAjp8RALLPu02gpXGzBOSDy1AIj5fCV93lGkO2qGHVzt5FgZJ+n8N6ul5zEviv8A== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1758539274; bh=wS/e+rPwaFZBchui4b2q9F+CMEqovYeKy4noCBk+vU4=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=MbhdDmsAb8Wb92ZUfG1XjMkYYTa/UEH1GQx+NasCLSoaqWTtq+Qx167ittig9VjhvtY/ofo1WJe47V2b9t/V4HVR9JnVAbGAmoPHspKzg5seuRn4ZC5RsLUhrYlOE8pNQ32/N74P4hJtpQQZLmCsJlE8JYNgxoyJXkLxmCkOrYXnmj/yop0Lfuj7S4qKMoa8aWVoZWUV4wb6zthmxmjnP5oIZBxEC1U2s46yvk+ZwYHK95dTRTqchGBjnD2P8zjf5dktZbyW9x3DRsSTrHcuknvg4NGpcrvquiNTfTJWhHfs6sSsXMOJpBvg3F2NLvJfShVRtk3Zr6Te4EFL00dp9w== X-YMail-OSG: X52VvukVM1kDIdEIlckeH3xnZ5yKNdZ2hkGgdBkcfU8E2HL41K13U.8SaHASK8O pmkoWfocFvIj7U_yIhhILXTjPa1ff5GdAQZxmfROH29yqhlSJ0FdqzoN52meNEacdJ9GxRfgVbaB qVLnW_1n4jG8rDuPw1zaLrkDHjNpzOVbEN8hknV7vlBYKEtG9K922CPztSXFlt4Q7druI5LAMCQr MGlLiRmp12EaJFaMGPJbfxu_FVZUW44.tEJKhPaErhTDl_i.WJ3RoG5dpCddhvIC5utKjSLlLE6V AHuYspu28zYwYnFo6iWoqxlGQVr1NFpFq7DpIxvv.ZNjjIV0cmFJ.EhqMY0aqWg0H8r.z.uHneBW q3iKi5eqlBa8SZ9PE0s_EF735WnWIZRkaNzukqo2ukcipD3B39xd2pkAaCRXriL3GKnEKt0.ki8m ZJfWiwU0F1WfdFljYIdHFhCyPobIvvQybHEG4_P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RlZljxjWEQ713z1qKBsKOCeGd.fpE6 RUv0fzl1_il2QQ4JYM905F73GISpIIyRNSRWptgOlWhOuaSkwA.0JpfGtLPQRWi_KfBAX.578lJy KrRWEp96E59nRle5sK8b8_jnX3I8ZeAH7wpno2Fhi9g8T2Ba4thcgKpwBxbxXSnfVcFKMnaes1ul jrBPT9GnWRdwE.Qfqt0YKDQIV05W6ddmdR5lFw_5_pNV7n6h8XYSIZlwrimnybS0fc3y7IaBpuu. XZNrdjWjWCsVJO9bUPPS0rm.fDE3vmBv.h3WvQKnVkZLgNQWiZZSEf80Ay3TP3B08muJevTKi.HG rvDiOatvI_rwSbUwydyTKgntP1abwVOZqmydducLD7_ppdW.kSByxntJVrBt_rLNnV3XUEu62ahr 2U2ndh4Zk05Y.lQSIjws8otJ1uah3wxT72RnQql39XVbuaLhg8e4UY05WzqdK03TNXyJoz7Y98WK i6IXAVmaTjW1NijRBrmXCyHcz7P2SW6kG6HGC2O2VMAVMGF2H4Oxjk8685aB4HzNtz6DJ5afHsHC M3ENKnsr5uMeIBE4tJOiR.mFpmVWG2DXqJXkJuyhqk_MUM1_Npagk.o7y568.vFL7wtP57lxXwoj mSKKCsHOHluaHg9IikWxqbiLFxAhcqF.SH9Cjv0tnq.WvJw-- X-Sonic-MF: X-Sonic-ID: 0f9b02dc-6fd8-4eb9-aa3c-3c63d1b058ab Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Mon, 22 Sep 2025 11:07:54 +0000 Received: by hermes--production-ir2-74585cff4f-4sjhz (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID ca5bfbd718d89396be3325d48d68935b; Mon, 22 Sep 2025 11:07:29 +0000 (UTC) To: netdev@vger.kernel.org, sd@queasysnail.net, antonio@openvpn.net Date: Mon, 22 Sep 2025 13:06:21 +0200 Message-ID: <20250922110622.10368-3-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: 9443 X-Spam-Score: 0.1 (/) 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: In cases where udp_tunnel{,6}_xmit_skb is called inside a RCU read-side critical section, we can avoid referencing the dst_entry. Implement noref variants for udp_tunnel{,6}_xmit_skb and iptunnel_xmit to be used in noref flows. Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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.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.187.31 listed in wl.mailspike.net] X-Headers-End: 1v0eOq-00052a-OS Subject: [Openvpn-devel] [PATCH net-next v3 2/3] net: tunnel: implement noref flows in udp_tunnel{, 6}_xmit_skb 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?1843962095660115492?= X-GMAIL-MSGID: =?utf-8?q?1843962095660115492?= In cases where udp_tunnel{,6}_xmit_skb is called inside a RCU read-side critical section, we can avoid referencing the dst_entry. Implement noref variants for udp_tunnel{,6}_xmit_skb and iptunnel_xmit to be used in noref flows. Signed-off-by: Marek Mietus --- include/net/ip_tunnels.h | 3 +++ include/net/udp_tunnel.h | 13 ++++++++++ net/ipv4/ip_tunnel_core.c | 34 +++++++++++++++++++------ net/ipv4/udp_tunnel_core.c | 29 +++++++++++++++++++--- net/ipv6/ip6_udp_tunnel.c | 51 ++++++++++++++++++++++++++++++-------- 5 files changed, 109 insertions(+), 21 deletions(-) diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 8cf1380f3656..6dcea237bf21 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -604,6 +604,9 @@ static inline int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, __be32 src, __be32 dst, u8 proto, u8 tos, u8 ttl, __be16 df, bool xnet, u16 ipcb_flags); +void iptunnel_xmit_noref(struct sock *sk, struct rtable *rt, struct sk_buff *skb, + __be32 src, __be32 dst, u8 proto, + u8 tos, u8 ttl, __be16 df, bool xnet, u16 ipcb_flags); struct metadata_dst *iptunnel_metadata_reply(struct metadata_dst *md, gfp_t flags); int skb_tunnel_check_pmtu(struct sk_buff *skb, struct dst_entry *encap_dst, diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h index 9acef2fbd2fd..b35e0267e318 100644 --- a/include/net/udp_tunnel.h +++ b/include/net/udp_tunnel.h @@ -135,6 +135,10 @@ void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df, __be16 src_port, __be16 dst_port, bool xnet, bool nocheck, u16 ipcb_flags); +void udp_tunnel_xmit_skb_noref(struct rtable *rt, struct sock *sk, struct sk_buff *skb, + __be32 src, __be32 dst, __u8 tos, __u8 ttl, + __be16 df, __be16 src_port, __be16 dst_port, + bool xnet, bool nocheck, u16 ipcb_flags); void udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk, struct sk_buff *skb, @@ -145,6 +149,15 @@ void udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk, __be16 src_port, __be16 dst_port, bool nocheck, u16 ip6cb_flags); +void udp_tunnel6_xmit_skb_noref(struct dst_entry *dst, + struct sock *sk, struct sk_buff *skb, + struct net_device *dev, + const struct in6_addr *saddr, + const struct in6_addr *daddr, + __u8 prio, __u8 ttl, __be32 label, + __be16 src_port, __be16 dst_port, + bool nocheck, u16 ip6cb_flags); + void udp_tunnel_sock_release(struct socket *sock); struct rtable *udp_tunnel_dst_lookup(struct sk_buff *skb, diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c index cc9915543637..8b03fb380397 100644 --- a/net/ipv4/ip_tunnel_core.c +++ b/net/ipv4/ip_tunnel_core.c @@ -47,10 +47,10 @@ const struct ip6_tnl_encap_ops __rcu * ip6tun_encaps[MAX_IPTUN_ENCAP_OPS] __read_mostly; EXPORT_SYMBOL(ip6tun_encaps); -void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, - __be32 src, __be32 dst, __u8 proto, - __u8 tos, __u8 ttl, __be16 df, bool xnet, - u16 ipcb_flags) +static void __iptunnel_xmit(struct sock *sk, struct rtable *rt, + struct sk_buff *skb, __be32 src, __be32 dst, + __u8 proto, __u8 tos, __u8 ttl, __be16 df, + u16 ipcb_flags) { int pkt_len = skb->len - skb_inner_network_offset(skb); struct net *net = dev_net(rt->dst.dev); @@ -58,10 +58,7 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, struct iphdr *iph; int err; - skb_scrub_packet(skb, xnet); - skb_clear_hash_if_not_l4(skb); - skb_dst_set(skb, &rt->dst); memset(IPCB(skb), 0, sizeof(*IPCB(skb))); IPCB(skb)->flags = ipcb_flags; @@ -89,8 +86,31 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, iptunnel_xmit_stats(dev, pkt_len); } } + +void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, + __be32 src, __be32 dst, __u8 proto, + __u8 tos, __u8 ttl, __be16 df, bool xnet, + u16 ipcb_flags) +{ + skb_scrub_packet(skb, xnet); + skb_dst_set(skb, &rt->dst); + + __iptunnel_xmit(sk, rt, skb, src, dst, proto, tos, ttl, df, ipcb_flags); +} EXPORT_SYMBOL_GPL(iptunnel_xmit); +void iptunnel_xmit_noref(struct sock *sk, struct rtable *rt, struct sk_buff *skb, + __be32 src, __be32 dst, __u8 proto, + __u8 tos, __u8 ttl, __be16 df, bool xnet, + u16 ipcb_flags) +{ + skb_scrub_packet(skb, xnet); + skb_dst_set_noref(skb, &rt->dst); + + __iptunnel_xmit(sk, rt, skb, src, dst, proto, tos, ttl, df, ipcb_flags); +} +EXPORT_SYMBOL_GPL(iptunnel_xmit_noref); + int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto, bool raw_proto, bool xnet) { diff --git a/net/ipv4/udp_tunnel_core.c b/net/ipv4/udp_tunnel_core.c index fce945f23069..c0e9007cf081 100644 --- a/net/ipv4/udp_tunnel_core.c +++ b/net/ipv4/udp_tunnel_core.c @@ -170,10 +170,9 @@ void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type) } EXPORT_SYMBOL_GPL(udp_tunnel_notify_del_rx_port); -void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb, - __be32 src, __be32 dst, __u8 tos, __u8 ttl, - __be16 df, __be16 src_port, __be16 dst_port, - bool xnet, bool nocheck, u16 ipcb_flags) +static void udp_tunnel_add_hdr(struct sk_buff *skb, __be32 src, + __be32 dst, __be16 src_port, + __be16 dst_port, bool nocheck) { struct udphdr *uh; @@ -188,12 +187,34 @@ void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); udp_set_csum(nocheck, skb, src, dst, skb->len); +} + +void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, + struct sk_buff *skb, __be32 src, __be32 dst, + __u8 tos, __u8 ttl, __be16 df, __be16 src_port, + __be16 dst_port, bool xnet, bool nocheck, + u16 ipcb_flags) +{ + udp_tunnel_add_hdr(skb, src, dst, src_port, dst_port, nocheck); iptunnel_xmit(sk, rt, skb, src, dst, IPPROTO_UDP, tos, ttl, df, xnet, ipcb_flags); } EXPORT_SYMBOL_GPL(udp_tunnel_xmit_skb); +void udp_tunnel_xmit_skb_noref(struct rtable *rt, struct sock *sk, + struct sk_buff *skb, __be32 src, __be32 dst, + __u8 tos, __u8 ttl, __be16 df, __be16 src_port, + __be16 dst_port, bool xnet, bool nocheck, + u16 ipcb_flags) +{ + udp_tunnel_add_hdr(skb, src, dst, src_port, dst_port, nocheck); + + iptunnel_xmit_noref(sk, rt, skb, src, dst, IPPROTO_UDP, tos, ttl, df, + xnet, ipcb_flags); +} +EXPORT_SYMBOL_GPL(udp_tunnel_xmit_skb_noref); + void udp_tunnel_sock_release(struct socket *sock) { rcu_assign_sk_user_data(sock->sk, NULL); diff --git a/net/ipv6/ip6_udp_tunnel.c b/net/ipv6/ip6_udp_tunnel.c index 0ff547a4bff7..d262d0a0a178 100644 --- a/net/ipv6/ip6_udp_tunnel.c +++ b/net/ipv6/ip6_udp_tunnel.c @@ -74,14 +74,16 @@ int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg, } EXPORT_SYMBOL_GPL(udp_sock_create6); -void udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk, - struct sk_buff *skb, - struct net_device *dev, - const struct in6_addr *saddr, - const struct in6_addr *daddr, - __u8 prio, __u8 ttl, __be32 label, - __be16 src_port, __be16 dst_port, bool nocheck, - u16 ip6cb_flags) +static void __udp_tunnel6_xmit_skb(struct dst_entry *dst, + struct sock *sk, + struct sk_buff *skb, + struct net_device *dev, + const struct in6_addr *saddr, + const struct in6_addr *daddr, + __u8 prio, __u8 ttl, __be32 label, + __be16 src_port, __be16 dst_port, + bool nocheck, + u16 ip6cb_flags) { struct udphdr *uh; struct ipv6hdr *ip6h; @@ -95,8 +97,6 @@ void udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk, uh->len = htons(skb->len); - skb_dst_set(skb, dst); - udp6_set_csum(nocheck, skb, saddr, daddr, skb->len); __skb_push(skb, sizeof(*ip6h)); @@ -111,8 +111,39 @@ void udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk, ip6tunnel_xmit(sk, skb, dev, ip6cb_flags); } + +void udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk, + struct sk_buff *skb, + struct net_device *dev, + const struct in6_addr *saddr, + const struct in6_addr *daddr, + __u8 prio, __u8 ttl, __be32 label, + __be16 src_port, __be16 dst_port, bool nocheck, + u16 ip6cb_flags) +{ + skb_dst_set(skb, dst); + __udp_tunnel6_xmit_skb(dst, sk, skb, dev, saddr, daddr, + prio, ttl, label, src_port, dst_port, + nocheck, ip6cb_flags); +} EXPORT_SYMBOL_GPL(udp_tunnel6_xmit_skb); +void udp_tunnel6_xmit_skb_noref(struct dst_entry *dst, + struct sock *sk, struct sk_buff *skb, + struct net_device *dev, + const struct in6_addr *saddr, + const struct in6_addr *daddr, + __u8 prio, __u8 ttl, __be32 label, + __be16 src_port, __be16 dst_port, + bool nocheck, u16 ip6cb_flags) +{ + skb_dst_set_noref(skb, dst); + __udp_tunnel6_xmit_skb(dst, sk, skb, dev, saddr, daddr, + prio, ttl, label, src_port, dst_port, + nocheck, ip6cb_flags); +} +EXPORT_SYMBOL_GPL(udp_tunnel6_xmit_skb_noref); + /** * udp_tunnel6_dst_lookup - perform route lookup on UDP tunnel * @skb: Packet for which lookup is done 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_bAq3kodU_7.yZV5hZ4q4gHNP628TKeVFEBuj3QYSYCP41zV_ .S9Q49zPeDK2XfQMsuprEsHGXAaLqluG3mInvVrxy1WP0qIykti5ovJIIC1CqHpdAv7N5QXVkC2u GGVrfP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48-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();