Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: Fix link info netfilter flags to populate defrag flag

This fix correctly populates the `bpf_link_info.netfilter.flags` field
when user passes the `BPF_F_NETFILTER_IP_DEFRAG` flag.

Fixes: 91721c2d02d3 ("netfilter: bpf: Support BPF_F_NETFILTER_IP_DEFRAG in netfilter link")
Signed-off-by: Tyrone Wu <wudevelops@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Florian Westphal <fw@strlen.de>
Cc: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/bpf/20241011193252.178997-1-wudevelops@gmail.com

authored by

Tyrone Wu and committed by
Daniel Borkmann
92f3715e ee230090

+2 -1
+2 -1
net/netfilter/nf_bpf_link.c
··· 150 150 struct bpf_link_info *info) 151 151 { 152 152 struct bpf_nf_link *nf_link = container_of(link, struct bpf_nf_link, link); 153 + const struct nf_defrag_hook *hook = nf_link->defrag_hook; 153 154 154 155 info->netfilter.pf = nf_link->hook_ops.pf; 155 156 info->netfilter.hooknum = nf_link->hook_ops.hooknum; 156 157 info->netfilter.priority = nf_link->hook_ops.priority; 157 - info->netfilter.flags = 0; 158 + info->netfilter.flags = hook ? BPF_F_NETFILTER_IP_DEFRAG : 0; 158 159 159 160 return 0; 160 161 }