From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796356994; b=QcOTXs8+DC9KBvrhlIipRXH+yW92j2BTX6Rv2Zccb1MSi4P+YWRai5iTmccGDq3VDOfT x+yUyuE4a+FejmQLndW4YuxxsaBfWL1ptsNvSSkEQ1+24BJDH9u1Il15RFuyihtLwzYNo l4b1eTRzNftpiHcbrki3wtSWTl0ZLHbyEmY5VZjo+3bE1EC7P8W/AOmUmgabNkknJtcVa 1ocZlcSh92wH/iwtx12UAizZtqBZ9JzdC/tdIlp1ckJ4WbYNePE0SuNpwydNJ95QFC79y 62gI7RWZfYnJWhAq6EEuCwCTCJSDJdVmipHU8MTyQ8k2cOULTKh6N8IPKxXxo72AVkA== 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=Ibfp7RFhCVQ75HHALnRfZmR3yhMH5pKEdsOb6QdhNOG9WCDDUdReSMakuLVxpsdcCqDn Hz841jgy4b+aKNiLRTypTXXdnlXcKxyY2bjJZc7xMXdWA0PSegFFU5PTOMm3YZZz3bf6l uQI07aqz5QH80LMTnC6g9JZhieiLRnhtxxVKObihPRUrP3Mhl6K1D54iwSluS7kI6GCq/ 3q3fwmK9mCe11rka2ZnqatErsWnMgxeQoS5bC/YEJvqatgHy7WlSqYGju2L0t957IS0jS Pr0cnbyxAIw0tM0IOK5IZlGKXvrbQKUhxoI51z3I6VwS1jAbR1TZ87Wo9UATURkaohQ== 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.70 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (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 53C04606A32D for ; Fri, 4 Dec 2026 04:03:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 53C04606A32D 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-f70.google.com with SMTP id 6a1803df08f44-91b937ecbb4so5546486d6.2 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=TCdOq0Hs0s+CYgpB7Svda9m0obd+pgyqN1lZWvI304kWYj34V9HOQ3MunMltY23Osk lvQvKBBM0jERH+6ETIFCmetPgkbN+veOWukaDe+Q6p/Mw9nxnWtimfYNo98yZ9j8EQ1P 5t8xh4zjPOAMWEPcEGCNPEyv1S9qNKkf2OCAeTHUP+Y+eoRcJYIkenqD42vN3mRS5xqn eD7876UF7brXESQy0jaGuZTt8IBsGZ8ZZyh2zWdu+v7we724cE/TgLC+rqP087ZWd6tA 52DwR5jBjLkyWFgblpATvfzeEkVL3IepHyVRq/Nh3id3zZDcgtSUN5QCRHgsyY0Pb7YH mI0g== X-Forwarded-Encrypted: i=1; AL+hErGle3eV2N7Sh3ISjahrwhPhWo++UU/YVjueIhRBG1FASZyHxtPqxiGESdjScvcXBspFRjuln+E=@vger.kernel.org X-Gm-Message-State: APuU4Z9+D3Q2aJ7TQUUaqoBdCqjG115tGu1c/6UTJmxyqosInpK2sDdw tnwkVRTJ4qaMqIJLMorkFFOlVyQ8+Ym5x7SnZv3AkMdwkxpMNv+8Qy7C9H5ijWbwBA5DGZaCBrQ YtX9IPw23lA== 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: netdev@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()