The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=cb7009867ae6b33aa39cb6cb1453b69073144b44
commit cb7009867ae6b33aa39cb6cb1453b69073144b44 Author: Mark Johnston <[email protected]> AuthorDate: 2026-08-25 18:09:09 +0000 Commit: Mark Johnston <[email protected]> CommitDate: 2026-08-25 18:09:09 +0000 socket: Restore handling of IPPROTO_DIVERT Python scripts which use divert sockets no longer work after commit e967a2a03677; even if one patches socket() calls, getaddrlen() doesn't work on divert sockets, needed to use recvfrom(). Restore compatibility when COMPAT_FREEBSD15 is defined. Reviewed by: kib Sponsored by: OPNsense Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D59018 --- sys/kern/uipc_socket.c | 7 +++++++ sys/netinet/in.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index dc4db57c07e2..17f36ae69125 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -989,6 +989,13 @@ socreate(int dom, struct socket **aso, int type, int proto, struct socket *so; int error; +#ifdef COMPAT_FREEBSD15 + /* divert(4) historically abuses PF_INET. Use PF_DIVERT instead. */ + if (__predict_false(dom == PF_INET && type == SOCK_RAW && + proto == __IPPROTO_DIVERT)) + dom = PF_DIVERT; +#endif + prp = pffindproto(dom, type, proto); if (prp == NULL) { /* No support for domain. */ diff --git a/sys/netinet/in.h b/sys/netinet/in.h index c4698b7056eb..8838bdbdb416 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -253,6 +253,8 @@ __END_DECLS /* last return value of *_input(), meaning "all job for this pkt is done". */ #define IPPROTO_DONE 257 +#define __IPPROTO_DIVERT 258 /* Deprecated, use PF_DIVERT */ + /* Only used internally, so can be outside the range of valid IP protocols. */ #define IPPROTO_SEND 259 /* SeND pseudo-protocol */
