<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/sys/compat/linux/linux_socket.c, branch releng/15.0</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>linux: getsockopt(): Simplify exporting groups a bit</title>
<updated>2025-09-23T12:02:45+00:00</updated>
<author>
<name>Olivier Certner</name>
<email>olce@FreeBSD.org</email>
</author>
<published>2025-08-29T08:26:59+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=5eaee33a2a701ef86026338fbfa9dda4634e3b2c'/>
<id>5eaee33a2a701ef86026338fbfa9dda4634e3b2c</id>
<content type='text'>
No functional change (intended).

Go through conversion to a 'l_gid_t' before copying out in order to cope
with differing group types (except for not representable values, of
course).  This is what is done, e.g., for getgroups() in 'linux_misc.c'.
As Linux's group type is the same as ours on all architectures, we could
as well just stop bothering and copy out our memory representation,
eliminating the loop here.  Whatever the choice, though, it has to be
consistent here and there.

Introduce 'out' of type 'l_gid_t' to avoid performing "by hand" array
arithmetics when copying out.

MFC after:      5 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52280

(cherry picked from commit 10b789d7e14862c77f77f07e8af84d73d73012c6)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
No functional change (intended).

Go through conversion to a 'l_gid_t' before copying out in order to cope
with differing group types (except for not representable values, of
course).  This is what is done, e.g., for getgroups() in 'linux_misc.c'.
As Linux's group type is the same as ours on all architectures, we could
as well just stop bothering and copy out our memory representation,
eliminating the loop here.  Whatever the choice, though, it has to be
consistent here and there.

Introduce 'out' of type 'l_gid_t' to avoid performing "by hand" array
arithmetics when copying out.

MFC after:      5 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52280

(cherry picked from commit 10b789d7e14862c77f77f07e8af84d73d73012c6)
</pre>
</div>
</content>
</entry>
<entry>
<title>linux: Handle IP_RECVTOS cmsg type</title>
<updated>2025-03-10T18:12:36+00:00</updated>
<author>
<name>Alex S</name>
<email>iwtcex@gmail.com</email>
</author>
<published>2025-03-10T18:12:36+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=186dc094cf1ce14b26c6dfa329a445357121238a'/>
<id>186dc094cf1ce14b26c6dfa329a445357121238a</id>
<content type='text'>
This unbreaks apps using GameNetworkingSockets from Valve.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This unbreaks apps using GameNetworkingSockets from Valve.
</pre>
</div>
</content>
</entry>
<entry>
<title>linux: Fix a typo in linux_recvmsg_common</title>
<updated>2025-03-10T18:12:36+00:00</updated>
<author>
<name>Alex S</name>
<email>iwtcex@gmail.com</email>
</author>
<published>2025-03-10T18:12:36+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=9f55630b8d72602f6ec86b15b607f5fc5fde911e'/>
<id>9f55630b8d72602f6ec86b15b607f5fc5fde911e</id>
<content type='text'>
We are supposed to check the result of bsd_to_linux_sockopt_level here
rather than its input.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We are supposed to check the result of bsd_to_linux_sockopt_level here
rather than its input.
</pre>
</div>
</content>
</entry>
<entry>
<title>linux sendfile: Fix handling of non-blocking sockets</title>
<updated>2024-11-13T14:15:47+00:00</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2024-11-13T14:15:47+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=a43b745aaf4f5bbc96875d2ab3ec9bea8024eda4'/>
<id>a43b745aaf4f5bbc96875d2ab3ec9bea8024eda4</id>
<content type='text'>
FreeBSD sendfile() may perform a partial transfer and return EAGAIN if
the socket is non-blocking.  Linux sendfile() expects no error in this
case, so squash EAGAIN.

PR:		282495
Tested by:	pieter@krikkit.xyz
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47447
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
FreeBSD sendfile() may perform a partial transfer and return EAGAIN if
the socket is non-blocking.  Linux sendfile() expects no error in this
case, so squash EAGAIN.

PR:		282495
Tested by:	pieter@krikkit.xyz
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47447
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix new users of MAXPHYS and hide it from the kernel namespace</title>
<updated>2024-04-30T19:29:06+00:00</updated>
<author>
<name>Andrew Gallatin</name>
<email>gallatin@FreeBSD.org</email>
</author>
<published>2024-04-29T23:11:56+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=13a5a46c49d0ec3e10e5476ad763947f165052e2'/>
<id>13a5a46c49d0ec3e10e5476ad763947f165052e2</id>
<content type='text'>
In cd8537910406, kib made maxphys a load-time tunable.  This made
the #define MAXPHYS in sys/param.h  almost entirely obsolete, as
it could now be overridden by kern.maxphys at boot time, or by
opt_maxphys.h.

However, decades of tradition have led to several new, incorrect, uses
of MAXPHYS in other parts of the kernel, mostly by seasoned
developers.  I've corrected those uses here in a mechanical fashion,
and verified that it fixes a bug in the md driver that I was
experiencing.

Since using MAXPHYS is such an easy mistake to make, it is best to
hide it from the kernel namespace.  So I've moved its definition to
_maxphys.h, which is now included in param.h only for userspace.

That brings up the fact that lots of userspace programs use MAXPHYS
for different reasons, most of them probably wrong.  Userspace consumers
that really need to know the value of maxphys should probably be
changed to use the kern.maxphys sysctl.  But that's outside the scope
of this change.

Reviewed by: imp, jkim, kib, markj
Fixes: 30038a8b4efc ("md: Get rid of the pbuf zone")
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44986
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In cd8537910406, kib made maxphys a load-time tunable.  This made
the #define MAXPHYS in sys/param.h  almost entirely obsolete, as
it could now be overridden by kern.maxphys at boot time, or by
opt_maxphys.h.

However, decades of tradition have led to several new, incorrect, uses
of MAXPHYS in other parts of the kernel, mostly by seasoned
developers.  I've corrected those uses here in a mechanical fashion,
and verified that it fixes a bug in the md driver that I was
experiencing.

Since using MAXPHYS is such an easy mistake to make, it is best to
hide it from the kernel namespace.  So I've moved its definition to
_maxphys.h, which is now included in param.h only for userspace.

That brings up the fact that lots of userspace programs use MAXPHYS
for different reasons, most of them probably wrong.  Userspace consumers
that really need to know the value of maxphys should probably be
changed to use the kern.maxphys sysctl.  But that's outside the scope
of this change.

Reviewed by: imp, jkim, kib, markj
Fixes: 30038a8b4efc ("md: Get rid of the pbuf zone")
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44986
</pre>
</div>
</content>
</entry>
<entry>
<title>linux: ignore setsockopt(IPV6_RECVERR)</title>
<updated>2024-04-23T04:36:34+00:00</updated>
<author>
<name>Lexi Winter</name>
<email>lexi@le-Fay.ORG</email>
</author>
<published>2024-04-22T21:58:11+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=ca63710d3668cf6f3cb4faf065d8b4eeffa028ad'/>
<id>ca63710d3668cf6f3cb4faf065d8b4eeffa028ad</id>
<content type='text'>
Under Linux, the socket options IP_RECVERR and IPV6_RECVERR are used to
receive socket errors via a dedicated 'error queue' which can be
retrieved via recvmsg().  FreeBSD does not support this functionality.

For IPv4, the sysctl compat.linux.ignore_ip_recverr can be set to 1 to
silently ignore attempts to set IP_RECVERR and return success to the
application, which is wrong, but is required for (among other things)
a functional DNS client in recent versions of glibc.

Add support for ignoring IPV6_RECVERR, controlled by the same sysctl.
This fixes DNS in Linux when using IPv6 resolvers.

Reviewed by: imp, Jose Luis Duran
Pull Request: https://github.com/freebsd/freebsd-src/pull/1118
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Under Linux, the socket options IP_RECVERR and IPV6_RECVERR are used to
receive socket errors via a dedicated 'error queue' which can be
retrieved via recvmsg().  FreeBSD does not support this functionality.

For IPv4, the sysctl compat.linux.ignore_ip_recverr can be set to 1 to
silently ignore attempts to set IP_RECVERR and return success to the
application, which is wrong, but is required for (among other things)
a functional DNS client in recent versions of glibc.

Add support for ignoring IPV6_RECVERR, controlled by the same sysctl.
This fixes DNS in Linux when using IPv6 resolvers.

Reviewed by: imp, Jose Luis Duran
Pull Request: https://github.com/freebsd/freebsd-src/pull/1118
</pre>
</div>
</content>
</entry>
<entry>
<title>linux: use sa_family_t for address family conversions</title>
<updated>2024-03-29T20:35:37+00:00</updated>
<author>
<name>Gleb Smirnoff</name>
<email>glebius@FreeBSD.org</email>
</author>
<published>2024-03-29T20:35:37+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=9d4a08d162d87ba120f418a1a71facd2c631b549'/>
<id>9d4a08d162d87ba120f418a1a71facd2c631b549</id>
<content type='text'>
Express "conversion failed" with maximum possible value.  This allows to
reduce number of size/signedness conversion in the code that utilizes the
functions.

PR:			274536
Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D44375
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Express "conversion failed" with maximum possible value.  This allows to
reduce number of size/signedness conversion in the code that utilizes the
functions.

PR:			274536
Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D44375
</pre>
</div>
</content>
</entry>
<entry>
<title>linux/netlink: don't override sopt level</title>
<updated>2023-12-27T04:21:58+00:00</updated>
<author>
<name>Gleb Smirnoff</name>
<email>glebius@FreeBSD.org</email>
</author>
<published>2023-12-27T04:21:58+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=f27aff8f7f4f7628a652602e55409f7e858d7f56'/>
<id>f27aff8f7f4f7628a652602e55409f7e858d7f56</id>
<content type='text'>
This override effectively prevents correct entering of netlink
protocol specific pr_ctloutput in sosetopt().

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D42520
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This override effectively prevents correct entering of netlink
protocol specific pr_ctloutput in sosetopt().

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D42520
</pre>
</div>
</content>
</entry>
<entry>
<title>sockets: don't malloc/free sockaddr memory on getpeername/getsockname</title>
<updated>2023-11-30T16:31:10+00:00</updated>
<author>
<name>Gleb Smirnoff</name>
<email>glebius@FreeBSD.org</email>
</author>
<published>2023-11-30T16:30:55+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=0fac350c54d0a72f5341e15021efcde63eb58a4b'/>
<id>0fac350c54d0a72f5341e15021efcde63eb58a4b</id>
<content type='text'>
Just like it was done for accept(2) in cfb1e92912b4, use same approach
for two simplier syscalls that return socket addresses.  Although,
these two syscalls aren't performance critical, this change generalizes
some code between 3 syscalls trimming code size.

Following example of accept(2), provide VNET-aware and INVARIANT-checking
wrappers sopeeraddr() and sosockaddr() around protosw methods.

Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D42694
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Just like it was done for accept(2) in cfb1e92912b4, use same approach
for two simplier syscalls that return socket addresses.  Although,
these two syscalls aren't performance critical, this change generalizes
some code between 3 syscalls trimming code size.

Following example of accept(2), provide VNET-aware and INVARIANT-checking
wrappers sopeeraddr() and sosockaddr() around protosw methods.

Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D42694
</pre>
</div>
</content>
</entry>
<entry>
<title>sockets: don't malloc/free sockaddr memory on accept(2)</title>
<updated>2023-11-30T16:30:55+00:00</updated>
<author>
<name>Gleb Smirnoff</name>
<email>glebius@FreeBSD.org</email>
</author>
<published>2023-11-30T16:30:55+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=cfb1e92912b4cf75360b7fbe86197cc29bc212c1'/>
<id>cfb1e92912b4cf75360b7fbe86197cc29bc212c1</id>
<content type='text'>
Let the accept functions provide stack memory for protocols to fill it in.
Generic code should provide sockaddr_storage, specialized code may provide
smaller structure.

While rewriting accept(2) make 'addrlen' a true in/out parameter, reporting
required length in case if provided length was insufficient.  Our manual
page accept(2) and POSIX don't explicitly require that, but one can read
the text as they do.  Linux also does that. Update tests accordingly.

Reviewed by:		rscheff, tuexen, zlei, dchagin
Differential Revision:	https://reviews.freebsd.org/D42635
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Let the accept functions provide stack memory for protocols to fill it in.
Generic code should provide sockaddr_storage, specialized code may provide
smaller structure.

While rewriting accept(2) make 'addrlen' a true in/out parameter, reporting
required length in case if provided length was insufficient.  Our manual
page accept(2) and POSIX don't explicitly require that, but one can read
the text as they do.  Linux also does that. Update tests accordingly.

Reviewed by:		rscheff, tuexen, zlei, dchagin
Differential Revision:	https://reviews.freebsd.org/D42635
</pre>
</div>
</content>
</entry>
</feed>
