This was broken in commit 64268c8, which moved parsing of addresses for
AF_UNIX sockets to the socket/unix package.
While we're here, add strace support for AF_PACKET sockets, since
socket.AddressAndFamily can already decode their address.
PiperOrigin-RevId: 661391690
This allows for external information to be passed to restore code.
Similar to c087777e37 ("Plumb restore context to afterLoad()").
Updates #1956.
PiperOrigin-RevId: 614125262
The documentation for EPOLLET (which repeatedly instructs users to read/write
until EAGAIN or short read) suggests that its intent is to only cause an epoll
notification when an FD registered with EPOLLET transitions from not-readable
to readable, or not-writable to writable. In practice, however, the actual
implementation for at least Unix domain sockets will trigger an epoll
notification on *every* send (cf. `net/unix/af_unix.c:unix_stream_sendmsg()` =>
"`other->sk_data_ready(other)`" => `net/core/sock.c:sock_def_readable()`), and
nginx (which registers Unix domain sockets with EPOLLET and - apparently
incorrectly - does *not* read from them until EAGAIN or short read) depends on
this property.
PiperOrigin-RevId: 601911295
...they were getting out of control.
The two interface methods now take the same RecvArgs inputs, and return
RecvOutput.
I left `data [][]byte` as an explicit argument since it's technically an
argument (passed into Recv method), but acts like an output in that data is
written to it.
PiperOrigin-RevId: 578625002
This Recv method is called with mm.activeRWMutex in mm.CopyOutFrom, which can
lead to lock order violatations because Release()ing a RightsControlMessage can
trigger filesystem operations (like inotify) which may need filesystem locks.
Instead, we plumb these "unusedRights" messages allll the way up to the
EndpointReader, where they can be safely released outside of mm.activeRWMutex.
PiperOrigin-RevId: 578584323
SO_ACCEPTCONN returns true for TCP sockets which are in a listening state.
Added this socket option support for unix sockets.
PiperOrigin-RevId: 577008617
It is an idea of running codespell as part of our presubmit checks.
Before enabling it for new changes, let's fix what it has found.
Signed-off-by: Andrei Vagin <avagin@gmail.com>
If a bind call specifies addrlen as sizeof(sa_family_t) ,then the socket
is auto-bound to an abstract address. The address consists of a null byte
followed by 5 bytes in the character set [0-9a-f].
PiperOrigin-RevId: 572810162
This change introduces the nsfs file system. Each new namespace allocates
a new nsfs inode.
Here are reasons why we need these inodes:
* each namespace has to have an unique id.
* proc/pid/ns/ contains one entry for each namespace. Bind mounting one of
the files in this directory to somewhere else in the filesystem keeps the
corresponding namespace alive even if all processes currently in
the namespace terminate.
* setns() allows the calling process to join an existing namespace specified
by a file descriptor.
PiperOrigin-RevId: 550694515
The important change here is in tcpip/tcpip.go, where tcpip.Address is defined.
The rest is updating uses of tcpip.Address.
This is preparation for netip.Addr or []byte based addresses, which should save
us a bunch of allocations. Currently, we allocate every time we want to, say,
get a tcpip.Address from a header. This is because the header is a byte slice,
but Address is a string. Strings are immutable, so Go allocates and copies.
PiperOrigin-RevId: 532284732
This catches up the interface to the `EmitUnimplementedEvent` method signature
on `kernel.Kernel`.
Also add build-time test to verify that `kernel.Kernel` implements this
interface, in order to catch such breakages at build time in the future.
PiperOrigin-RevId: 519000411
Earlier SetBoundSocketFD() was taking ownership of bound socket FD only on
success. Having it take ownership unconditionally is cleaner.
PiperOrigin-RevId: 516903597