bpf: User program for testing NRM
Subsystems (3)
PATCH 8/9 bpf: User program for testing NRM
The program nrm creates a cgroup and attaches a BPF program to the cgroup for testing NRM for egress traffic. One still needs to create network traffic. This can be done through netesto, netperf or iperf3. A follow-up patch contains a script to create traffic.
USAGE: nrm [-d] [-l] [-n <id>] [-r <rate>] [-s] [-t <secs>]
[-w] [-h] [prog] Where: -d Print BPF trace debug buffer -l Also limit flows doing loopback -n <#> To create cgroup "/nrm#" and attach prog. Default is /nrm1
This is convenient when testing NRM in more than 1 cgroup
-r <rate> Rate limit in Mbps
-s Get NRM stats (marked, dropped, etc.)
-t <time> Exit after specified seconds (deault is 0)
-w Work conserving flag. cgroup can increase its bandwidth
beyond the rate limit specified while there is available bandwidth. Current implementation assumes there is only NIC (eth0), but can be extended to support multiple NICs. Currrently only supported for egress. Note, this is just a proof of concept.
-h Print this info
prog BPF program file name. Name defaults to nrm_out_kern.o for
output, and nrm_in_ker.o for input.
More information about NRM can be found in the paper "BPF Host Resource Management" presented at the 2018 Linux Plumbers Conference, Networking Track
(http://vger.kernel.org/lpc_net2018_talks/LPC%20BPF%20Network%20Resource%20Paper.pdf)
--- samples/bpf/Makefile | 3 + samples/bpf/nrm.c | 439 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 442 insertions(+) create mode 100644 samples/bpf/nrm.c
samples/bpf/Makefile +3 -0
@@ -54,6 +54,7 @@ hostprogs-y += xdp_fwd hostprogs-y += task_fd_query hostprogs-y += xdp_sample_pkts hostprogs-y += load_cg_skb +hostprogs-y += nrm # Libbpf dependencies LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
@@ -111,6 +112,7 @@ 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 +nrm-objs := bpf_load.o nrm.o $(CGROUP_HELPERS) # Tell kbuild to always build the programs always := $(hostprogs-y)
@@ -270,6 +272,7 @@ $(src)/*.c: verify_target_bpf $(LIBBPF) $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h $(obj)/nrm_out_kern.o: $(src)/nrm.h $(src)/nrm_kern.h +$(obj)/nrm.o: $(src)/nrm.h # asm/sysreg.h - inline assembly used by it is incompatible with llvm. # But, there is no easy way to fix it, so just exclude it since it is
samples/bpf/nrm.c new file +439 -0
439 lines not on this page · raw message
Signature · 1 line
2.17.1