selftests/bpf: Fix BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL for empty flow label
Subsystems (3)
PATCH 1/1 selftests/bpf: Fix BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL for empty flow label
Kernel's flow dissector continues to parse the packet when the (optional) IPv6 flow label is empty even when instructed to stop (via BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL). Do the same in our reference BPF reimplementation.
--- .../selftests/bpf/prog_tests/flow_dissector.c | 24 +++++++++++++++++++ tools/testing/selftests/bpf/progs/bpf_flow.c | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/flow_dissector.c +24 -0
@@ -345,6 +345,30 @@ struct test tests[] = { .flags = BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL, .retval = BPF_OK, }, + { + .name = "ipv6-empty-flow-label", + .pkt.ipv6 = { + .eth.h_proto = __bpf_constant_htons(ETH_P_IPV6), + .iph.nexthdr = IPPROTO_TCP, + .iph.payload_len = __bpf_constant_htons(MAGIC_BYTES), + .iph.flow_lbl = { 0x00, 0x00, 0x00 }, + .tcp.doff = 5, + .tcp.source = 80, + .tcp.dest = 8080, + }, + .keys = { + .flags =BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL , + .nhoff = ETH_HLEN, + .thoff = ETH_HLEN + sizeof(struct ipv6hdr), + .addr_proto = ETH_P_IPV6, + .ip_proto = IPPROTO_TCP, + .n_proto = __bpf_constant_htons(ETH_P_IPV6), + .sport = 80, + .dport = 8080, + }, + .flags =BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL , + .retval = BPF_OK, + }, { .name ="ipip-encap" , .pkt.ipip = {
tools/testing/selftests/bpf/progs/bpf_flow.c +1 -1
@@ -337,7 +337,7 @@ PROG(IPV6)(struct __sk_buff *skb) keys->ip_proto = ip6h->nexthdr; keys->flow_label =ip6_flowlabel (ip6h); -if (keys->flags &BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL ) +if (keys->flow_label && keys->flags &BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL )return export_flow_keys (keys,BPF_OK );return parse_ipv6_proto (skb, ip6h->nexthdr);
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Quoted 6 lines · Stanislav Fomichev
Kernel's flow dissector continues to parse the packet when the (optional) IPv6 flow label is empty even when instructed to stop (via
BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL). Do the same in our reference BPF reimplementation.Signed-off-by Stanislav Fomichev <[email protected]>
Thanks for fixing this. We do want entropy if L4 is available.
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 8 lines · On Tue, 21 Feb 2023 10:05:18 -0800 you wrote:
Kernel's flow dissector continues to parse the packet when the (optional) IPv6 flow label is empty even when instructed to stop (via
BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL). Do the same in our reference BPF reimplementation.Signed-off-by Stanislav Fomichev <[email protected]>[...]
Here is the summary with links:
- [bpf-next] selftests/bpf: Fix BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL for empty flow label
https://git.kernel.org/bpf/bpf-next/c/9fa02892857a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html