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

elf: Make build compatible with RHEL7 #305

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anujsrv
Copy link

@anujsrv anujsrv commented Nov 21, 2021

Defining SO_ATTACH_BPF and SO_DETACH_BPF to fix go build and go install on RHEL7 OS.
For reference: Kernel version on RHEL7 is 3.10.x with eBPF capabilities
backported. (https://access.redhat.com/articles/3078 &
https://www.redhat.com/en/blog/introduction-ebpf-red-hat-enterprise-linux-7)

But SO_ATTACH_BPF and SO_DETACH_BPF capabilities were added since kernel
version 3.19 onwards.

Without these changes, this is the error I get on my RHEL7 machine (with 3.10.0-1160 kernel) -

$ git branch -l
* master
  socket_compat
$ go build -a ./elf/
# github.com/iovisor/gobpf/elf
elf/module.go: In function 'bpf_attach_socket':
elf/module.go:96:38: error: 'SO_ATTACH_BPF' undeclared (first use in this function)
  return setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &fd, sizeof(fd));
                                      ^
elf/module.go:96:38: note: each undeclared identifier is reported only once for each function it appears in
elf/module.go: In function 'bpf_detach_socket':
elf/module.go:101:38: error: 'SO_DETACH_BPF' undeclared (first use in this function)
  return setsockopt(sock, SOL_SOCKET, SO_DETACH_BPF, &fd, sizeof(fd));

Define SO_ATTACH_BPF and SO_DETACH_BPF to fix go build and go install
for gobpf on RHEL7 OS.
For reference: Kernel version on RHEL7 is 3.10.x with eBPF capabilities
backported. (https://access.redhat.com/articles/3078 &
https://www.redhat.com/en/blog/introduction-ebpf-red-hat-enterprise-linux-7)

But SO_ATTACH_BPF and SO_DETACH_BPF capabilites were added since kernel
version 3.19 onwards.
@anujsrv anujsrv changed the title Make build compatible with RHEL7 elf: Make build compatible with RHEL7 Nov 21, 2021
@anujsrv
Copy link
Author

anujsrv commented Nov 22, 2021

@schu Can you have a look at this? Appreciate it.

@fanfanbj
Copy link

fanfanbj commented Jun 9, 2023

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants