From patchwork Fri Sep 12 11:24:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Mietus X-Patchwork-Id: 4405 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:b149:b0:671:5a2c:6455 with SMTP id s9csp3741623maw; Fri, 12 Sep 2025 04:45:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXOpIeiqPnEjMoZVZM0NBKB0M90j0ZNAT/tdBo2rFgXg7tR0MjxAt2BRf/Adc8eKrzyWd7WsA4Hpek=@openvpn.net X-Google-Smtp-Source: AGHT+IGZUpLYIwJ7iPfp5NNBP8z9HgpeMoGb5GnKTyYdLZojJreBhUWASs5fZDBJesx6zd7xtDt2 X-Received: by 2002:a05:6830:6686:b0:746:d50f:f9c7 with SMTP id 46e09a7af769-7535269824cmr1688317a34.4.1757677524435; Fri, 12 Sep 2025 04:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1757677524; cv=none; d=google.com; s=arc-20240605; b=E4EYJXn+vc7IJUnDHgZ+q0HEubmtcEdc+zb/g9vwb6W5xC14xF17MzKn1voOFAAGAF juBgk5OOGlh0CxXeFvd8RVIolwnPtWvUR/EMlrNgx0I0kisnQJaGq1zCcixtb3+wyOum q/ee32SjNnoHRf+oX55NG5ImXiwpLkdIqDu8S1LoQSe8RAibXU6ENOC5wyjZ/KH6a4Sf /F0cEnqLVEtW8QBVJZhIO3Ne7eF5DtgE/ojqpr9Z0xCP8tECFzCGvdQO3GV98qabBq6F maI5GhBe/SSAlSl+NzU0nusHvz+MF9BpHvz2gG29MRqa+YN6yPdDJ7fzhjpofSYhe9Hz QeUw== 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=tbn6gT8KVa8R5aR6/KEgtyfv849HKlYSDapYim46ulI=; fh=Nld6ED5MA/hilqlwqNF+z3bWNSgobxU8XeD15u7QoP0=; b=DiVad0KfPum8E92P5cZicHqHWQS8atPckpTX08yap067fTIMPkAB+yUvXBltifkOmm 72BL3UkO9kPQ2dGknoLdog5gWfwMkvGWpR9D4vqkBV594c+0LmAavhh9dfr1Y67fJlIW djJauP5pxctwgsf1dnL+/GILIreI1dvzQ/yrRHJUqy/a3VVZhs7ARl9sRtoiVGFSQsOP fcja8OhNI/GywyCGYPkZfuIrIFdal+IXf7ESEJL2x0Pr0j9A+jzVPNitQ+FNuaGffGlr 4jyQeZ+HIV9cofuSzPaHe4LfwbhSd6Xei8AfrSnltwP5OyZVb6aXVEkAPgO4CKIXIBWm 0faQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=PDR3miQH; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=eVZpcTST; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="i8w/9C6u"; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b="FPR/2d+a"; 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 46e09a7af769-7524b7a91dfsi950110a34.442.2025.09.12.04.45.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Sep 2025 04:45:24 -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=PDR3miQH; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=eVZpcTST; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="i8w/9C6u"; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b="FPR/2d+a"; 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=tbn6gT8KVa8R5aR6/KEgtyfv849HKlYSDapYim46ulI=; b=PDR3miQHy1qnpJPjf/tPo1GYb5 LmAR9EMPmBkoKY9S2gBkiwgk0m/nwfK8ZJ0Kp1XRlncnJa7rVfxDGvySwhPvAnLr9p9CNeQ+khrak tMl7popGiTwCLoR7sTDncmYy31pjRY0wGTSbMLzASPvLlgjG8GxXVgBGKhekSdaTuHo4=; 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 1ux2DR-0002dU-9K; Fri, 12 Sep 2025 11:45:21 +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 1ux2DQ-0002dO-Ff for openvpn-devel@lists.sourceforge.net; Fri, 12 Sep 2025 11:45:20 +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=kQN6ns9dR4cKsHVgmniWSuQnXl22gTgXJWUVwRX4GN8=; b=eVZpcTST1PFrtvTl3XJMmEbrpQ zwv0jPLEOCnZCDHAdmwd3qvpcmv6AxUMeQzYml8dkd/Y79cD1/tAfDcO+8rQ5XSbzx0M+hd5juDrT RslhA96IdzVr8XgG5K7KVNGI98JUv9jZt5FQMGJnZDS8hQXyRJwKehfvzfwNKdKDA0no=; 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=kQN6ns9dR4cKsHVgmniWSuQnXl22gTgXJWUVwRX4GN8=; b=i8w/9C6uOdz7mCv3UVUPRUC21M 0NlZ9+CqEZythcIul1q7WxEs5IxPYnOD8IblbIKWklbFXm9S6T0HHnt6T89OGddOgwKz2FfTi/c0m HlDP1iovSas+wZhVF6gCBinZWjFeDbJfFOxgkqLJjFhVdgq+M84DEGSXdgZvl6lHYj4s=; Received: from sonic310-23.consmr.mail.ne1.yahoo.com ([66.163.186.204]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1ux2DP-0004Gf-TE for openvpn-devel@lists.sourceforge.net; Fri, 12 Sep 2025 11:45:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1757677514; bh=kQN6ns9dR4cKsHVgmniWSuQnXl22gTgXJWUVwRX4GN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=FPR/2d+ad/xs9IuTXCLBap9vzKH3vEWBZUZZ8qH/201JLrkmHzsAsI+4FLSkLuTRJLQFYlK+GyWgKM10uID8cppUrCIn9ycMASzCNn43+HLFctdaBkDf090BqrIzA/vDvbL4PfGyplCKtoUHL6efnzMOJlo4p0PT1VtHkCR+aY3R8gW6E2+MrfronLv9tSx6/PptJc7qRYyRRg4T2Bl8zXAiIvx/uZjpic1gLYRHduC+lENe2/Mz5GgPIEiZ89bZnyVl0Ji+Cu/cMRD3ZixZS/bpAv4CqgPtqpfU/Yz3YzwPDCx0iKvqOtU90kVi3UVTMNPHUx18e5lMd9w7c7G5bg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1757677514; bh=zxnBuYPZa9+/hd5HznF31Ffq8AD/IJjZPsOjr7aV6jG=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=ESH40R3xzO/QBRfaU8jE91/LF69a8IRXtMeRm7D1g8SE7tF4a0Tj5rPIic6c4T+4abQ/x8eFHJqEewtLAvsEPMjqy1CPItb9Ag2ZCCzE3BfPoz2+NzLbRhEKO0soKHuV4ZJzWR5f6tEhgNhj3N9pVOC3No+lUF3xHhuMBkoHKh73nGSyvny6Ajnef1hiWUciyZuraT+aAhEVKICpwUnMbPQ8G2XXmPth4kiIctavVIlqfqzUrrfz6A2jH/mN/eHZ0OBz4PWsrzfL/KXq8xJoxuMEJA1nsOUmEIV2LYOo0hrs52Oeqyf3SVr+zApIRVH3ePw/fbgqAZYCzW8dTe3+3g== X-YMail-OSG: nIivqLoVM1lOivMbtDPvp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9cK bTGrrC3Cl0PugKox0niQQ8FA5Sg9qsx8p7N1VZ12HOXNjVw-- X-Sonic-MF: X-Sonic-ID: c405784a-adb1-4de2-9ec4-31216b83b70e Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Fri, 12 Sep 2025 11:45:14 +0000 Received: by hermes--production-ir2-7d8c9489f-pnggd (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 93cda13a9625b3ea865113cded111022; Fri, 12 Sep 2025 11:24:49 +0000 (UTC) To: netdev@vger.kernel.org, antonio@openvpn.net, kuba@kernel.org Date: Fri, 12 Sep 2025 13:24:18 +0200 Message-ID: <20250912112420.4394-2-mmietus97@yahoo.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250912112420.4394-1-mmietus97@yahoo.com> References: <20250912112420.4394-1-mmietus97@yahoo.com> MIME-Version: 1.0 Content-Length: 5830 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.0 RCVD_IN_DNSWL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to DNSWL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#DnsBlocklists-dnsbl-block for more information. [66.163.186.204 listed in list.dnswl.org] 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.186.204 listed in wl.mailspike.net] X-Headers-End: 1ux2DP-0004Gf-TE Subject: [Openvpn-devel] [PATCH net-next v2 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?1843058467904819874?= X-GMAIL-MSGID: =?utf-8?q?1843058467904819874?= 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 | 26 ++++++++++++++ net/core/dst_cache.c | 78 +++++++++++++++++++++++++++++++++++------ 2 files changed, 94 insertions(+), 10 deletions(-) diff --git a/include/net/dst_cache.h b/include/net/dst_cache.h index 1961699598e2..d3bf616a6e6f 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) /** diff --git a/net/core/dst_cache.c b/net/core/dst_cache.c index 9ab4902324e1..f1e3992d8171 100644 --- a/net/core/dst_cache.c +++ b/net/core/dst_cache.c @@ -25,20 +25,30 @@ 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_cache->dst && cookie == dst_cache->cookie) + return; + + 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 +57,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 +70,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 +118,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 +156,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) From patchwork Fri Sep 12 11:24:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Mietus X-Patchwork-Id: 4406 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:b149:b0:671:5a2c:6455 with SMTP id s9csp3741671maw; Fri, 12 Sep 2025 04:45:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV52Sk8hRtfyXceshwvKheHeGihJHNxXCnayR2n3lRUiYJFgyZtQKVjI8Xu05wLLKcHQVFzkDIiXXc=@openvpn.net X-Google-Smtp-Source: AGHT+IGErjziv2AMIFjRbI2u5ktO51udClkpjYKGi/6e2jkG9RnsRsObDkwhv8DOaIgI/3DG0t9o X-Received: by 2002:a05:6808:152c:b0:438:236a:af8 with SMTP id 5614622812f47-43b8d91e696mr1403383b6e.17.1757677529488; Fri, 12 Sep 2025 04:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1757677529; cv=none; d=google.com; s=arc-20240605; b=EM9u33AbMjLllyKDyBmUYTzIr40YBh+BIywgS0wcvAT8cM3zN+CthxW1f561t63yWu 3Qj+rOrYh7RfyujkhGXHL4wmbnjXhwfApqqD/zbF+C5Hv0VLprSNzzzDuwGSeu6auUUa OKpQIl3pdnZg8t8oBmQGcHjj4GiLxxD76QOGlmpAI8kUHzt5StVgeHOVOXDxg3u5B06L /8tHsG6E12T2yO/ZYolLRHpL6LmYUlC1ecrc8P0t3110dlbI1blZaa7A1NrfcellUUZH pM1LUbGYQe+HpMW0JdXpIPp/RRPIRb45cPLALrf7fBpVtUiG+L2L04pH+f1rHmtcyF8h oj7Q== 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=5GHn6ZInS490kcb3/ARlquQnrr2iX5ruYvx5hSRWR4Y=; fh=Nld6ED5MA/hilqlwqNF+z3bWNSgobxU8XeD15u7QoP0=; b=PUPb+npON2dzmNHtM6/YtC+3WTYs2GHATHyCu4scBQ6wBKMg+XrcqknSh/ppWZCe8Y zQw40ZqubCvuPyf5ixBFBRo/jw9L+IAP256dq/eHO4n8VKziwVXDyZVj+uap1ocGqby7 3nksE4lNVz/W+TFlpwFvHdE2/mFPYF96VcH/HlUfVHf3/ZS+WD/wlAqJT87Ig7j57kHq n9fLK+ULzgc8ctyHhLlk6ID0b+CXeWRzdEMDKyqjT3+PXWjh+ZZEApGEAQJw/wZHhVuz n2VFUab4Qte95XcFTYcqEwgscL82qWnrB9ARt8c0QT7/oI/LSpOTK+wkNVjlrMu/H/rK r8sQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=CkgHesMZ; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=C7s1ymRQ; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=EOiq2uCs; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=AXUTbpGx; 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-43b8dd9ffa8si411759b6e.193.2025.09.12.04.45.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Sep 2025 04:45:29 -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=CkgHesMZ; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=C7s1ymRQ; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=EOiq2uCs; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=AXUTbpGx; 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=5GHn6ZInS490kcb3/ARlquQnrr2iX5ruYvx5hSRWR4Y=; b=CkgHesMZT2OCe1iZTqcrFp6Suq e83cEFwGeTHw+Vos8um4iupr8CWG9owvpenePJV3Y8ylSBbkZ280HGzP7ptRq6h1JpdlJhsSFQ97h sLDsUoZESh9ImxXSMWpfyBuJ1+iemNvVE7J3d5e6q/09ThTeWbsikR14VcjHyb3UQt5Y=; 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 1ux2DV-0005W4-QX; Fri, 12 Sep 2025 11:45:26 +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 1ux2DV-0005Vu-2m for openvpn-devel@lists.sourceforge.net; Fri, 12 Sep 2025 11:45:25 +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=hOCx3exMi/gEZlRMsfu6f3yZal5ZMUNsmvImqwmEt+8=; b=C7s1ymRQTsKmZXviTWMQjbSFYv Enfo4I4tEQNeLxyUANaK4AqtNGYGEdWFJwKyac8hrmN42VSnd5JpWfmNNaVenPZOYovDOwN6B4LVf PpWRkswnbXRIbh7hYI1btHcJDv4ZZmkYq0hrz3o3a9ytX4+iDT/pqEFNjaSX4M82YVKI=; 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=hOCx3exMi/gEZlRMsfu6f3yZal5ZMUNsmvImqwmEt+8=; b=EOiq2uCsnTJjD7Ls2F+cestdkA 9u8nMTM+m5Uy4sMN1zZSDEARBGKxN3m1f2C2VmiQ8cO0MDDDUkHXbb5DW7WwsvkA6OEoFreCHDhg3 prtJ+9axNvfSMWc5nu/2VJgor73F4uxM4uUDOQVOSBdmPG72bX4VWrkvOlsMIoDsZr0o=; 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 1ux2DV-0004Gt-7H for openvpn-devel@lists.sourceforge.net; Fri, 12 Sep 2025 11:45:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1757677514; bh=hOCx3exMi/gEZlRMsfu6f3yZal5ZMUNsmvImqwmEt+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=AXUTbpGx0siMAtt6YU689kMKfhmoRcurqE3j8wEwtlEMYef9Gr13i62HRUKzkDnTfEE64KsibFcZpINTujZkCBMNX2cpHWIoCyyJ86deBO6re8V3s5hJxl57BPHwVEwpvq7WnfR02F88MmNfljzuvy+dZeO/rkYnVRSW3S7374SnAHtLZaD9A1GWBcV6A8aP/vQJ5zPx4mZXdxzqFS8QhQdZmwOKD118I0b8XH9bBegswHmDUQNpW5LRuQll37cdWUAy+pVEm9L1PDewDqL4OBNViNbSrNcHTYC6yDvx2rnldkpocRVBXiz8YVPRRwrPxfV5s+abPHVGJkVjFJU2BA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1757677514; bh=EIbczJs5hrLgBqXpeV0IZYiBtX11wR5HdKlRFNJY0LA=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=b45dEL0vWANkApE4LITdc4+S6p/DLAjAapKBOLQuYkwoUpABa2FH+zBL01S0aERZtNr7R97RynKgI+plozieSZrZVdHLzWDvpny9VoCz1VIzw0w8kxEwrX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HbMIgvRUe7uWylSy1VhXI0sYl9m5R9tUtPRf6TDipu61f6Z76yq7skzXM2yXi9Skt7GHt4K yzooLZKGVRavykDxRbAjacp52V1Miliv.0uYBLUL9XIwLvQHOVCubfDVlVshc2pKlttam4crg_GU UtXTul4BrHRm4VT0ru95y2gkc5wZMXulGpxYRQg.z8UFm_3QjlULTVuuUN83p4peT.EAd_8Jkl7q dye2GUOAkbbX7gvhYQPUZ0x1xYWEYWyPFGfMWGRxYFyhqnq7bqobRfB7DJDsvkB.3Ii_tWuZd4tK .41i.vBcfi_bbnl0qH0B_jB1SDNRgNxGsmnY2O2QyjH8NvihwGAI- X-Sonic-MF: X-Sonic-ID: 1a3c935b-93fc-4057-a8bb-bf9bf1fce931 Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Fri, 12 Sep 2025 11:45:14 +0000 Received: by hermes--production-ir2-7d8c9489f-pnggd (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 93cda13a9625b3ea865113cded111022; Fri, 12 Sep 2025 11:24:53 +0000 (UTC) To: netdev@vger.kernel.org, antonio@openvpn.net, kuba@kernel.org Date: Fri, 12 Sep 2025 13:24:19 +0200 Message-ID: <20250912112420.4394-3-mmietus97@yahoo.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250912112420.4394-1-mmietus97@yahoo.com> References: <20250912112420.4394-1-mmietus97@yahoo.com> MIME-Version: 1.0 Content-Length: 6197 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: In cases where udp_tunnel_xmit_skb is called inside a RCU read-side critical section, we can avoid referencing the dst_entry. Implement noref variants for udp_tunnel_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_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.187.31 listed in wl.mailspike.net] X-Headers-End: 1ux2DV-0004Gt-7H Subject: [Openvpn-devel] [PATCH net-next v2 2/3] net: tunnel: implement noref flows in udp_tunnel_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?1843058472771219542?= X-GMAIL-MSGID: =?utf-8?q?1843058472771219542?= In cases where udp_tunnel_xmit_skb is called inside a RCU read-side critical section, we can avoid referencing the dst_entry. Implement noref variants for udp_tunnel_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 | 4 ++++ net/ipv4/ip_tunnel_core.c | 34 +++++++++++++++++++++++++++------- net/ipv4/udp_tunnel_core.c | 29 +++++++++++++++++++++++++---- 4 files changed, 59 insertions(+), 11 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..033098ebf789 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, 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); From patchwork Fri Sep 12 11:24: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: 4404 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:b149:b0:671:5a2c:6455 with SMTP id s9csp3736461maw; Fri, 12 Sep 2025 04:35:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXP77gEOyPwUnfGJh+XnE0z2UmrZ7nUnyZLLtFY59yXd623ztSBrzZIHU74MNm96AnvIzJjkmvoq5w=@openvpn.net X-Google-Smtp-Source: AGHT+IG99032f0AGxZfEf38+A91E8OxZ0Jb6sX8DHwCfT9Q1zuLfEOHEGYpl5VUiEU1XOnwbhVpZ X-Received: by 2002:a05:6870:6489:b0:30b:ae56:578b with SMTP id 586e51a60fabf-32e565c93camr1247344fac.39.1757676923387; Fri, 12 Sep 2025 04:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1757676923; cv=none; d=google.com; s=arc-20240605; b=LtVWOEeT8tkqcdusgh1lYiyhlfTnS7OlL/9hcmSmwYRrrp72pyQAnrpnmSOoUG9ysE OQ0UKOlCCRIM8OGypTG3YYGKlk/mC+Cn9jAfTPMPHYyegua02L3KnwxgUqQxOUwN0wGd HlEI9ZFQnOYJNUCSqU6/MFnTRKfuWlsCnYW6Flpf/gHNPfqHOOTZKvtRGErr1JVNKbte d171vD27mIGIHSe2K8QQ06xljO8Wi6rFK7vIWGEFa835CkjzU5B5X7QmNBg0ZxjO6yhY xD6T3f6SkWNnN44MSLkRt7iqV1LB22Mgs+QD5DL0eO0Ob5SqROKUYJxk37s9IQo74hY5 /wng== 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=ni6M5UTH+ljG6GdaAFhFRzNGC2aRTBSADq+z5QwBKh0=; fh=Nld6ED5MA/hilqlwqNF+z3bWNSgobxU8XeD15u7QoP0=; b=bakao2ViCwzQUymAM5hX2HzC5aTw8PsMeeehJYvffcy13IdCj4AZdPFfykMPL5wfr6 s3h5Tg8ywY4rN9xDELPA1BpTqXuviEGg8naAtFmPx5PEiGzpQAzipzVwTcMnib+cosq1 mWza85LbpcsoH1LjpTP9cI/gxTjyHKaDhX8twpqUXnm3/+41MLF0iXpuzBe/GilmzSbX UU8CjiNeQAIUuoL0d8GpfUbLyvOv9HEm9n0/0OYgOozPO4B2XpR0r2b0YlRmYaDxRq39 UdK1Z34InykWNDbmyCLleHR4XFGLSIwVHk3AO5MsE3fatz7etFxmxOEdipfdbxkdGB7m TmGg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="dpYBsB/l"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=cneMqfQU; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Dd7o/HDw"; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=sCnMhxKO; 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 46e09a7af769-7524abf2b59si1030264a34.198.2025.09.12.04.35.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Sep 2025 04:35:23 -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="dpYBsB/l"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=cneMqfQU; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Dd7o/HDw"; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=sCnMhxKO; 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=ni6M5UTH+ljG6GdaAFhFRzNGC2aRTBSADq+z5QwBKh0=; b=dpYBsB/lwm2dEfAP/+OGkxUI0F wbwU2pM74sjgZ+Pk/IW04uGnw3N8Jh3SHCI6LQM4YTzy+JKM/Dl4d6VTpTKA2NCOxXcmLearyyfZv V4ApMp7vzT8fhvgAxdvRCXowHgnCUKKmY279/Tz08hez/Dxr6Ho6OuPuVleu/kSqmN3o=; 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 1ux23j-0004dm-Cj; Fri, 12 Sep 2025 11:35:20 +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 1ux23i-0004db-Ea for openvpn-devel@lists.sourceforge.net; Fri, 12 Sep 2025 11:35:19 +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=5tdcv9pUVVHNs+QwD5gb0mr+Chpp7ofQFMpu+NxUlmg=; b=cneMqfQUIGapZQ1uxxT4hZc3+s JAesBEBpjzGv4Cjn1iovd2LNW43KfcEF+7DFdOD7RW2VpBfjH1UDDdKppJZnCyX/R79I97Sx82MhY aHiePmijj43vRcsJcjcqFf1b9OWQHj7eGZXPZIGHGvcuz3dyDDKDkTMDKxm5MUmrcOek=; 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=5tdcv9pUVVHNs+QwD5gb0mr+Chpp7ofQFMpu+NxUlmg=; b=Dd7o/HDwFHwEYQlaB0XEgibx1O vdIb6k6yYeaaESvDdjC4oFmZGOYNALU6i8D9QnojKg6R1Ne3WSFrHjiKYEs9VG7/BB/i65BNFH2uk r7H0EP76IHxXnD2CDIkYw2vy1n1mT6T6C9+DFSQm3p4hmOtqRO78D67JGjPClS6isCZo=; Received: from sonic306-20.consmr.mail.ne1.yahoo.com ([66.163.189.82]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1ux23i-0003c5-Qj for openvpn-devel@lists.sourceforge.net; Fri, 12 Sep 2025 11:35:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1757676912; bh=5tdcv9pUVVHNs+QwD5gb0mr+Chpp7ofQFMpu+NxUlmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=sCnMhxKOSz2Cy2QTo9wHOnMcgrzMUw7sCjsLIJ6QyZmiHGZwhHPytkIdmDcUZeZvs4KmkYsuQ6Ox/nEs9kVpc+mKnuj/kwzs0Ly6EmihfsjOqibbTb8ze9ImaajcLaMWgVeo8aJZzOxYs9ArMwrYvvMA80TQnyvRozR98i1WKeo1ljp4Ds/kTkE/kepU7GSoKAyHrvEn9aW7e2e768IzPJzRTGvgqk/Gnr71hIK0Ets2Ynjlempbc4bEJr+huK++3HfRpRYrsYNqRUa47+/YeqwPzzVctClCbGEA2xZeXZzTbUf1+8OriE7odghCcNBNz0XTxq8jX9q1/+YZCeneqw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1757676913; bh=FSFmoJ3G8E8inBNWfv/HqrK7GT+k7BiyGppOM7vAkW4=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=gswYaND7Em78YcX0Dn4ZPCdQBONYgDeWvuqadQRmWC7W+kmS0na+6h05UBRD0ku400EDL3AZtLj4TeZyXGtykNsvelTITSnuPrp6OPtneD0bBOKxJ+doAi/LfCGepWS81hALbL0cGRIRqKZyhOIqSU/mXrlsEaPicpohUANqCQIpeQTWYF7KqptxeXIUMaeCgsC4EsGxYD3faQnSmM4awGEH6sNSqSQwqaGTf6GJ6glBsjqjsIO4ADv7usZSCO7tRYJSkBEBfewjA+8lqRGkLqwLU4BBq3b1AgZ83kmjWArwsn/GC/1AHLwGFFFpCno1kJ7C37CfYtY9Unp4Yf4cKg== X-YMail-OSG: sjMusMgVM1kbrsP_QoAyz0qrbkinPBdd4pjNcIpj655LT8OdKlVAtXxwLveG1Ui TnTGBZJPRiDkBWTkM1WWk0xYMpR7K0siOIAoQjs1uZcKy.bX9sIfnk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onic-ID: 5dc2c8ea-e83c-4326-a34e-d2b13ee2b719 Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ne1.yahoo.com with HTTP; Fri, 12 Sep 2025 11:35:12 +0000 Received: by hermes--production-ir2-7d8c9489f-pnggd (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 93cda13a9625b3ea865113cded111022; Fri, 12 Sep 2025 11:24:57 +0000 (UTC) To: netdev@vger.kernel.org, antonio@openvpn.net, kuba@kernel.org Date: Fri, 12 Sep 2025 13:24:20 +0200 Message-ID: <20250912112420.4394-4-mmietus97@yahoo.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250912112420.4394-1-mmietus97@yahoo.com> References: <20250912112420.4394-1-mmietus97@yahoo.com> MIME-Version: 1.0 Content-Length: 1726 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: ovpn_udp4_output unnecessarily references the dst_entry from the dst_cache. Reduce this overhead by using the newly implemented udp_tunnel_xmit_skb_noref function and dst_cache helpers. Signed-off-by: Marek Mietus --- drivers/net/ovpn/udp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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.189.82 listed in wl.mailspike.net] X-Headers-End: 1ux23i-0003c5-Qj Subject: [Openvpn-devel] [PATCH net-next v2 3/3] net: ovpn: use new noref xmit flow in ovpn_udp4_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?1843057837556544174?= X-GMAIL-MSGID: =?utf-8?q?1843057837556544174?= ovpn_udp4_output unnecessarily references the dst_entry from the dst_cache. Reduce this overhead by using the newly implemented udp_tunnel_xmit_skb_noref function and dst_cache helpers. Signed-off-by: Marek Mietus --- drivers/net/ovpn/udp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ovpn/udp.c b/drivers/net/ovpn/udp.c index d6a0f7a0b75d..c5d289c23d2b 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(); @@ -269,7 +269,7 @@ 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,