netfilter: bpf: Support BPF_F_NETFILTER_IP_DEFRAG in netfilter link
authorDaniel Xu <dxu@dxuuu.xyz>
Fri, 21 Jul 2023 20:22:46 +0000 (14:22 -0600)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 28 Jul 2023 23:52:08 +0000 (16:52 -0700)
commit91721c2d02d3a0141df8a4787c7079b89b0d0607
tree6a8e7169d33bc9d348c46cfec854cbcbe825f24f
parent9abddac583d68e16258d5e0b95dc1b3ca1886173
netfilter: bpf: Support BPF_F_NETFILTER_IP_DEFRAG in netfilter link

This commit adds support for enabling IP defrag using pre-existing
netfilter defrag support. Basically all the flag does is bump a refcnt
while the link the active. Checks are also added to ensure the prog
requesting defrag support is run _after_ netfilter defrag hooks.

We also take care to avoid any issues w.r.t. module unloading -- while
defrag is active on a link, the module is prevented from unloading.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Reviewed-by: Florian Westphal <fw@strlen.de>
Link: https://lore.kernel.org/r/5cff26f97e55161b7d56b09ddcf5f8888a5add1d.1689970773.git.dxu@dxuuu.xyz
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/uapi/linux/bpf.h
net/netfilter/nf_bpf_link.c
tools/include/uapi/linux/bpf.h