Skip to content

Commit 7193230

Browse files
authored
Merge pull request #1474 from wxnzb/ut_cgroup_skb
feat: add cgroup_skb eBPF program
2 parents 098968a + 5e179d5 commit 7193230

File tree

5 files changed

+417
-6
lines changed

5 files changed

+417
-6
lines changed

pkg/bpf/factory/factory.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ package factory
1919
import "github.com/cilium/ebpf"
2020

2121
type GlobalBpfConfig struct {
22-
BpfLogLevel uint32
23-
NodeIP [16]byte
24-
PodGateway [16]byte
25-
AuthzOffload uint32
26-
EnableMonitoring uint32
22+
BpfLogLevel uint32
23+
NodeIP [16]byte
24+
PodGateway [16]byte
25+
AuthzOffload uint32
26+
EnableMonitoring uint32
27+
EnablePeriodicReport uint32
2728
}
2829

2930
type KmeshBpfConfig struct {

test/bpf_ut/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ all: xdp_shutdown_in_userspace_test.o \
3030
xdp_authz_offload_test.o \
3131
workload_sockops_test.o \
3232
tc_mark_encrypt_test.o \
33-
tc_mark_decrypt_test.o
33+
tc_mark_decrypt_test.o \
34+
workload_cgroup_skb_test.o
3435

3536

3637
XDP_FLAGS = -I$(ROOT_DIR)/bpf/kmesh/ -I$(ROOT_DIR)/bpf/kmesh/workload/include -I$(ROOT_DIR)/api/v2-c
@@ -47,6 +48,12 @@ tc_mark_encrypt_test.o: tc_mark_encrypt_test.c
4748
tc_mark_decrypt_test.o: tc_mark_decrypt_test.c
4849
$(QUIET) $(CLANG) $(CLANG_FLAGS) $(TC_FLAGS) -c $< -o $@
4950

51+
WORKLOAD_CGROUP_SKB_FLAGS = -I$(ROOT_DIR)/bpf/kmesh/ \
52+
-I$(ROOT_DIR)/bpf/kmesh/probes \
53+
-I$(ROOT_DIR)/bpf/kmesh/workload/include \
54+
-I$(ROOT_DIR)/api/v2-c
55+
workload_cgroup_skb_test.o: workload_cgroup_skb_test.c
56+
$(QUIET) $(CLANG) $(CLANG_FLAGS) $(WORKLOAD_CGROUP_SKB_FLAGS) -c $< -o $@
5057
clean:
5158
$(QUIET) rm -f $(wildcard *.o)
5259
$(QUIET) rm -f $(wildcard *.d)

test/bpf_ut/bpftest/bpf_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ func setBpfConfig(t *testing.T, coll *ebpf.Collection, config *factory.GlobalBpf
234234
t.Fatalf("failed to set authz_offload: %v", err)
235235
}
236236
}
237+
if v, ok := coll.Variables["enable_periodic_report"]; ok {
238+
if err := v.Set(&config.EnablePeriodicReport); err != nil {
239+
t.Fatalf("failed to set enable_periodic_report: %v", err)
240+
}
241+
}
237242
}
238243

239244
// registerTailCall registers a tail call in the eBPF collection by updating the specified

0 commit comments

Comments
 (0)