Files
moby/daemon/libnetwork/portallocator/sctp_linux_386.go
Albin Kerouanton 50d2dafc7f libnet/portallocator: introduce OSAllocator
This new struct allocates ports from the operating system by creating
sockets and binding them. It's based on the existing bindTCPOrUDP and
bindSCTP functions previously defined in the bridge driver. It tries to
detect conflicts on best effort basis, and doesn't guarantee that the
ports it allocates are not in use by other processes.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-07-15 12:16:01 +02:00

22 lines
568 B
Go

package portallocator
import (
"syscall"
"unsafe"
"github.com/ishidawataru/sctp"
)
const sysSetsockopt = 14 // See https://elixir.bootlin.com/linux/v6.13.3/source/include/uapi/linux/net.h#L40
func setSCTPInitMsg(sd int, options sctp.InitMsg) syscall.Errno {
_, _, errno := syscall.Syscall6(syscall.SYS_SOCKETCALL, // See `man 2 socketcall`
sysSetsockopt,
uintptr(sd),
sctp.SOL_SCTP,
sctp.SCTP_INITMSG,
uintptr(unsafe.Pointer(&options)), // #nosec G103 -- Ignore "G103: Use of unsafe calls should be audited"
unsafe.Sizeof(options))
return errno
}