Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syscall: missing SYS_GETSOCKOPT in zsysnum_linux_386.go #19043

Closed
riobard opened this issue Feb 12, 2017 · 4 comments
Closed

syscall: missing SYS_GETSOCKOPT in zsysnum_linux_386.go #19043

riobard opened this issue Feb 12, 2017 · 4 comments

Comments

@riobard
Copy link

riobard commented Feb 12, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.7.5

What operating system and processor architecture are you using (go env)?

Darwin/amd64

What did you do?

If possible, provide a recipe for reproducing the error.

GOOS=linux GOARCH=386 go doc syscall.SYS_GETSOCKOPT

What did you expect to see?

List of defined constants containing SYS_GETSOCKOPT.

What did you see instead?

doc: no symbol SYS_GETSOCKOPT in package syscall
@minux
Copy link
Member

minux commented Feb 12, 2017 via email

@minux minux closed this as completed Feb 12, 2017
@riobard
Copy link
Author

riobard commented Feb 12, 2017

Thanks a lot for the explanation. In that case, how to implement Getsockopt* for structs not implemented in syscall or unix? The following code works on linux_amd64. I'd like to know a way to do that on linux_386 as well.

// Call getorigdst() from linux/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
func getorigdst(fd uintptr) (*syscall.RawSockaddrInet4, error) {
	const SO_ORIGINAL_DST = 80 // from linux/include/uapi/linux/netfilter_ipv4.h
	raw := syscall.RawSockaddrInet4{}
	siz := unsafe.Sizeof(raw)
	if _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, fd, syscall.IPPROTO_IP, SO_ORIGINAL_DST, uintptr(unsafe.Pointer(&raw)), uintptr(unsafe.Pointer(&siz)), 0); errno != 0 {
		return nil, errno
	}
	return raw, nil
}

@ianlancetaylor
Copy link
Contributor

ianlancetaylor commented Feb 13, 2017

Questions are best directed to a forum, rather than the issue tracker; see https://golang.org/wiki/Questions.

On 386 GNU/Linux you'll need to call something along the lines of Syscall6(syscall.SYS_SOCKETCALL, 15, /* setsockopt arguments */).

@riobard
Copy link
Author

riobard commented Feb 13, 2017

Thanks a lot for the pointer! :)

@golang golang locked and limited conversation to collaborators Feb 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants