diff --git a/felix/bpf-gpl/Makefile b/felix/bpf-gpl/Makefile index 7161d59e8d7..4c107ede28b 100644 --- a/felix/bpf-gpl/Makefile +++ b/felix/bpf-gpl/Makefile @@ -69,7 +69,7 @@ all: $(OBJS) ut-objs: $(UT_OBJS) libbpf: $(LIBBPF_FILE_CREATED) -$(LIBBPF_FILE_CREATED): +$(LIBBPF_FILE_CREATED): ifeq ("$(wildcard ./$(LIBBPF_DIR))", "") $(info "Directory does not exist.") @echo "Directory does not exist." @@ -83,18 +83,6 @@ endif COMPILE=$(CC) $(CFLAGS) `./calculate-flags $@` -c $< -o $@ -conntrack_cleanup_%v4.ll: conntrack_cleanup.c conntrack_cleanup.d calculate-flags - $(COMPILE) -conntrack_cleanup_%v6.ll: conntrack_cleanup.c conntrack_cleanup.d calculate-flags - $(COMPILE) - -connect_time_%v4.ll: connect_balancer.c connect_balancer.d calculate-flags - $(COMPILE) -connect_time_%v46.ll: connect_balancer_v46.c connect_balancer_v46.d calculate-flags - $(COMPILE) -connect_time_%v6.ll: connect_balancer_v6.c connect_balancer_v6.d calculate-flags - $(COMPILE) -DIPVER6 - UT_CFLAGS=\ -D__BPFTOOL_LOADER__ \ -DCALI_LOG_LEVEL=CALI_LOG_LEVEL_DEBUG \ @@ -119,27 +107,33 @@ policy_default.ll: policy_default.c policy_default.d # Production and UT versions of the main binaries. # Combining the targets into one rule causes make to fail to rebuild the .ll files. Not sure why. +to%_v6.ll: tc.c tc_v6.d calculate-flags + $(COMPILE) to%.ll: tc.c tc.d calculate-flags $(COMPILE) from%.ll: tc.c tc.d calculate-flags $(COMPILE) -to%_v6.ll: tc.c tc.d calculate-flags - $(COMPILE) -from%_v6.ll: tc.c tc.d calculate-flags +from%_v6.ll: tc.c tc_v6.d calculate-flags $(COMPILE) test%.ll: tc.c tc.d calculate-flags $(COMPILE) -test%_v6.ll: tc.c tc.d calculate-flags +test%_v6.ll: tc.c tc_v6.d calculate-flags $(COMPILE) xdp%.ll: xdp.c xdp.d calculate-flags $(COMPILE) -xdp%_v6.ll: xdp.c xdp.d calculate-flags +xdp%_v6.ll: xdp.c xdp_v6.d calculate-flags $(COMPILE) test_xdp%.ll: xdp.c xdp.d calculate-flags $(COMPILE) -test_xdp%_v6.ll: xdp.c xdp.d calculate-flags +test_xdp%_v6.ll: xdp.c xdp_v6.d calculate-flags $(COMPILE) +tc_v6.d: tc.c + $(COMPILE_DEPS) +xdp_v6.d: xdp.c + $(COMPILE_DEPS) + + LINK=$(LD) -march=bpf -filetype=obj -o $@ $< bin/tc_preamble.o: tc_preamble.ll | bin $(LINK) @@ -155,22 +149,7 @@ bin/test%.o: test%.ll | bin $(LINK) bin/xdp%.o: xdp%.ll | bin $(LINK) -bin/conntrack_cleanup_%v4.o: conntrack_cleanup_%v4.ll | bin - $(LINK) -bin/conntrack_cleanup_%v6.o: conntrack_cleanup_%v6.ll | bin - $(LINK) -bin/connect_time_%v4.o: connect_time_%v4.ll | bin - $(LINK) -bin/connect_time_%v46.o: connect_time_%v46.ll | bin - $(LINK) -bin/connect_time_%v6.o: connect_time_%v6.ll | bin - $(LINK) -bin/connect_time_%v4_co-re.o: connect_time_%v4.ll | bin - $(LINK) -bin/connect_time_%v46_co-re.o: connect_time_%v46.ll | bin - $(LINK) -bin/connect_time_%v6_co-re.o: connect_time_%v6.ll | bin - $(LINK) + ut/%.o: ut/%.ll $(LINK) ut/ip_parse_test_v6.ll: ut/ip_parse_test.c @@ -178,22 +157,90 @@ ut/ip_parse_test_v6.ll: ut/ip_parse_test.c ut/ip_parse_test_v6.o: ut/ip_parse_test_v6.ll $(LINK) +%_v4.ll: %.c %.d calculate-flags + $(COMPILE) +%_no_log_v4.ll: %.c %.d calculate-flags + $(COMPILE) +%_debug_v4.ll: %.c %.d calculate-flags + $(COMPILE) +%_no_log_co-re_v4.ll: %.c %.d calculate-flags + $(COMPILE) +%_debug_co-re_v4.ll: %.c %.d calculate-flags + $(COMPILE) + +%_v4.ll: %_v4.c %_v4.d calculate-flags + $(COMPILE) +%_no_log_v4.ll: %_v4.c %_v4.d calculate-flags + $(COMPILE) +%_debug_v4.ll: %_v4.c %_v4.d calculate-flags + $(COMPILE) +%_no_log_co-re_v4.ll: %_v4.c %_v4.d calculate-flags + $(COMPILE) +%_debug_co-re_v4.ll: %_v4.c %_v4.d calculate-flags + $(COMPILE) + +%_v46.ll: %_v46.c %_v46.d calculate-flags + $(COMPILE) +%_no_log_v46.ll: %_v46.c %_v46.d calculate-flags + $(COMPILE) +%_debug_v46.ll: %_v46.c %_v46.d calculate-flags + $(COMPILE) +%_no_log_co-re_v46.ll: %_v46.c %_v46.d calculate-flags + $(COMPILE) +%_debug_co-re_v46.ll: %_v46.c %_v46.d calculate-flags + $(COMPILE) + +%_v6.ll: %_v6.c %_v6.d calculate-flags + $(COMPILE) +%_no_log_v6.ll: %_v6.c %_v6.d calculate-flags + $(COMPILE) +%_debug_v6.ll: %_v6.c %_v6.d calculate-flags + $(COMPILE) +%_no_log_co-re_v6.ll: %_v6.c %_v6.d calculate-flags + $(COMPILE) +%_debug_co-re_v6.ll: %_v6.c %_v6.d calculate-flags + $(COMPILE) + +%_v6.ll: %.c %_v6.d calculate-flags + $(COMPILE) +%_no_log_v6.ll: %.c %_v6.d calculate-flags + $(COMPILE) +%_debug_v6.ll: %.c %_v6.d calculate-flags + $(COMPILE) +%_no_log_co-re_v6.ll: %.c %_v6.d calculate-flags + $(COMPILE) +%_debug_co-re_v6.ll: %.c %_v6.d calculate-flags + $(COMPILE) + +bin/%_v4.o: %_v4.ll | bin + $(LINK) +bin/%_v46.o: %_v46.ll | bin + $(LINK) +bin/%_v6.o: %_v6.ll | bin + $(LINK) + bin: mkdir -p bin -.PRECIOUS: %.d - %.d: %.c - set -e; rm -f $@; \ + $(COMPILE_DEPS) +%_v6.d: CFLAGS+=-DIPVER6 +%_v6.d: %_v6.c + $(COMPILE_DEPS) +%_v6.d: %.c + $(COMPILE_DEPS) + + +.PRECIOUS: %.d %_v6.d + +COMPILE_DEPS=set -e; rm -f $@; \ $(CC) -M $(CFLAGS) $< > $@.$$$$ || { rm -f $@.$$$$; false; } ; \ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ -D_FILES=$(C_FILES:.c=.d) - ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS), libbpf) - include $(D_FILES) + include $(shell ls *.d) endif endif diff --git a/felix/bpf-gpl/connect_balancer.c b/felix/bpf-gpl/connect_balancer_v4.c similarity index 100% rename from felix/bpf-gpl/connect_balancer.c rename to felix/bpf-gpl/connect_balancer_v4.c diff --git a/felix/bpf-gpl/list-objs b/felix/bpf-gpl/list-objs index edaa16d123b..88db5df385e 100755 --- a/felix/bpf-gpl/list-objs +++ b/felix/bpf-gpl/list-objs @@ -22,12 +22,12 @@ emit_filename() { for log_level in debug no_log; do echo "bin/conntrack_cleanup_${log_level}_co-re_v4.o" echo "bin/conntrack_cleanup_${log_level}_co-re_v6.o" - echo "bin/connect_time_${log_level}_v4.o" - echo "bin/connect_time_${log_level}_v6.o" - echo "bin/connect_time_${log_level}_v46.o" - echo "bin/connect_time_${log_level}_v4_co-re.o" - echo "bin/connect_time_${log_level}_v46_co-re.o" - echo "bin/connect_time_${log_level}_v6_co-re.o" + echo "bin/connect_balancer_${log_level}_v4.o" + echo "bin/connect_balancer_${log_level}_v6.o" + echo "bin/connect_balancer_${log_level}_v46.o" + echo "bin/connect_balancer_${log_level}_co-re_v4.o" + echo "bin/connect_balancer_${log_level}_co-re_v46.o" + echo "bin/connect_balancer_${log_level}_co-re_v6.o" echo "bin/xdp_${log_level}.o" echo "bin/xdp_${log_level}_co-re_v6.o" diff --git a/felix/bpf/nat/connecttime.go b/felix/bpf/nat/connecttime.go index eafbf8efe36..a457f27c4f0 100644 --- a/felix/bpf/nat/connecttime.go +++ b/felix/bpf/nat/connecttime.go @@ -307,7 +307,7 @@ func ProgFileName(logLevel string, ipver string) string { btf = "_co-re" } - return fmt.Sprintf("connect_time_%s_v%s%s.o", logLevel, ipver, btf) + return fmt.Sprintf("connect_balancer_%s_v%s%s.o", logLevel, ipver, btf) } func ensureCgroupPath(cgroupv2 string) (string, error) {