Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions features/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,47 @@ var haveMapTypeMatrix = internal.FeatureMatrix[ebpf.MapType]{
Version: "5.11",
Fn: func() error { return probeStorageMap(sys.BPF_MAP_TYPE_TASK_STORAGE) },
},
ebpf.BloomFilter: {
Version: "5.16",
Fn: func() error {
return createMap(&sys.MapCreateAttr{
MapType: sys.BPF_MAP_TYPE_BLOOM_FILTER,
KeySize: 0,
ValueSize: 4,
MaxEntries: 1,
})
},
},
ebpf.UserRingbuf: {
Version: "6.1",
Fn: func() error {
// keySize and valueSize need to be 0
// maxEntries needs to be power of 2 and PAGE_ALIGNED
return createMap(&sys.MapCreateAttr{
MapType: sys.BPF_MAP_TYPE_USER_RINGBUF,
KeySize: 0,
ValueSize: 0,
MaxEntries: uint32(os.Getpagesize()),
})
},
},
ebpf.CgroupStorage: {
Version: "6.2",
Fn: func() error { return probeStorageMap(sys.BPF_MAP_TYPE_CGRP_STORAGE) },
},
ebpf.Arena: {
Version: "6.9",
Fn: func() error {
return createMap(&sys.MapCreateAttr{
MapType: sys.BPF_MAP_TYPE_ARENA,
KeySize: 0,
ValueSize: 0,
MaxEntries: 1, // one page
MapExtra: 0, // can mmap() at any address
MapFlags: sys.BPF_F_MMAPABLE,
})
},
},
}

func init() {
Expand Down
11 changes: 11 additions & 0 deletions features/prog.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ var haveProgramTypeMatrix = internal.FeatureMatrix[ebpf.ProgramType]{
})
},
},
ebpf.Netfilter: {
Version: "6.4",
Fn: func() error {
return probeProgram(&ebpf.ProgramSpec{
Type: ebpf.Netfilter,
AttachType: ebpf.AttachNetfilter,
})
},
},
}

func init() {
Expand Down Expand Up @@ -261,6 +270,8 @@ func haveProgramHelper(pt ebpf.ProgramType, helper asm.BuiltinFunc) error {
spec.AttachType = ebpf.AttachSkLookup
case ebpf.Syscall:
spec.Flags = sys.BPF_F_SLEEPABLE
case ebpf.Netfilter:
spec.AttachType = ebpf.AttachNetfilter
}

prog, err := ebpf.NewProgramWithOptions(spec, ebpf.ProgramOptions{
Expand Down
6 changes: 5 additions & 1 deletion features/prog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestHaveProgramHelper(t *testing.T) {
}

// Referencing linux kernel commits to track the kernel version required to pass these test cases.
// They cases are derived from libbpf's selftests and helper/prog combinations that are
// These cases are derived from libbpf's selftests and helper/prog combinations that are
// probed for in cilium/cilium.
testCases := []testCase{
{ebpf.Kprobe, asm.FnMapLookupElem, nil, "3.19"}, // d0003ec01c66
Expand All @@ -63,6 +63,10 @@ func TestHaveProgramHelper(t *testing.T) {
{ebpf.CGroupSockAddr, asm.FnGetCgroupClassid, nil, "5.7"}, // 5a52ae4e32a6
{ebpf.Kprobe, asm.FnGetBranchSnapshot, nil, "5.16"}, // 856c02dbce4f
{ebpf.SchedCLS, asm.FnSkbSetTstamp, nil, "5.18"}, // 9bb984f28d5b
{ebpf.CGroupSockopt, asm.FnSkStorageDelete, nil, "5.3"}, // 6ac99e8f23d4
{ebpf.SkLookup, asm.FnSkcToUdp6Sock, nil, "5.9"}, // 0d4fad3e57df
{ebpf.Syscall, asm.FnSysClose, nil, "5.14"}, // 3abea089246f
{ebpf.Netfilter, asm.FnCgrpStorageDelete, nil, "6.4"}, // c4bcfb38a95e
}

for _, tc := range testCases {
Expand Down