diff mbox series

[bpf,v1,1/2] bpf: fix link info netfilter flags to populate defrag flag

Message ID 20241011193252.178997-1-wudevelops@gmail.com
State New
Headers show
Series [bpf,v1,1/2] bpf: fix link info netfilter flags to populate defrag flag | expand

Commit Message

Tyrone Wu Oct. 11, 2024, 7:32 p.m. UTC
This patch correctly populates the `bpf_link_info.netfilter.flags` field
when user passes the `BPF_F_NETFILTER_IP_DEFRAG` flag.

Fixes: 84601d6ee68a ("bpf: add bpf_link support for BPF_NETFILTER programs")
Signed-off-by: Tyrone Wu <wudevelops@gmail.com>
---
 net/netfilter/nf_bpf_link.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Daniel Borkmann Oct. 16, 2024, 3:13 p.m. UTC | #1
On 10/15/24 5:25 PM, Florian Westphal wrote:
> Tyrone Wu <wudevelops@gmail.com> wrote:
>> This patch correctly populates the `bpf_link_info.netfilter.flags` field
>> when user passes the `BPF_F_NETFILTER_IP_DEFRAG` flag.
> 
> Indeed, thanks for fixing this.
> Patch and testcase look good, but one nit:
> 
>> Fixes: 84601d6ee68a ("bpf: add bpf_link support for BPF_NETFILTER programs")
> 
> BPF_F_NETFILTER_IP_DEFRAG flag was added in
> 91721c2d02d3 ("netfilter: bpf: Support BPF_F_NETFILTER_IP_DEFRAG in netfilter link"), that was a bit later than the initial support.
> 
> Other than that,
> Acked-by: Florian Westphal <fw@strlen.de>

Thanks Florian & Tyrone, fixed up Fixes tag while applying.
diff mbox series

Patch

diff --git a/net/netfilter/nf_bpf_link.c b/net/netfilter/nf_bpf_link.c
index 5257d5e7eb09..797fe8a9971e 100644
--- a/net/netfilter/nf_bpf_link.c
+++ b/net/netfilter/nf_bpf_link.c
@@ -150,11 +150,12 @@  static int bpf_nf_link_fill_link_info(const struct bpf_link *link,
 				      struct bpf_link_info *info)
 {
 	struct bpf_nf_link *nf_link = container_of(link, struct bpf_nf_link, link);
+	const struct nf_defrag_hook *hook = nf_link->defrag_hook;
 
 	info->netfilter.pf = nf_link->hook_ops.pf;
 	info->netfilter.hooknum = nf_link->hook_ops.hooknum;
 	info->netfilter.priority = nf_link->hook_ops.priority;
-	info->netfilter.flags = 0;
+	info->netfilter.flags = hook ? BPF_F_NETFILTER_IP_DEFRAG : 0;
 
 	return 0;
 }