Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libbpf bump #324

Merged
merged 3 commits into from
May 3, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion libbpf
Submodule libbpf updated 47 files
+1 −0 .gitattributes
+21 −4 .github/actions/build-selftests/build_selftests.sh
+85,495 −81,298 .github/actions/build-selftests/vmlinux.h
+6 −6 .github/actions/vmtest/action.yml
+1 −1 BPF-CHECKPOINT-COMMIT
+1 −1 CHECKPOINT-COMMIT
+1 −1 README.md
+281 −0 SYNC.md
+70 −0 ci/diffs/0001-s390-define-RUNTIME_DISCARD_EXIT-to-fix-link-error-w.patch
+83 −0 ci/diffs/0001-veth-take-into-account-peer-device-for-NETDEV_XDP_AC.patch
+0 −2 ci/vmtest/configs/ALLOWLIST-5.5.0
+1 −0 ci/vmtest/configs/DENYLIST-latest
+17 −8 docs/index.rst
+3 −3 docs/libbpf_naming_convention.rst
+228 −0 docs/libbpf_overview.rst
+105 −16 include/uapi/linux/bpf.h
+1 −0 include/uapi/linux/fcntl.h
+1 −0 include/uapi/linux/if_link.h
+61 −0 include/uapi/linux/netdev.h
+43 −0 include/uapi/linux/openat2.h
+3 −0 include/uapi/linux/perf_event.h
+2 −0 scripts/sync-kernel.sh
+1 −1 src/Makefile
+36 −9 src/bpf.c
+89 −6 src/bpf.h
+2 −2 src/bpf_core_read.h
+3 −1 src/bpf_gen_internal.h
+32 −7 src/bpf_helper_defs.h
+110 −2 src/bpf_helpers.h
+3 −0 src/bpf_tracing.h
+4 −6 src/btf.c
+25 −23 src/gen_loader.c
+455 −154 src/libbpf.c
+126 −24 src/libbpf.h
+6 −0 src/libbpf.map
+2 −2 src/libbpf_internal.h
+83 −0 src/libbpf_probes.c
+15 −10 src/linker.c
+115 −11 src/netlink.c
+1 −1 src/nlattr.c
+12 −0 src/nlattr.h
+0 −3 src/relo_core.c
+2 −2 src/ringbuf.c
+4 −1 src/usdt.bpf.h
+118 −78 src/usdt.c
+333 −0 src/zip.c
+47 −0 src/zip.h
29 changes: 22 additions & 7 deletions selftest/cgroup-legacy/main.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

#include <vmlinux.h>

#include <bpf/bpf_helpers.h>
#include <bpf/bpf_core_read.h>
#include <bpf/bpf_endian.h>
#include <bpf/bpf_helpers.h>

struct {
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
__uint(max_entries, 10);
__uint(max_entries, 1024);
__uint(key_size, sizeof(u32));
__uint(value_size, sizeof(u32));
} perfbuffer SEC(".maps");
Expand All @@ -31,22 +32,36 @@ int cgroup__skb_ingress(struct __sk_buff *ctx)
}

struct iphdr ip = {0};
if (bpf_skb_load_bytes_relative(ctx, 0, &ip, sizeof(ip), BPF_HDR_START_NET))
struct icmphdr icmp = {0};

u32 s_iphdr = bpf_core_type_size(struct iphdr);
u32 s_icmphdr = bpf_core_type_size(struct icmphdr);

if (bpf_skb_load_bytes_relative(ctx, 0, &ip, s_iphdr, BPF_HDR_START_NET))
return 1;

struct icmphdr icmp = {0};
// clang-format off

switch (ip.protocol) {
case IPPROTO_ICMP:
if (bpf_skb_load_bytes_relative(
ctx, sizeof(ip), &icmp, sizeof(struct icmphdr), BPF_HDR_START_NET))
if (bpf_skb_load_bytes_relative(ctx,
s_iphdr,
&icmp,
s_icmphdr,
BPF_HDR_START_NET))
return 1;

u32 bleh = 20220823;
bpf_perf_event_output(ctx, &perfbuffer, BPF_F_CURRENT_CPU, &bleh, sizeof(bleh));
bpf_perf_event_output(ctx,
&perfbuffer,
BPF_F_CURRENT_CPU,
&bleh,
sizeof(bleh));
break;
}

// clang-format on

return 1;
}

Expand Down
9 changes: 6 additions & 3 deletions selftest/cgroup-legacy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ func main() {

cgroupRootDir := getCgroupV2RootDir()

// link, err := prog.AttachCgroup(cgroupRootDir)
rafaeldtinoco marked this conversation as resolved.
Show resolved Hide resolved
link, err := prog.AttachCgroupLegacy(cgroupRootDir, bpf.BPFAttachTypeCgroupInetIngress)
if err != nil {
Error(err)
}

eventsChannel := make(chan []byte, 100)
lostChannel := make(chan uint64, 10)
eventsChannel := make(chan []byte, 1)
lostChannel := make(chan uint64, 1)

// initialize an eBPF perf buffer to receive events
bpfPerfBuffer, err := bpfModule.InitPerfBuf(
Expand All @@ -63,7 +64,7 @@ func main() {
defer stop()

// start eBPF perf buffer event polling
bpfPerfBuffer.Poll(300)
bpfPerfBuffer.Poll(5000)

go func() {
_, err := exec.Command("ping", "127.0.0.1", "-c 5", "-w 10").Output()
Expand All @@ -76,10 +77,12 @@ func main() {

testPassed := false
numberOfEventsReceived := 0

LOOP:
for {
select {
case raw := <-eventsChannel:

value := int(binary.LittleEndian.Uint32(raw))
if value == 20220823 {
fmt.Println("Received correct event.")
Expand Down
2 changes: 1 addition & 1 deletion selftest/set-attach/main.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct {
} events SEC(".maps");
long ringbuffer_flags = 0;

SEC("fentry/FUNC")
SEC("fentry")
int BPF_PROG(foobar)
{
int *process;
Expand Down
6 changes: 5 additions & 1 deletion selftest/set-attach/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ func main() {
os.Exit(-1)
}

prog.SetProgramType(bpf.BPFProgTypeTracing)
// eBPF program type should only be set if it differs from the desired one
// commit d6e6286a12e7 ("libbpf: disassociate section handler on explicit bpf_program__set_type() call")
// prog.SetProgramType(bpf.BPFProgTypeTracing)
prog.SetAttachType(bpf.BPFAttachTypeTraceFentry)

err = prog.SetAttachTarget(0, "__x64_sys_mmap")
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}

err = bpfModule.BPFLoadObject()
if err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down