]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Sample HBM BPF program to limit egress bw
authorbrakmo <brakmo@fb.com>
Fri, 1 Mar 2019 20:38:48 +0000 (12:38 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 2 Mar 2019 18:48:27 +0000 (10:48 -0800)
commit618ba1e657dc61f6b9a4c06595daff288eaf48a1
tree23f8914204b589b663a8e76e086b16bab0bfcf81
parentf7bd2f522f3e481106407f74a2ca2b888bb78062
bpf: Sample HBM BPF program to limit egress bw

A cgroup skb BPF program to limit cgroup output bandwidth.
It uses a modified virtual token bucket queue to limit average
egress bandwidth. The implementation uses credits instead of tokens.
Negative credits imply that queueing would have happened (this is
a virtual queue, so no queueing is done by it. However, queueing may
occur at the actual qdisc (which is not used for rate limiting).

This implementation uses 3 thresholds, one to start marking packets and
the other two to drop packets:
                                 CREDIT
       - <--------------------------|------------------------> +
             |    |          |      0
             |  Large pkt    |
             |  drop thresh  |
  Small pkt drop             Mark threshold
      thresh

The effect of marking depends on the type of packet:
a) If the packet is ECN enabled, then the packet is ECN ce marked.
   The current mark threshold is tuned for DCTCP.
c) Else, it is dropped if it is a large packet.

If the credit is below the drop threshold, the packet is dropped.
Note that dropping a packet through the BPF program does not trigger CWR
(Congestion Window Reduction) in TCP packets. A future patch will add
support for triggering CWR.

This BPF program actually uses 2 drop thresholds, one threshold
for larger packets (>= 120 bytes) and another for smaller packets. This
protects smaller packets such as SYNs, ACKs, etc.

The default bandwidth limit is set at 1Gbps but this can be changed by
a user program through a shared BPF map. In addition, by default this BPF
program does not limit connections using loopback. This behavior can be
overwritten by the user program. There is also an option to calculate
some statistics, such as percent of packets marked or dropped, which
the user program can access.

A latter patch provides such a program (hbm.c)

Signed-off-by: Lawrence Brakmo <brakmo@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
samples/bpf/Makefile
samples/bpf/hbm.h [new file with mode: 0644]
samples/bpf/hbm_kern.h [new file with mode: 0644]
samples/bpf/hbm_out_kern.c [new file with mode: 0644]