bpf: Sample program to load cg skb BPF programs
Subsystems (3)
PATCH 6/9 bpf: Sample program to load cg skb BPF programs
The program load_cg_skb can be used to load BPF_PROG_TYPE_CGROUP_SKB type bpf_prog which currently can be attached to the ingress and egress patch. It can also be used to detach the bpf_prog.
Examples:
load_cg_skb [-i] <cg-path> <prog filename>
Load and attaches a cg skb program to the specified cgroup. If "-i" is used, the program is attached as ingress (default is egress).
load_cg_skb -r[i] <cg-path>
Detaches the currnetly attached egress (or ingress if -ri is used) cg skb program from the specified cgroup.
--- samples/bpf/Makefile | 2 + samples/bpf/load_cg_skb.c | 109 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 samples/bpf/load_cg_skb.c
samples/bpf/Makefile +2 -0
@@ -53,6 +53,7 @@ hostprogs-y += xdpsock hostprogs-y += xdp_fwd hostprogs-y += task_fd_query hostprogs-y += xdp_sample_pkts +hostprogs-y += load_cg_skb # Libbpf dependencies LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
@@ -109,6 +110,7 @@ xdpsock-objs := xdpsock_user.o xdp_fwd-objs := xdp_fwd_user.o task_fd_query-objs := bpf_load.o task_fd_query_user.o $(TRACE_HELPERS) xdp_sample_pkts-objs := xdp_sample_pkts_user.o $(TRACE_HELPERS) +load_cg_skb-objs := bpf_load.o load_cg_skb.o # Tell kbuild to always build the programs always := $(hostprogs-y)
samples/bpf/load_cg_skb.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 1 line · brakmo
+#include "
bpf_load.h"
nit: please use libbpf
Quoted 4 lines · Jakub Kicinski
Quoted 1 line · brakmo
+#include "
bpf_load.h"nit: please use libbpf
My suggestion was to just use bpftool, no need for another helper in the samples/ directory. WDYT?
Quoted 7 lines · Stanislav Fomichev
Quoted 4 lines · Jakub Kicinski
Quoted 1 line · brakmo
+#include "
bpf_load.h"nit: please use libbpf
My suggestion was to just use bpftool, no need for another helper in the
samples/directory. WDYT?
Oh yes, you're right, bpftool fully covers what this samples does.