Network Resource Manager is a framework for limiting the bandwidth used by v2 cgroups. It consists of 4 BPF helpers and a sample BPF program to limit egress bandwdith as well as a sample user program and script to simplify NRM testing.
The sample NRM BPF program is not meant to be production quality, it is provided as proof of concept. A lot more information, including sample runs in some cases, are provided in the commit messages of the individual patches. Two more BPF programs, one to limit ingress and one that limits egress and uses fq's Earliest Departure Time feature (EDT), will be provided in an upcomming patchset. Changes from v1 to v2: * bpf_tcp_enter_cwr can only be called from a cgroup skb egress BPF program (otherwise load or attach will fail) where we already hold the sk lock. Also only applies for ESTABLISHED state. * bpf_skb_ecn_set_ce uses INET_ECN_set_ce() * bpf_tcp_check_probe_timer now uses tcp_reset_xmit_timer. Can only be used by egress cgroup skb programs. * removed load_cg_skb user program. * nrm bpf egress program checks packet header in skb to determine ECN value. Now also works for ECN enabled UDP packets. Using ECN_ defines instead of integers. * NRM script test program now uses bpftool instead of load_cg_skb Martin KaFai Lau (2): bpf: Remove const from get_func_proto bpf: Add bpf helper bpf_tcp_enter_cwr brakmo (7): bpf: Test bpf_tcp_enter_cwr in test_verifier bpf: add bpf helper bpf_skb_ecn_set_ce bpf: Add bpf helper bpf_tcp_check_probe_timer bpf: sync bpf.h to tools and update bpf_helpers.h bpf: Sample NRM BPF program to limit egress bw bpf: User program for testing NRM bpf: NRM test script drivers/media/rc/bpf-lirc.c | 2 +- include/linux/bpf.h | 3 +- include/linux/filter.h | 3 +- include/uapi/linux/bpf.h | 27 +- kernel/bpf/cgroup.c | 2 +- kernel/bpf/syscall.c | 12 + kernel/bpf/verifier.c | 4 + kernel/trace/bpf_trace.c | 10 +- net/core/filter.c | 101 ++++- samples/bpf/Makefile | 5 + samples/bpf/do_nrm_test.sh | 437 +++++++++++++++++++ samples/bpf/nrm.c | 440 ++++++++++++++++++++ samples/bpf/nrm.h | 31 ++ samples/bpf/nrm_kern.h | 137 ++++++ samples/bpf/nrm_out_kern.c | 190 +++++++++ tools/include/uapi/linux/bpf.h | 27 +- tools/testing/selftests/bpf/bpf_helpers.h | 6 + tools/testing/selftests/bpf/verifier/sock.c | 33 ++ 18 files changed, 1444 insertions(+), 26 deletions(-) create mode 100755 samples/bpf/do_nrm_test.sh create mode 100644 samples/bpf/nrm.c create mode 100644 samples/bpf/nrm.h create mode 100644 samples/bpf/nrm_kern.h create mode 100644 samples/bpf/nrm_out_kern.c -- 2.17.1