Commit ec7b60b0 authored by Matt Layher's avatar Matt Layher

unix: add SetsockoptSockFprog on Linux for attaching BPF filters

Adding this helper enables me to eliminate some nasty code which
invokes unix.Syscall6 directly, and which has 32-bit shims for
invoking setsockopt properly on 32-bit Linux.

Change-Id: I53ef411e4c96cef557999261760cddc00df58d8a
Reviewed-on: https://go-review.googlesource.com/c/163303
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarTobias Klauser <tobias.klauser@gmail.com>
parent b4e8571b
......@@ -994,6 +994,12 @@ func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
}
// SetsockoptSockFprog attaches a classic BPF or an extended BPF program to a
// socket to filter incoming packets. See 'man 7 socket' for usage information.
func SetsockoptSockFprog(fd, level, opt int, fprog *SockFprog) error {
return setsockopt(fd, level, opt, unsafe.Pointer(fprog), unsafe.Sizeof(*fprog))
}
// Keyctl Commands (http://man7.org/linux/man-pages/man2/keyctl.2.html)
// KeyctlInt calls keyctl commands in which each argument is an int.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment