Files
moby/libnetwork/drivers/bridge/port_mapping_linux_386.go
Albin Kerouanton 73f2a5336d libnet/d/bridge: fix compilation on i386
On i386, Linux doesn't provide direct socket syscall but instead
multiplexes them through the socketcall syscall (see `man 2 socketcall`).
This commit fixes compilation for i386 by wrapping the offending syscall
in a new function that uses the socketcall syscall on i386, and
the `setsockopt` syscall on other archs.

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

22 lines
561 B
Go

package bridge
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
}