Skip to content

proposal: x/sys/unix: add RawAccept4 #62655

@kolyshkin

Description

@kolyshkin

This is a proposal to add RawAccept4 function to x/sys/unix for Linux. The implementation may look like this:

func RawAccept4(fd int, rsa *RawSockaddrAny, addrlen *uint32, flags int) (int, error) {
	return accept4(fd, rsa, (*_Socklen)(addrlen), flags)
}

Background

I did a small change to (*SockaddrALG).sockaddr (CL 527836) and wasn't quite sure it doesn't break anything. So I wrote a test case for AF_ALG functionality (CL 527837) to make sure it's still working, but found out that it's not possible to use unix.Accept with AF_ALG socket, as it sets the second and the third accept4 syscall arguments to non-nil values, and with AF_ALG those needs to be set to nil.

Alternatives

  1. Use unix.SYSCALL(unix.ACCEPT4, ....
  2. Add AcceptWithoutAddr (https://go-review.googlesource.com/c/sys/+/527837/comment/4d5963aa_e794dbd3/). The implementation can look like this:
func AcceptWithoutAddr(fd int) (int, error) {
	return accept4(fd, 0, 0, 0)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions