mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-05-20 17:28:40 +00:00
57dc742c76
Bumps [github.com/KimMachineGun/automemlimit](https://github.com/KimMachineGun/automemlimit) from 0.2.4 to 0.2.5. - [Release notes](https://github.com/KimMachineGun/automemlimit/releases) - [Commits](https://github.com/KimMachineGun/automemlimit/compare/v0.2.4...v0.2.5) --- updated-dependencies: - dependency-name: github.com/KimMachineGun/automemlimit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
41 lines
921 B
Go
41 lines
921 B
Go
package link
|
|
|
|
import (
|
|
"syscall"
|
|
|
|
"github.com/cilium/ebpf"
|
|
"github.com/cilium/ebpf/internal/unix"
|
|
)
|
|
|
|
// AttachSocketFilter attaches a SocketFilter BPF program to a socket.
|
|
func AttachSocketFilter(conn syscall.Conn, program *ebpf.Program) error {
|
|
rawConn, err := conn.SyscallConn()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var ssoErr error
|
|
err = rawConn.Control(func(fd uintptr) {
|
|
ssoErr = syscall.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_ATTACH_BPF, program.FD())
|
|
})
|
|
if ssoErr != nil {
|
|
return ssoErr
|
|
}
|
|
return err
|
|
}
|
|
|
|
// DetachSocketFilter detaches a SocketFilter BPF program from a socket.
|
|
func DetachSocketFilter(conn syscall.Conn) error {
|
|
rawConn, err := conn.SyscallConn()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var ssoErr error
|
|
err = rawConn.Control(func(fd uintptr) {
|
|
ssoErr = syscall.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_DETACH_BPF, 0)
|
|
})
|
|
if ssoErr != nil {
|
|
return ssoErr
|
|
}
|
|
return err
|
|
}
|