From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796356994; b=0w3zpdCYnTbRRGJGBnWvFhdnVurD1L0ALp2VAurW3WRUdVxiUiiFXWNi6U/XiEqcljhs lxzuMDgFB3rIeQNu/pmhKfj5NO1AEEALfwK/LHbTisMh6oUrWFwazQj6/TI5/voTSRJLr JOUpHGcQZTrp0ufOkP8uEgCnDfK0VoVMKTar1cJT6CtUWghvtHnq4vfpQUFomnyH3THC0 Qis5FwWlCbblepVM1TV4dczshkprdkjO+lkAd9k288hZ7cMihBENCGyyRTT/hknA0o0da xxIVv8z5Ug+6ElZmHX+kIXtoNZksxFFQKpTl7Mb1wIL7QNf35s3wzJHd6XzrVHzo3Jw== 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=U2tElVKTzdfkFs2gYGEOoYPHNMPyd4bqYLPFm7g4YaEOiHuZVBDE5H++a4lXYrMYrB7z adVcNcTOpe98+ij7WWBdYMlW87ieHE3PS0gjw8/ng3HCGFn6iUDONcvipZ3ar8eKzhEbT T68/cWILVdnfeG4ly7lbQD8nbQpnfelAXq6oAGK6iqQN2HXSCF4M8i4tSh1KlSKS4OS3j 4WIrsSdyzzzugePx6nRBUSZswqnQvSvLQ5pD6+9LpCUtzbG6DSaAXPUbxnEe91BhHzh8e JztrnBgqkZX5pLIT8dgQnccbI04q4hj6sk2cgsgn7BtsmPCoEmwgiWAP4SlEolt43SQ== 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.69 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (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 56CB6606A32F for ; Fri, 4 Dec 2026 04:03:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 56CB6606A32F 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) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=iZ9kdKcH Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-921db6a9009so6078346d6.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=l3vqKKVGYI/gELqO5J5dJmh/vasLP6C7PEgeQ5s4rSKathKh0zin/WMN5SByAVyxWm AWC0EAEHYJTwvTYQOMSk7UMiNxGk4lIBAHANLpPGC/+ivJiZ0dn6YYCAU05BGnPkRLCg acEY37ewTH6/IJgzj/kUUo+n+RLmqplHYm1k1/NrdQNhAhPqhNRAjBK9dO1xYIFiukvU 7hRgHT5fYJhjdawWWfBjftu/MIbU6QhOd1QiX9L25SRB6K9nhKjjq+GOADeN7H+8joLH LEbPPnCWjeQZeEHNV60ci4JNTOC+/jM7kYw18ptmaNFiIxGWXboJeDqnjIiAHa/aG30I YDeA== X-Forwarded-Encrypted: i=1; AL+hErFiuywiCG5tIpFnP4dr8//hqm8PKviLlLIkuy47tnhHxqbtNBzQqyLmW8NNSPV2r2OUqGnCwqVWNUg=@vger.kernel.org X-Gm-Message-State: APuU4Z/DhiSJzWJHbkO3YoaB7d30CihFS76RmEaKwVCqT4UuC9TFe8Nu Fizon5/P4S5XNf9NuDJczQv5Od6jsxh1MowICNOXDKSlyxfqyh9KbosT2dG0UE9JwK7jZOfcyDW CjumAo5887g== 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-doc@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()