HN 提问:如何在 eBPF 中处理内核结构体(例如 iov_iter)的更改?
3 分•作者: morolis•大约 6 小时前
我使用 pwru 的内核 vmlinux 头文件(6.10 版本)进行编译,但我的实际内核版本是 6.6。在内核版本变更(6.10 -> 6.6)时,`iov_iter` 中的 `iov` 字段名变成了内部匿名结构 `__iov`。因此,如果我按照 6.10 版本的字段名进行提取和编译,就无法在当前系统上运行,反之亦然。我想请问,对于这种内核结构的变化,是否有更正式或官方的解决方案?我目前的解决方案是直接自定义两个不同版本的 `iov` 匿名结构,然后通过 `bpf_core_field_exists` 来判断两种获取 `iov` 的方式是否兼容。
查看原文
I used the kernel vmlinux header file(6.10 version) from pwru to compile, but my actual kernel version was 6.6. the iov field name in iov_iter become an internal anonymous structure __iov file on kernel changing(6.10->6.6), so the led to that if I extracted and compiled according to the field name of version 6.10, I could not run in my current system, and vice versa. I would like to ask what is a more formal or official solution to deal with this change in kernel structure? My current solution is to directly customize two different versions of iov anonymous structures to judge whether two ways to obtain iov are compatible through bpf_core_field_exists.