aregm / nff-go

NFF-Go -Network Function Framework for GO (former YANFF)
BSD 3-Clause "New" or "Revised" License
1.38k stars 156 forks source link

make testing failure on XDP enable #656

Closed zartbot closed 4 years ago

zartbot commented 4 years ago
/tmp/go-build107101737/b063/_x002.o: In function `initXDP':
low.cgo2.c:(.text+0x7a09): undefined reference to `xsk_umem__create'
low.cgo2.c:(.text+0x7a5d): undefined reference to `xsk_socket__create'
low.cgo2.c:(.text+0x7a9e): undefined reference to `bpf_get_link_xdp_id'
/tmp/go-build107101737/b063/_x002.o: In function `removeXDP':
low.cgo2.c:(.text+0x7bb5): undefined reference to `xsk_socket__delete'
low.cgo2.c:(.text+0x7bc2): undefined reference to `xsk_umem__delete'
low.cgo2.c:(.text+0x7bd9): undefined reference to `bpf_get_link_xdp_id'
low.cgo2.c:(.text+0x7c1e): undefined reference to `bpf_set_link_xdp_fd'
/tmp/go-build107101737/b063/_x002.o: In function `sendXDP':
low.cgo2.c:(.text+0x8e22): undefined reference to `xsk_socket(float, double)'

after check with mk/include.mk it may overwrite the CGO_LDFLAGS and which does not include -lbpf

zartbot commented 4 years ago
diff --git a/mk/include.mk b/mk/include.mk
index 4516944..7e06612 100644
--- a/mk/include.mk
+++ b/mk/include.mk
@@ -73,8 +73,14 @@ export CGO_LDFLAGS =                         \
        -Wl,--no-as-needed                      \
        -Wl,-export-dynamic

+ifndef NFF_GO_NO_BPF_SUPPORT
+export CGO_LDFLAGS += -lbpf
+endif
+
gshimansky commented 4 years ago

Hi BPF library is specified in internal/low/low_bpf.go file https://github.com/intel-go/nff-go/blob/master/internal/low/low_bpf.go which is compiled when go build command is called with tags bpf. Did you build and install libbpf as specified in README.md file in AF_XDP support section?

zartbot commented 4 years ago

some test code under /test/stability/ like "testMerge" , "testCksum" does not include tags, so cause make testing failure.

gshimansky commented 4 years ago

You are right. I fixed test targets and I am going to promote this change to a new release 0.9.1.