From nobody Fri Mar 21 08:29:59 2025 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZJwcF6qdYz5qrJb for ; Fri, 21 Mar 2025 08:30:05 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZJwcF2kvpz480D for ; Fri, 21 Mar 2025 08:30:05 +0000 (UTC) (envelope-from markjdb@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-22349bb8605so37634845ad.0 for ; Fri, 21 Mar 2025 01:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742545804; x=1743150604; darn=freebsd.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=CoT+ZMXea+NvIovnJ4jAdevZuXOqWH76SvZ/PGSRo8A=; b=AlPGuvYF92z9CKawE3lsAe3LzcJkh8xVYkP2rUNXrn9D6dvNlzzbxCpFFeTQk3+dWf +IwnbT93BceCYofkCoTyicllB1Vn/wmaHm30Ap7A7XssHSfUZ3epc6KbwCMDlt/4xkwD TnLRxPXuoDSC/4YezpqYGf8e68PXoeTHWdY1IjX6Xus3GxC/SrllEGP1CfhJubrb3KkI nS7unmJmfy/pyb9DksLEJ6AAdXxyLCrV+sjxH8IBrjFXMJPrnc5xVHTiQegBirawMDcY iYdB0esmFsGrrMhNswauPYasmVeqnr90VO+mBZTGiDKonrNhKMtYF+QZHeO8LrrPziRT IHiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742545804; x=1743150604; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CoT+ZMXea+NvIovnJ4jAdevZuXOqWH76SvZ/PGSRo8A=; b=ewNJeKE6HiheFIsApJ9ryqyOTTsRX93ZIrFxbTyoA8lljxFvpl55XN0+xauntco3dl /c134f4xgw/upPK5QXRnXHDJsyIMUmZsgc/Haswe2HUM4ykW/pdkdHcIQ9Lqono7EPyh q5d0blFgCMJbj5qSr8GYTlYxPempx7xN59QuS8tvsb2Ib70G1Qkc3jZyKps2DnbNfHBg KvKHVrODp3oHGq7fpPnTVMc157qrZtm6rDT+gxyXnB/gtR8XI2xr2946LFmYoQ3t07Zi 5r1mZVRaF0cO00tFCACrmM3nrOG670/UHCAvtcynm6arshpSA6VPXl8Bxh7m8L2bDZ5P wdsA== X-Forwarded-Encrypted: i=1; AJvYcCXYCKWAJ8dSAsa3J9l4Pc5cxnPo402e7auYSXtPYPMgFlRSW6NydQJeCX3FcwZiGL++Aa2RebfbyXCGdA==@freebsd.org X-Gm-Message-State: AOJu0Ywmvx8EUt45CTCy0bP2aIPxy8kex5CfYr0i+/ucb6PkQddchYp0 pQeOXkIRiZw5BQ+lGQmVAwMjfG1MRXEg83iyAaUT9Ft0+SCzGWNT X-Gm-Gg: ASbGncvbwQngfOHDS4iuqDyVtQ0H9ALvHsqmVtcsKaGN75kkWL3v6HhGHGpVmo/dgbG lOEpaif7140Eynwdic11Jurmgw4K14aHIbq5/FWJlO2UYjpHmfzMIvGrFP7KSEGjpGykfeIwHgW uTqIactvVtxxCTxvu9bz3C42WiB9/sHqAVRKPEFp2VUsOCVGKeQW56H8G5sP19QZuygrVm5rHGt Xn80h8hiiZDhWCeYzbWABtqw+g60CwfGrrk7npf8FmI64L9+omuEl1lEj+kQTmXwqE/SEc8I/jm ay/fOOM+KbnAXvoLx9ysvs56I2uN55ydbYwLMiHfEA39zRKAer771N9oISW/nE/QS3U= X-Google-Smtp-Source: AGHT+IFXvm9edAwNDVpMsfPGRC9nee0mSx5ylZvxwGu+aiSMqs4gi2/SNV9cvX8+8QqfCFR2WlCVlg== X-Received: by 2002:a17:902:cccb:b0:224:18bb:44c2 with SMTP id d9443c01a7336-22780c7e14dmr35941595ad.6.1742545803674; Fri, 21 Mar 2025 01:30:03 -0700 (PDT) Received: from framework (M106185150005.v4.enabler.ne.jp. [106.185.150.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7390618e4b6sm1234600b3a.180.2025.03.21.01.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Mar 2025 01:30:03 -0700 (PDT) Date: Fri, 21 Mar 2025 04:29:59 -0400 From: Mark Johnston To: Paul Vixie Cc: Julian Elischer , "freebsd-net@freebsd.org" Subject: Re: per-FIB socket binding Message-ID: References: <7772475.EvYhyI6sBW@dhcp-151.access.rits.tisf.net> <31693e65-7d88-40ea-900d-d736cadcfe1f@elischer.org> <24545810.ouqheUzb2q@localhost> List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24545810.ouqheUzb2q@localhost> X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Queue-Id: 4ZJwcF2kvpz480D X-Spamd-Bar: ---- On Fri, Mar 21, 2025 at 08:13:59AM +0000, Paul Vixie wrote: > This is a reply to the first of two of Julian's recent messages. > > On Friday, March 14, 2025 4:26:30 AM UTC Julian Elischer wrote: > > On 1/28/25 12:09 AM, Mark Johnston wrote: > > > On Sat, Jan 25, 2025 at 08:44:25PM +0000, Paul Vixie wrote: > > >> does anyone remember why the FIB of a socket or process cannot be > > >> discovered from user mode? lack of motivation -- or deliberate design > > >> decision? > > That was probably me. > > I probably just didn't need it for my case and didn't spend time on it. > > KK. I have a need now. > > > > ... > > > > > > So, an application already knows the FIB number of any given socket, > > > since it can find its own FIB number, and new sockets always inherit the > > > FIB number of the process or the listening socket. Therefore, I believe > > > there's no reason not to provide an explicit mechanism to query the FIB > > > number. > > > > I believe so.. > > Not all sockets within a process are created within that process. When stdin, > stdout, and stderr are pty's or pipes, they predate the process, and have no > FIB of their own since they aren't sockets. Therefore the process FIB in this > case has to be set after fork and before exec by the parent, so that work done > within this process is within the FIB that only the parent would otherwise > know about. > > I expect to teach sshd, http, and nginx to look at the FIB of its network > socket (which after fibnum2 will not always be that of the listener socket) > and then setfib() the forked process FIB to this value before execing the > shell or command. Obviously that subprocess will be able to setfib() to some > other value if so desired, but the default FIB for the shell and its > subprocesses should be the same as for the network socket. > > For this I do not need a getfib() syscall but I will need an SO_FIB socket > option which would allow both setting and getting. We'll have to leave > SO_SETFIB for ABI/API stability reasons, of course. For what it's worth, I already added this in main: https://cgit.FreeBSD.org/src/commit/?id=ee951eb59f2136a604e3fbb12abf8d8344da0c99 and in stable/14: https://cgit.FreeBSD.org/src/commit/?id=b0f2df45e7a6f1db28bd96fc5da690618a0c38a6