forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bpf: minimal support for programs hooked into netfilter framework
Not for merging: has problems. This adds minimal support for BPF_PROG_TYPE_NETFILTER bpf programs that will be invoked via the NF_HOOK() points in the ip(6) stack. Invocation incurs an indirect call. This is not a necessity: Its possible to add 'DEFINE_BPF_DISPATCHER(nf_progs)' and handle the program invocation with the same method already done for xdp progs. This isn't done here to keep the size of this chunk down. Verifier will reject programs that don't return either DROP or ACCEPT verdicts. Programs currently pretend they have prototype func(struct __sk_buff *skb) with rewrite via verifier, but this will be changed to native kernel struct, i.e.: func(struct bpf_nf_ctx *ctx) Instead of direct packet access, plan is to have programs use upcoming 'dynptr' api. For 'traditional' netfilter (c-functions), skb->data is only guaranteed to be linear for the ip/ip6 header, for everything else skb_header_pointer is mandatory. Signed-off-by: Florian Westphal <fw@strlen.de>
- Loading branch information
1 parent
27ac276
commit 594e7d0
Showing
5 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
|
||
struct bpf_nf_ctx { | ||
const struct nf_hook_state *state; | ||
const struct sk_buff *skb; | ||
const void *data; | ||
const void *data_end; | ||
}; | ||
|
||
int bpf_nf_link_attach(const union bpf_attr *attr, struct bpf_prog *prog); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters