diff options
author | Shmulik Ladkani <shmulik.ladkani@gmail.com> | 2022-08-21 14:35:17 +0300 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2022-08-23 22:47:55 +0200 |
commit | 91350fe152930c0d61a362af68272526490efea5 (patch) | |
tree | c22bbbb2f28198da8019dd4bd27170aa29981845 /net | |
parent | 0ba985024ae7db226776725d9aa436b5c1c9fca2 (diff) | |
download | linux-stable-91350fe152930c0d61a362af68272526490efea5.tar.gz linux-stable-91350fe152930c0d61a362af68272526490efea5.tar.bz2 linux-stable-91350fe152930c0d61a362af68272526490efea5.zip |
bpf, flow_dissector: Introduce BPF_FLOW_DISSECTOR_CONTINUE retcode for bpf progs
Currently, attaching BPF_PROG_TYPE_FLOW_DISSECTOR programs completely
replaces the flow-dissector logic with custom dissection logic. This
forces implementors to write programs that handle dissection for any
flows expected in the namespace.
It makes sense for flow-dissector BPF programs to just augment the
dissector with custom logic (e.g. dissecting certain flows or custom
protocols), while enjoying the broad capabilities of the standard
dissector for any other traffic.
Introduce BPF_FLOW_DISSECTOR_CONTINUE retcode. Flow-dissector BPF
programs may return this to indicate no dissection was made, and
fallback to the standard dissector is requested.
Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20220821113519.116765-3-shmulik.ladkani@gmail.com
Diffstat (limited to 'net')
-rw-r--r-- | net/core/flow_dissector.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index a01817fb4ef4..990429c69ccd 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1022,11 +1022,14 @@ bool __skb_flow_dissect(const struct net *net, prog = READ_ONCE(run_array->items[0].prog); result = bpf_flow_dissect(prog, &ctx, n_proto, nhoff, hlen, flags); + if (result == BPF_FLOW_DISSECTOR_CONTINUE) + goto dissect_continue; __skb_flow_bpf_to_target(&flow_keys, flow_dissector, target_container); rcu_read_unlock(); return result == BPF_OK; } +dissect_continue: rcu_read_unlock(); } |