[PATCH] tools/ebpf: Fix IPv4 fragmentation identify

luwenpeng posted 1 patch 1 year ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230421082028.53579-1-lwp._5F1994@163.com
Maintainers: Jason Wang <jasowang@redhat.com>, Andrew Melnychenko <andrew@daynix.com>, Yuri Benditovich <yuri.benditovich@daynix.com>
tools/ebpf/rss.bpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tools/ebpf: Fix IPv4 fragmentation identify
Posted by luwenpeng 1 year ago
The meaning of the bit flag in ip.frag_off is Don`t fragmented
When judging IPv4 is_fragmented according to ip.frag_off,
should use !(bpf_ntohs(ip.frag_off) & 0x4000) instead of !!ip.frag_off

Signed-off-by: WenPeng Lu <lwp_1994@163.com>
---
 tools/ebpf/rss.bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/ebpf/rss.bpf.c b/tools/ebpf/rss.bpf.c
index 20f227e2ac..e77b764f3d 100644
--- a/tools/ebpf/rss.bpf.c
+++ b/tools/ebpf/rss.bpf.c
@@ -317,7 +317,7 @@ static inline int parse_packet(struct __sk_buff *skb,
 
         info->in_src = ip.saddr;
         info->in_dst = ip.daddr;
-        info->is_fragmented = !!ip.frag_off;
+        info->is_fragmented = !(bpf_ntohs(ip.frag_off) & 0x4000);
 
         l4_protocol = ip.protocol;
         l4_offset = ip.ihl * 4;
-- 
2.30.1 (Apple Git-130)