From patchwork Mon Jul 27 20:07:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 5136 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:190f:b0:87d:a69c:34be with SMTP id g15csp1598707maz; Mon, 27 Jul 2026 13:07:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AHgh+RqFtvBNIjvjYMxxIqGBwMQwGjcJh2cbunA4LkuE4dffFGocKB1vgSeyyNBnPVJnnikYwsR216/yEj4=@openvpn.net X-Received: by 2002:a05:6820:2008:b0:6a1:3e91:dca8 with SMTP id 006d021491bc7-6aaff8f2c5emr7904156eaf.24.1785182854209; Mon, 27 Jul 2026 13:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1785182854; cv=none; d=google.com; s=arc-20260327; b=gxNr0jTGQNeyeEHdyqtamQcuKHN9F+q4DFYFdSMC63WFW2bsEOaTl7yI8Zw6wg9nJ1 rUb27A739xlG0UumCXkrD+BmJIOK65mNQ9VVB729paAyv4Uv61IdgJ7BckXG+FC+9GDw h+hrNpbWLHRvHGSU6ZStWwMjvw4qXzNPSdMume6NlF7DR2LyZ//JPEABzVjWKx+4pNkQ V35R5F/nitgN2q79/KzyKylWTlpUpE4Bdcx0bWTNCH7CqsOb0DbdId7LoPfDLZ+hlIAv L4XPLRLuITj+RXbqrwK6yP3PfdI4gmq7DcfEgvdy+qw76UWDCxwbcGUigZrQF+XQd12A w6HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:cc:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=c3LMynfM/+OH0kRIAcfdfck6JfPCIhuWHv84WnQ5XCA=; fh=BsMg/B0Yb/hS/rzP5Npz4luh0IleZm8REk1XWiWRt2A=; b=OiZG/m3Sf/HXLI40GeqC/W45FWa/YXumLKuAXm3HtcUxBrq1Wr+xBwp+kvHaTtCVsF 32Nkmw4IBex7B3eniaFfL/WRI/8hSc3QpL92pPbW4hy7Mt6q6oDzLclwPZURqEsVPt+a s8RRaNUafnfx2S2LXdowrqGAqrxUgAw1vRrZitL5PW7uxmogkRJbMu4RFYfNH4wzAqEq hw6ibwBAAkVYz5CDLKohze+RjCPcIJ/4O3DTXpOxjiS67xEUoQUVpnw1P54mcrs1652X Isl2lbsydOCWAzNQdjMhAuafx+s3p1muSkyG4TjNwG645kYdFza7702fA3M+hZ5uj6Vw 5NVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=QofmzTc7; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=KGTOD6IV; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=GyR8MZO6; dkim=neutral (body hash did not verify) header.i=@unstable.cc header.s=MBO0001 header.b=zfXcc6E1; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 586e51a60fabf-457aa18e57esi13456497fac.12.2026.07.27.13.07.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jul 2026 13:07:34 -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=QofmzTc7; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=KGTOD6IV; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=GyR8MZO6; dkim=neutral (body hash did not verify) header.i=@unstable.cc header.s=MBO0001 header.b=zfXcc6E1; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=c3LMynfM/+OH0kRIAcfdfck6JfPCIhuWHv84WnQ5XCA=; b=QofmzTc7KUAnlNQReshSIjl5u0 JzWQoclltwLvy2IAhzdHGiRyAYekbv5h2eMqJBM2C3AcCyyWjVuIzQnsgD69aBpIaxGule2Rg96fR QTrvHV+/BuucSDDXQYo3Ms+n2NS/O20h5B2+A/5gzRj9CVAAj8521ZoyN0iUzygiCTr4=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1woRbm-0004Jc-Gv; Mon, 27 Jul 2026 20:07:31 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1woRbi-0004JD-I4 for openvpn-devel@lists.sourceforge.net; Mon, 27 Jul 2026 20:07:27 +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=IU8+7nKGLXOwf74BQT5HAZ0RSMUWAe0anDASGXWrYcM=; b=KGTOD6IVTY6HBMDLARd71wMeU5 f/IA66quBNWOjlh6aeEwMCWooq/7bfitc5nOnPvkkgxvOjgLOERRjrIUFQiFfAu9WH8BwjTEAISZr 3tMWd+EGLRKR07WbF71dcrfOycuwc8YYYIzpU5C+mie+iSF/UcHUzCmAVbaTnQrg6GM0=; 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=IU8+7nKGLXOwf74BQT5HAZ0RSMUWAe0anDASGXWrYcM=; b=GyR8MZO6kDUDNTu0UbGHdhLjOt ZbzXA3XshLljrz+ZhnOMp47xBkIEn8OYkKvZE2cNB8+o6MrSJ1UAQ8FXb9waMX+iO2AJMvEkZ1JFl 6CPOjI7xjA/Wp8ReHIRrQdDM4vzgw7+gWRXRpEDUF0T/Nv3KCjLA9yP7aEAiaoHuYNW8=; Received: from mout-p-201.mailbox.org ([80.241.56.171]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1woRbg-0001PL-Ds for openvpn-devel@lists.sourceforge.net; Mon, 27 Jul 2026 20:07:27 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4h88l84TqHzMlKk; Mon, 27 Jul 2026 22:07:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unstable.cc; s=MBO0001; t=1785182836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IU8+7nKGLXOwf74BQT5HAZ0RSMUWAe0anDASGXWrYcM=; b=zfXcc6E1Bt8Ty9SH8lb8hFm1aKyMCCkfTvRP/cE+AjGNyh/PJSOVpK3MIlrMRNjG9zaNK7 9l4pbKC5GE7Ic2aSommwEDL48sqaxf9AT8H1Ll+fT714j08fOiL8ZdPxBmfMt2e5Ra0s/F OuFoOZqWpj/oavmAGSO+WExKQv4OidHQivyHBD7/XNjoCQqx95uptPpj2WenbhiyoOZJP/ PFXVB3OrRj4MP8MKcN5yoGd8El8p0epEvxADubt6jeM2jDYxPvUu774GX8DAZym8at8aue lxxp/E6f5xIf/f4BNMYghyglaPCfF141ePUs9TtJkYoLLSVW9U2+0Xet+yRbNA== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of a@unstable.cc designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=a@unstable.cc From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Mon, 27 Jul 2026 22:07:02 +0200 Message-ID: <20260727200705.869169-7-a@unstable.cc> In-Reply-To: <20260727200705.869169-1-a@unstable.cc> References: <20260727200705.869169-1-a@unstable.cc> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4h88l84TqHzMlKk X-Spam-Score: -0.2 (/) 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: From: Antonio Quartulli The by_transp_addr table is keyed on the peer's remote transport address, but the float rehash hashed bind->remote directly, while the two other sites that touch the table build a clean key first: ovp [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H5 RBL: Excellent reputation (+5) [80.241.56.171 listed in wl.mailspike.net] -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Headers-End: 1woRbg-0001PL-Ds Subject: [Openvpn-devel] [PATCH ovpn net v3 6/9] ovpn: hash floated peer by transport identity only 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: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1871899896984629390 X-GMAIL-MSGID: 1871899896984629390 From: Antonio Quartulli The by_transp_addr table is keyed on the peer's remote transport address, but the float rehash hashed bind->remote directly, while the two other sites that touch the table build a clean key first: ovpn_peer_add_mp() and the lookup in ovpn_peer_get_by_transp_addr() both hash a sockaddr holding only family/address/port. For a link-local IPv6 peer, bind->remote carries sin6_scope_id (set from ipv6_iface_scope_id() when the endpoint is learned), and that field is folded into the jhash() over sizeof(struct sockaddr_in6). The lookup never sets sin6_scope_id, so after such a peer floats it is rehashed into a scope_id-dependent bucket that lookups (scope_id 0) never visit, making the peer unreachable through the by_transp_addr fallback. ovpn_peer_transp_match() only compares address and port, so the hash was keying on a field the match ignores. sin6_scope_id must stay in bind->remote because the TX path uses it as flowi6_oif, so it cannot just be cleared there. Instead build the hash key from family/address/port only, exactly like ovpn_peer_add_mp() and the lookup, so all three sites agree on the bucket. Fixes: f0281c1d3732 ("ovpn: add support for updating local or remote UDP endpoint") Signed-off-by: Antonio Quartulli --- drivers/net/ovpn/peer.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/net/ovpn/peer.c b/drivers/net/ovpn/peer.c index be772d14ae41..5282dfead4b3 100644 --- a/drivers/net/ovpn/peer.c +++ b/drivers/net/ovpn/peer.c @@ -913,7 +913,10 @@ bool ovpn_peer_check_by_src(struct ovpn_priv *ovpn, struct sk_buff *skb, static void __ovpn_peer_hash_transp_addr(struct ovpn_peer *peer, const struct ovpn_bind *bind) { + struct sockaddr_storage sa = {}; struct hlist_nulls_head *nhead; + struct sockaddr_in6 *sa6; + struct sockaddr_in *sa4; size_t salen; lockdep_assert_held(&peer->ovpn->lock); @@ -929,12 +932,26 @@ static void __ovpn_peer_hash_transp_addr(struct ovpn_peer *peer, if (unlikely(hlist_unhashed(&peer->hash_entry_id))) return; + /* Build the hash key from the transport identity only + * (family/address/port), matching ovpn_peer_add_mp() and the lookup + * in ovpn_peer_get_by_transp_addr(). Hashing bind->remote directly + * would fold in sin6_scope_id (set on the float path but never by the + * lookup), scattering the peer into a bucket lookups cannot reach. + */ switch (bind->remote.in4.sin_family) { case AF_INET: - salen = sizeof(struct sockaddr_in); + sa4 = (struct sockaddr_in *)&sa; + sa4->sin_family = AF_INET; + sa4->sin_addr.s_addr = bind->remote.in4.sin_addr.s_addr; + sa4->sin_port = bind->remote.in4.sin_port; + salen = sizeof(*sa4); break; case AF_INET6: - salen = sizeof(struct sockaddr_in6); + sa6 = (struct sockaddr_in6 *)&sa; + sa6->sin6_family = AF_INET6; + sa6->sin6_addr = bind->remote.in6.sin6_addr; + sa6->sin6_port = bind->remote.in6.sin6_port; + salen = sizeof(*sa6); break; default: return; @@ -943,8 +960,8 @@ static void __ovpn_peer_hash_transp_addr(struct ovpn_peer *peer, /* remove old hashing (no-op if entry is not currently linked) */ hlist_nulls_del_init_rcu(&peer->hash_entry_transp_addr); /* re-add with current transport address */ - nhead = ovpn_get_hash_head(peer->ovpn->peers->by_transp_addr, - &bind->remote, salen); + nhead = ovpn_get_hash_head(peer->ovpn->peers->by_transp_addr, &sa, + salen); hlist_nulls_add_head_rcu(&peer->hash_entry_transp_addr, nhead); }