]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Add test for l3 use of bpf_redirect_peer
authorJussi Maki <joamaki@gmail.com>
Tue, 25 May 2021 10:29:55 +0000 (10:29 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 25 May 2021 16:00:28 +0000 (18:00 +0200)
commit6fd5fb63820a9a1146aba0bba2fdbc1db4b903e7
tree24f7d28c24b6eea45a9228d6bd8f59d18d4f86d7
parenta8deba8547e39f26440101164a3bbc2899c5b305
selftests/bpf: Add test for l3 use of bpf_redirect_peer

Add a test case for using bpf_skb_change_head() in combination with
bpf_redirect_peer() to redirect a packet from a L3 device to veth and back.

The test uses a BPF program that adds L2 headers to the packet coming
from a L3 device and then calls bpf_redirect_peer() to redirect the packet
to a veth device. The test fails as skb->mac_len is not set properly and
thus the ethernet headers are not properly skb_pull'd in cls_bpf_classify(),
causing tcp_v4_rcv() to point the TCP header into middle of the IP header.

Signed-off-by: Jussi Maki <joamaki@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210525102955.2811090-1-joamaki@gmail.com
tools/testing/selftests/bpf/prog_tests/tc_redirect.c
tools/testing/selftests/bpf/progs/test_tc_peer.c