Re: git: cb7009867ae6 - main - socket: Restore handling of IPPROTO_DIVERT

From: Mark Johnston <markj_at_freebsd.org>
Date: Tue, 25 Aug 2026 19:37:51 UTC
On Tue, Aug 25, 2026 at 11:56:19AM -0700, Gleb Smirnoff wrote:
> On Tue, Aug 25, 2026 at 06:17:45PM +0000, Mark Johnston wrote:
> M> The branch main has been updated by markj:
> M> 
> M> URL: https://cgit.FreeBSD.org/src/commit/?id=cb7009867ae6b33aa39cb6cb1453b69073144b44
> M> 
> M> commit cb7009867ae6b33aa39cb6cb1453b69073144b44
> M> Author:     Mark Johnston <markj@FreeBSD.org>
> M> AuthorDate: 2026-08-25 18:09:09 +0000
> M> Commit:     Mark Johnston <markj@FreeBSD.org>
> M> CommitDate: 2026-08-25 18:09:09 +0000
> M> 
> M>     socket: Restore handling of IPPROTO_DIVERT
> M>     
> M>     Python scripts which use divert sockets no longer work after commit
> M>     e967a2a03677; even if one patches socket() calls, getaddrlen() doesn't
> M>     work on divert sockets, needed to use recvfrom().
> M>     
> M>     Restore compatibility when COMPAT_FREEBSD15 is defined.
> M>     
> M>     Reviewed by:    kib
> M>     Sponsored by:   OPNsense
> M>     Sponsored by:   Klara, Inc.
> M>     Differential Revision:  https://reviews.freebsd.org/D59018
> 
> I'm not happy with this change.  I know that I'm slow on reacting on reviews,
> but for this one you didn't give me a week to say anything.

In December you wrote this email:
https://lists.freebsd.org/archives/dev-commits-src-main/2025-December/038370.html

Specifically:

	I'm fine with prolonging existence of the shim until python 3.11
	goes out of support, which is 2027-10.

I took this to mean that you were tacitly ok with restoring the shim, at
least for now, given that 2027-10 is more than a year away.

> I did a lot of work to discover and upstream all applications in the ports that
> use divert(4) to properly use PF_DIVERT.
> 
> I worked with python to adopt PF_DIVERT and I also fixed the getaddrlen()
> there, too.  See https://github.com/python/cpython/pull/142993
> 
> I addressed all python scripts in the tests to properly use PF_DIVERT.
> 
> Unfortunately python is very slow with accepting changes and our ports are very
> slow with adopting newer python versions.  However, the bugfix can be easily
> added to python312 port as a patch.
> 
> Now with this change we will have extra check for every socket(2) syscall to
> satisfy a very small number of installations, who are ether willing to run
> FreeBSD 16 with outdated python either with proper version of python, but are
> unwilling to apply a trivial change to their script.  Can you estimate number
> of this installations?

Of course I cannot, nor can you estimate the number of applications
silently broken by the original change.  The ports tree does not contain
everything that runs on FreeBSD.

Python is just an example, I used it to justify this change because it
has bitten me multiple times since you removed this check.  It seems
quite plausible that there are other divert sockets applications out
that are simply broken now.

In general I believe we try quite hard to make old binaries continue to
work on FreeBSD.  It's a very useful feature.  That is why e.g.,
sendfile() still has a COMPAT_FREEBSD4 shim.  Is it important to remove
that too?  If not, then what's different about socket()?

> And we all know that COMPAT_FREEBSD15 is going to be part of GENERIC for the
> time being, thus the argument that it can potentially be compiled out isn't
> strong at all.