linux_dsm_epyc7002/tools/testing/selftests
Lorenz Bauer 234589012b selftests/bpf: Add cls_redirect classifier
cls_redirect is a TC clsact based replacement for the glb-redirect iptables
module available at [1]. It enables what GitHub calls "second chance"
flows [2], similarly proposed by the Beamer paper [3]. In contrast to
glb-redirect, it also supports migrating UDP flows as long as connected
sockets are used. cls_redirect is in production at Cloudflare, as part of
our own L4 load balancer.

We have modified the encapsulation format slightly from glb-redirect:
glbgue_chained_routing.private_data_type has been repurposed to form a
version field and several flags. Both have been arranged in a way that
a private_data_type value of zero matches the current glb-redirect
behaviour. This means that cls_redirect will understand packets in
glb-redirect format, but not vice versa.

The test suite only covers basic features. For example, cls_redirect will
correctly forward path MTU discovery packets, but this is not exercised.
It is also possible to switch the encapsulation format to GRE on the last
hop, which is also not tested.

There are two major distinctions from glb-redirect: first, cls_redirect
relies on receiving encapsulated packets directly from a router. This is
because we don't have access to the neighbour tables from BPF, yet. See
forward_to_next_hop for details. Second, cls_redirect performs decapsulation
instead of using separate ipip and sit tunnel devices. This
avoids issues with the sit tunnel [4] and makes deploying the classifier
easier: decapsulated packets appear on the same interface, so existing
firewall rules continue to work as expected.

The code base started it's life on v4.19, so there are most likely still
hold overs from old workarounds. In no particular order:

- The function buf_off is required to defeat a clang optimization
  that leads to the verifier rejecting the program due to pointer
  arithmetic in the wrong order.

- The function pkt_parse_ipv6 is force inlined, because it would
  otherwise be rejected due to returning a pointer to stack memory.

- The functions fill_tuple and classify_tcp contain kludges, because
  we've run out of function arguments.

- The logic in general is rather nested, due to verifier restrictions.
  I think this is either because the verifier loses track of constants
  on the stack, or because it can't track enum like variables.

1: https://github.com/github/glb-director/tree/master/src/glb-redirect
2: https://github.com/github/glb-director/blob/master/docs/development/second-chance-design.md
3: https://www.usenix.org/conference/nsdi18/presentation/olteanu
4: https://github.com/github/glb-director/issues/64

Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200424185556.7358-2-lmb@cloudflare.com
2020-04-26 10:00:36 -07:00
..
android SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
arm64 .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
bpf selftests/bpf: Add cls_redirect classifier 2020-04-26 10:00:36 -07:00
breakpoints .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
capabilities .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
cgroup SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
clone3 SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
cpu-hotplug
cpufreq
dmabuf-heaps dma-buf: heaps: Use _IOCTL_ for userspace IOCTL identifier 2019-12-17 21:37:40 +05:30
drivers SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
efivarfs .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
exec .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
filesystems kselftest: introduce new epoll test case 2020-04-07 10:43:44 -07:00
firmware selftests: firmware: Add firmware_request_platform tests 2020-03-20 14:54:04 +01:00
ftrace selftests/ftrace: Add CONFIG_SAMPLE_FTRACE_DIRECT=m kconfig 2020-04-14 10:00:29 -06:00
futex .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
gpio .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
ia64 .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
intel_pstate .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
ipc selftests/ipc: Fix test failure seen after initial test run 2020-04-14 10:24:28 -06:00
ir .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
kcmp .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
kexec
kmod selftests: kmod: test disabling module autoloading 2020-04-10 15:36:22 -07:00
kselftest kselftest/runner: allow to properly deliver signals to tests 2020-04-14 09:49:13 -06:00
kvm SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
lib selftests: Move kselftest_module.sh into kselftest/ 2019-11-07 14:46:08 -07:00
livepatch selftests: Install settings files to fix TIMEOUT failures 2020-02-20 08:56:42 -07:00
lkdtm selftest/lkdtm: Use local .gitignore 2020-03-02 08:39:39 -07:00
locking
media_tests .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
membarrier .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
memfd selftests: Fix memfd test run-time regression 2020-04-13 09:33:46 -06:00
memory-hotplug
mount .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
mqueue .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-04-25 20:18:53 -07:00
netfilter selftests: netfilter: add nfqueue test case 2020-03-24 20:00:12 +01:00
nsfs .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
ntb
openat2 .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
pid_namespace selftests: add pid namespace ENOMEM regression test 2020-03-25 13:50:34 +01:00
pidfd threads-v5.7 2020-04-04 10:08:18 -07:00
powerpc powerpc updates for 5.7 #2 2020-04-09 11:01:42 -07:00
prctl .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
proc .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
pstore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
ptp .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
ptrace SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
rcutorture SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
resctrl selftests/resctrl: fix spelling mistake "Errror" -> "Error" 2020-03-13 13:29:22 -06:00
rseq .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
rtc .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
safesetid .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
seccomp selftests/seccomp: allow clock_nanosleep instead of nanosleep 2020-04-14 09:49:51 -06:00
sigaltstack .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
size .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
sparc64 .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
splice .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
static_keys
sync .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
sysctl
tc-testing selftests: tc-testing: Add a TDC test for pedit munge ip6 dsfield 2020-04-22 19:48:57 -07:00
timens SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
timers .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
tmpfs .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
tpm2 Revert "Kernel selftests: tpm2: check for tpm support" 2020-04-14 10:08:24 -06:00
uevent
user
vDSO .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
vm selftests: vm: Fix 64-bit test builds for powerpc64le 2020-04-13 09:33:46 -06:00
watchdog .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
wireguard SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
x86 SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
zram
.gitignore SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
gen_kselftest_tar.sh selftests: gen_kselftest_tar.sh: Do not clobber kselftest/ 2019-11-07 14:43:27 -07:00
kselftest_harness.h selftests/harness: fix spelling mistake "SIGARLM" -> "SIGALRM" 2020-04-14 09:44:04 -06:00
kselftest_install.sh selftests: gen_kselftest_tar.sh: Do not clobber kselftest/ 2019-11-07 14:43:27 -07:00
kselftest_module.h
kselftest.h
lib.mk linux-kselftest-5.7-rc1 2020-04-01 16:09:12 -07:00
Makefile threads-v5.7 2020-04-04 10:08:18 -07:00