]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: fix vlan handling in flow dissector program
authorStanislav Fomichev <sdf@google.com>
Mon, 1 Apr 2019 20:57:30 +0000 (13:57 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 3 Apr 2019 14:49:48 +0000 (16:49 +0200)
commited7fef4cf5451e91541273ef5bc9ae98bc9977de
treec47ea3641f3f3c97386ad5bcb9fdfe3a03717098
parent6c880448ada5df7da7f325b8624ca242870cbb51
selftests/bpf: fix vlan handling in flow dissector program

When we tail call PROG(VLAN) from parse_eth_proto we don't need to peek
back to handle vlan proto because we didn't adjust nhoff/thoff yet. Use
flow_keys->n_proto, that we set in parse_eth_proto instead and
properly increment nhoff as well.

Also, always use skb->protocol and don't look at skb->vlan_present.
skb->vlan_present indicates that vlan information is stored out-of-band
in skb->vlan_{tci,proto} and vlan header is already pulled from skb.
That means, skb->vlan_present == true is not relevant for BPF flow
dissector.

Add simple test cases with VLAN tagged frames:
  * single vlan for ipv4
  * double vlan for ipv6

Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/prog_tests/flow_dissector.c
tools/testing/selftests/bpf/progs/bpf_flow.c