Hi,
When I run the below command in the /p4c/extensions/p4c-xdp/tests :
# gcc -I ../lib/ ../lib/libbpf.o user_xdp5.c -o xdp5
there's an error that
In file included from xdp5.h:6:0,
from user_xdp5.c:20:
ebpf_xdp.h:24:25: fatal error: ebpf_kernel.h: No such file or directory
#include "ebpf_kernel.h"
^
compilation terminated.
And then I found the header files to be included are in the /p4c/backends/ebpf/runtime/,
so I move the ebpf_kernel.h and ebpf_common.h into the /tests :
root@debian:~/p4c/extensions/p4c-xdp/tests# cp /root/p4c/backends/ebpf/runtime/ebpf_common.h ./
root@debian:~/p4c/extensions/p4c-xdp/tests# cp /root/p4c/backends/ebpf/runtime/ebpf_kernel.h ./
however, when I compile again , some other errors occured :
In file included from ebpf_xdp.h:24:0,
from xdp5.h:6,
from user_xdp5.c:20:
ebpf_kernel.h:111:19: error: static declaration of ‘bpf_lookup_elem’ follows non-static declaration
static inline int bpf_lookup_elem(int fd, void *key, void *value) {
^~~~~~~~~~~~~~~
In file included from user_xdp5.c:17:0:
../lib/libbpf.h:10:5: note: previous declaration of ‘bpf_lookup_elem’ was here
int bpf_lookup_elem(int fd, void *key, void *value);
^~~~~~~~~~~~~~~
In file included from ebpf_xdp.h:24:0,
from xdp5.h:6,
from user_xdp5.c:20:
ebpf_kernel.h:131:19: error: static declaration of ‘bpf_update_elem’ follows non-static declaration
static inline int bpf_update_elem(int fd, void *key, void *value, u64 flags) {
^~~~~~~~~~~~~~~
In file included from user_xdp5.c:17:0:
../lib/libbpf.h:9:5: note: previous declaration of ‘bpf_update_elem’ was here
int bpf_update_elem(int fd, void *key, void *value, unsigned long long flags);
^~~~~~~~~~~~~~~
In file included from ebpf_xdp.h:24:0,
from xdp5.h:6,
from user_xdp5.c:20:
ebpf_kernel.h:149:19: error: static declaration of ‘bpf_delete_elem’ follows non-static declaration
static inline int bpf_delete_elem(int fd, void *key) {
^~~~~~~~~~~~~~~
In file included from user_xdp5.c:17:0:
../lib/libbpf.h:11:5: note: previous declaration of ‘bpf_delete_elem’ was here
int bpf_delete_elem(int fd, void *key);
^~~~~~~~~~~~~~~
In file included from ebpf_xdp.h:24:0,
from xdp5.h:6,
from user_xdp5.c:20:
ebpf_kernel.h:165:19: error: static declaration of ‘bpf_obj_pin’ follows non-static declaration
static inline int bpf_obj_pin(int fd, const char *pathname) {
^~~~~~~~~~~
In file included from user_xdp5.c:17:0:
../lib/libbpf.h:18:5: note: previous declaration of ‘bpf_obj_pin’ was here
int bpf_obj_pin(int fd, const char *pathname);
^~~~~~~~~~~
In file included from ebpf_xdp.h:24:0,
from xdp5.h:6,
from user_xdp5.c:20:
ebpf_kernel.h:181:19: error: static declaration of ‘bpf_obj_get’ follows non-static declaration
static inline int bpf_obj_get(const char *pathname) {
^~~~~~~~~~~
In file included from user_xdp5.c:17:0:
../lib/libbpf.h:19:5: note: previous declaration of ‘bpf_obj_get’ was here
int bpf_obj_get(const char *pathname);
^~~~~~~~~~~
user_xdp5.c: In function ‘main’:
user_xdp5.c:29:25: error: storage size of ‘key’ isn’t known
struct dstmactable_key key;
^~~
user_xdp5.c:30:27: error: storage size of ‘value’ isn’t known
struct dstmactable_value value;
^~~~~
user_xdp5.c:33:2: warning: implicit declaration of function ‘initialize_tables’ [-Wimplicit-function-declaration]
initialize_tables();
^~~~~~~~~~~~~~~~~
user_xdp5.c:35:17: error: ‘Fallback_action’ undeclared (first use in this function)
value.action = Fallback_action;
^~~~~~~~~~~~~~~
user_xdp5.c:35:17: note: each undeclared identifier is reported only once for each function it appears in
could you give me some advice?
Thanks.
Hi,
When I run the below command in the /p4c/extensions/p4c-xdp/tests :
# gcc -I ../lib/ ../lib/libbpf.o user_xdp5.c -o xdp5there's an error that
In file included from xdp5.h:6:0, from user_xdp5.c:20: ebpf_xdp.h:24:25: fatal error: ebpf_kernel.h: No such file or directory #include "ebpf_kernel.h" ^ compilation terminated.And then I found the header files to be included are in the /p4c/backends/ebpf/runtime/,
so I move the ebpf_kernel.h and ebpf_common.h into the /tests :
however, when I compile again , some other errors occured :
In file included from ebpf_xdp.h:24:0, from xdp5.h:6, from user_xdp5.c:20: ebpf_kernel.h:111:19: error: static declaration of ‘bpf_lookup_elem’ follows non-static declaration static inline int bpf_lookup_elem(int fd, void *key, void *value) { ^~~~~~~~~~~~~~~ In file included from user_xdp5.c:17:0: ../lib/libbpf.h:10:5: note: previous declaration of ‘bpf_lookup_elem’ was here int bpf_lookup_elem(int fd, void *key, void *value); ^~~~~~~~~~~~~~~ In file included from ebpf_xdp.h:24:0, from xdp5.h:6, from user_xdp5.c:20: ebpf_kernel.h:131:19: error: static declaration of ‘bpf_update_elem’ follows non-static declaration static inline int bpf_update_elem(int fd, void *key, void *value, u64 flags) { ^~~~~~~~~~~~~~~ In file included from user_xdp5.c:17:0: ../lib/libbpf.h:9:5: note: previous declaration of ‘bpf_update_elem’ was here int bpf_update_elem(int fd, void *key, void *value, unsigned long long flags); ^~~~~~~~~~~~~~~ In file included from ebpf_xdp.h:24:0, from xdp5.h:6, from user_xdp5.c:20: ebpf_kernel.h:149:19: error: static declaration of ‘bpf_delete_elem’ follows non-static declaration static inline int bpf_delete_elem(int fd, void *key) { ^~~~~~~~~~~~~~~ In file included from user_xdp5.c:17:0: ../lib/libbpf.h:11:5: note: previous declaration of ‘bpf_delete_elem’ was here int bpf_delete_elem(int fd, void *key); ^~~~~~~~~~~~~~~ In file included from ebpf_xdp.h:24:0, from xdp5.h:6, from user_xdp5.c:20: ebpf_kernel.h:165:19: error: static declaration of ‘bpf_obj_pin’ follows non-static declaration static inline int bpf_obj_pin(int fd, const char *pathname) { ^~~~~~~~~~~ In file included from user_xdp5.c:17:0: ../lib/libbpf.h:18:5: note: previous declaration of ‘bpf_obj_pin’ was here int bpf_obj_pin(int fd, const char *pathname); ^~~~~~~~~~~ In file included from ebpf_xdp.h:24:0, from xdp5.h:6, from user_xdp5.c:20: ebpf_kernel.h:181:19: error: static declaration of ‘bpf_obj_get’ follows non-static declaration static inline int bpf_obj_get(const char *pathname) { ^~~~~~~~~~~ In file included from user_xdp5.c:17:0: ../lib/libbpf.h:19:5: note: previous declaration of ‘bpf_obj_get’ was here int bpf_obj_get(const char *pathname); ^~~~~~~~~~~ user_xdp5.c: In function ‘main’: user_xdp5.c:29:25: error: storage size of ‘key’ isn’t known struct dstmactable_key key; ^~~ user_xdp5.c:30:27: error: storage size of ‘value’ isn’t known struct dstmactable_value value; ^~~~~ user_xdp5.c:33:2: warning: implicit declaration of function ‘initialize_tables’ [-Wimplicit-function-declaration] initialize_tables(); ^~~~~~~~~~~~~~~~~ user_xdp5.c:35:17: error: ‘Fallback_action’ undeclared (first use in this function) value.action = Fallback_action; ^~~~~~~~~~~~~~~ user_xdp5.c:35:17: note: each undeclared identifier is reported only once for each function it appears incould you give me some advice?
Thanks.