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

bpf: one cannot compile BPFs that include rte_mbuf_core.h #672

Open
AltraMayor opened this issue Jan 30, 2024 · 2 comments
Open

bpf: one cannot compile BPFs that include rte_mbuf_core.h #672

AltraMayor opened this issue Jan 30, 2024 · 2 comments
Labels
bug workaround available A temporary solution has been found

Comments

@AltraMayor
Copy link
Owner

A BPF needs to include the header <rte_mbuf_core.h> to access struct rte_mbuf. But the current version of the header <rte_mbuf_core.h> cannot be included in a BPF. This bug is present in the latest DPDK (i.e. 23.11) and a bug report has been filed.

Here's the error one gets while compiling the BPFs included with Gatekeeper:

~/gatekeeper/bpf$ make
clang -O2 -g -target bpf -I../include -Wall -Wextra -Wno-int-to-void-pointer-cast -o granted.bpf -c granted.c
In file included from granted.c:29:
In file included from /usr/local/include/rte_mbuf_core.h:21:
/usr/local/include/rte_byteorder.h:31:16: error: invalid output constraint '=Q' in asm
                      : [x1] "=Q" (x)
                             ^
1 error generated.
make: *** [Makefile:17: granted.bpf] Error 1
@AltraMayor AltraMayor added the bug label Jan 30, 2024
@AltraMayor AltraMayor added this to the Version 1.2 milestone Jan 30, 2024
@AltraMayor
Copy link
Owner Author

The following patch works around the bug while the problem is being fixed in DPDK:

diff --git a/bpf/Makefile b/bpf/Makefile
index d98f52b..c426214 100644
--- a/bpf/Makefile
+++ b/bpf/Makefile
@@ -14,7 +14,7 @@ copy: all
        $(INSTALL) -m660 $(TARGETS) $(DESTDIR)
 
 %.bpf: %.c
-       $(CC) $(CFLAGS) -o $@ -c $^
+       $(CC) $(CFLAGS) -o $@ -D RTE_FORCE_INTRINSICS -c $^
 
 PHONY: cscope clean

This workaround is based on Tyler Retzlaff's comment.

@AltraMayor AltraMayor added the workaround available A temporary solution has been found label Jan 30, 2024
AltraMayor added a commit that referenced this issue Mar 22, 2024
More information on issue #672
AltraMayor added a commit that referenced this issue Mar 22, 2024
More information on issue #672
@AltraMayor
Copy link
Owner Author

Pull request #680 has applied the workaround. We are going to wait for DPDK to fix the issue upstream before removing the workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug workaround available A temporary solution has been found
Projects
None yet
Development

No branches or pull requests

1 participant