docs: add note for libbpf

This commit is contained in:
yunwei37
2024-01-17 19:20:31 +00:00
parent 3468fab36b
commit 406d9eae1e
4 changed files with 23 additions and 9 deletions

View File

@@ -374,6 +374,8 @@ if (bpf_strncmp(line_buffer, 3, "GET") != 0 &&
}
```
> 注意:bpf_strncmp 这个内核 helper 在 5.17 版本中才被引入,如果你的内核版本低于 5.17,可以手动匹配字符串来实现相同的功能。
这段代码使用`bpf_strncmp`函数比较`line_buffer`中的数据与HTTP请求方法(GET、POST、PUT、DELETE、HTTP)是否匹配。如果不匹配,说明不是HTTP请求,直接返回0,放弃处理。
```c

View File

@@ -363,6 +363,8 @@ if (bpf_strncmp(line_buffer, 3, "GET") != 0 &&
}
```
> Note: The `bpf_strncmp` function is a helper function available from kernel version 5.17. For earlier versions, you can manually write a function to compare strings.
This piece of code uses the `bpf_strncmp` function to compare the data in `line_buffer` with HTTP request methods (GET, POST, PUT, DELETE, HTTP). If there is no match, indicating that it is not an HTTP request, it returns 0, indicating that it should not be processed.
```c