From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796356994; b=iB+09hAnWU4vSK7spKLjbUWCTk5Y0q7aL6hJ5QyB66gghJinbS/nE6AFuqk7dGPyCkBO Cm6aEIUt10d/NejKiz0d+2IPiVrOHTp8SA1ACXcKRYyxRq0094/v3/XR1lxGdtLkLFble idcUgy2p6s/UyKE0hbIZIFahfSp/0ip8bN6J62Bi24qQAKFqIpwzKEEPzSSIolTfDN7EH +qkmyFWuxKrEqYNwcg8ysyrrbQRWMhr2jmoTVSryuqr/wda4HdMzACPdG09Ek6KxnRBgh OAc5fkX9dwr1pGWfGydq3oZbO5vQoGRNgEsfxsQrV8ccyybHyecPOMI9ZB3t5fOC6gQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796356994; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=DTAH3Lckwgp3giAF12zYKAhaX6nOfFOLPijqlv7FSUc=; b=RisXGuCbhiRQjhjryrggkky7/lAk+6jcTSASZs314v7xXXfVjwD4h3WTcg/QUb79++T3 AcWzCKLT0AGlr2xB2VMwNSIdlyT7PLm9l0DVd+CLz/9FY+3eDc1Pzay+BpYShet6Z4s7j Sov0NuM1mLWYZWaVBmyW3qLyTHFydUglONJV0TE48x7/AwZq4MA7rxDPk6H8+tR5FJwlR TvSQmj6GtjS7NNFCPy6tsEFCQZeI7AQvxHHtuAT3nOQxMfYuU/aMLyN7TAs2xBhmp99R6 YJcUFeyj5/6+YmdGuYYHjT79ujfn2xlIixH7J0CnsYAzv1uetzXaljo+w+sLEcxzx+g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=iZ9kdKcH; arc=none smtp.remote-ip=209.85.219.71 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E931606A322 for ; Fri, 4 Dec 2026 04:03:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4E931606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=iZ9kdKcH Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-921db6a9009so6078376d6.3 for ; Thu, 03 Dec 2026 20:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796356993; x=1796961793; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=DTAH3Lckwgp3giAF12zYKAhaX6nOfFOLPijqlv7FSUc=; b=iZ9kdKcH5NgtNDikFgktWn2r5qdAQXiKMScfCsVbovkmH8xjCUeor2v+y54JKuW9lX WlogVQd2rhB8WpjlYUKoRwTLL+mT9tE0UvYGBnPXgPAa1Nqvq/Z4qBRgbX0Cy1Nmz7fr ku3mmL6tGbHSBR9uN96kx45WWcCNQm9wF3BHp0+PFDRBVuJRFpJGrouYURoqPTxtf/Mm XNjAMWmAWGrhuJQ64QRy4gPzAQd1WnsBnQjXrt6AOoXfo4PhLtBfZm3GqkzHgHIEfb8s GWghJorOZ/n+8VdNoTCAxxST0McAuAaqrG0zvsw56RkHav/MXA9ztl6kaDkkcle9YJlU Q+LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796356993; x=1796961793; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=DTAH3Lckwgp3giAF12zYKAhaX6nOfFOLPijqlv7FSUc=; b=o6oBChoTKUAozVWWbr2BKmc9kKmXoDP7hLk0zST4pVVp/W3QkVeIST8yO3QOKqm8YM zJj2YgIGdKOm2xCayHu374x0QTstpMO7y3zKH+20WBQ6wHeOm4n5Ygdtkh22zdrz+TQY w4k1tzIQGK+flfo4V7cgkacNCwv7PgZGg93jKWISc8ErHZkwFBE2kjAwEFNYL8B2L1d0 UdzZ7PM3Dho24WGHt1PieY/eXF8xHcYo8HKBgrdPhN+kmOHhlppITju7P6Y6aB/5sh2M 9qwKEIzzeQbmiVzo6acBOWmPBpH8XHfMM16wQLghEpa+4SXSEpy0tT9LPFOJHeo1QJRw 7Wag== X-Forwarded-Encrypted: i=1; AL+hErFLcW84fzqsLF5PF4emd/rRRigimbqocCpba2aiu3qQaQ3IzupIJi5x39Q5g31XvclosEvstkkK5sEYgxI=@vger.kernel.org X-Gm-Message-State: APuU4Z+AXQIANELgFt6aBb9U480wxTYgaVqv9xkiITvUsd4G6LSJ8NbG KC4GSsg8O4wbcC3Gm/rJNRHoLhE3c0Tb35xkV/KGsSgdQbbPo1DOYbH9kvLSWSls9HMaYxPqjG2 Ixlw7yFg5eA== X-Received: from qvqd2.prod.google.com ([2002:ad4:50a2:0:b0:921:6405:b9a0]) (user=willemb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6214:5989:b0:921:d2af:b99e with SMTP id 6a1803df08f44-921e2471180mr11915436d6.34.1796356992893; Thu, 03 Dec 2026 20:03:12 -0800 (PST) Date: Thu, 03 Dec 2026 23:03:12 -0500 In-Reply-To: <20261127-tcp-l3mdev-exempt-ports-v3-1-f875b1184f26@nexthop.ai> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261127-tcp-l3mdev-exempt-ports-v3-0-f875b1184f26@nexthop.ai> <20261127-tcp-l3mdev-exempt-ports-v3-1-f875b1184f26@nexthop.ai> Message-ID: Subject: Re: [PATCH net-next v3 1/2] tcp: add net.ipv4.tcp_l3mdev_exempt_ports sysctl From: willemb@google.com To: Kalash Nainwal via B4 Relay , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Jonathan Corbet , Shuah Khan , Randy Dunlap , David Ahern , Ido Schimmel , Neal Cardwell , Kuniyuki Iwashima Cc: Shuah Khan , Joel Granados , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Kalash Nainwal Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes Kalash Nainwal via B4 Relay wrote: > From: Kalash Nainwal > With tcp_l3mdev_accept=1, an unbound listener also matches connections > that arrive in a VRF. If a VRF-bound listener exists on the same port > and both use SO_REUSEPORT, the lookup returns whichever is first in the > listen bucket, not the VRF-bound one. Since AF_INET and AF_INET6 > reuseport sockets are inserted at opposite ends of the bucket, the same > setup can pick the VRF-bound listener for IPv4 and the unbound one for > IPv6. > This breaks, for example, a BGP daemon with a TCP-MD5 key only on its > VRF-bound listener: IPv6 peers in the VRF reach the unbound listener > and the session comes up without MD5. > Add net.ipv4.tcp_l3mdev_exempt_ports, a per-netns port list in the > same format as ip_local_reserved_ports. For a listed port, an unbound > listener does not match connections that arrive in a VRF, so only a > listener bound to the VRF or to the receiving device can take them. > Only listener lookup changes. Other ports and default-VRF traffic are > not affected. The default is empty. > This is opt-in rather than a change to the lookup itself. With both > listeners present, existing setups get a stable result that depends on > creation order and address family; making the bound listener always > win would change that for every tcp_l3mdev_accept user. This compatibility argument does not justify adding a permanent 65536-bit port bitmap sysctl (and 8 KiB per network namespace) instead of fixing listener lookup: 1. The current behavior is explicitly documented as unspecified, not a UAPI contract. Documentation/networking/vrf.rst (commit b1165777fe0b) already warns that with tcp_l3mdev_accept=1 "it is unspecified which listening socket will be selected to handle connections for VRF traffic" and calls out this exact TCP-MD5 failure mode. 2. No deployment can meaningfully rely on the current behavior. Because inet_hash() prepends AF_INET sockets (LIFO) and appends AF_INET6 SO_REUSEPORT sockets (FIFO), the same startup order selects opposite listeners for IPv4 vs IPv6, and any daemon/VRF restart flips the winner. Worse, whenever the unbound listener sits ahead in the bucket, the VRF-bound listener is completely unreachable (it cannot match non-VRF traffic and its own VRF traffic is stolen). For non-reuseport listeners, compute_score() already prefers sk_bound_dev_if != 0. 3. Netdev precedent is to fix SO_REUSEPORT short-circuit shadowing in the lookup without a sysctl: - d894ba18d4e4 ("soreuseport: fix ordering for mixed v4/v6 sockets") - d9fbc7f6431f / 0ee58dad5b06 ("net: tcp[6]: prefer listeners bound to an address") - 8d6c414cd2fb ("net: prefer socket bound to interface when not in VRF") 4. The bitmap sysctl leaves the real bug unfixed everywhere else: every unlisted port keeps the IPv4/IPv6 divergence and MD5/AO bypass, non-VRF SO_BINDTODEVICE + unbound SO_REUSEPORT (sdif == 0) remains broken regardless of the sysctl, and UDP (udp_l3mdev_accept=1, udp[46]_lib_lookup2() when !reuseport_has_conns()) has the same early return. Please drop the sysctl and rework the series to fix device-bound listener preference in inet_lhash2_lookup() / inet6_lhash2_lookup()