我正在运行 bcc 示例/http_filter/http-parse-simple.c,其中有一条评论说明:
/*
eBPF program.
Filter IP and TCP packets, having payload not empty
and containing "HTTP", "GET", "POST" ... as first bytes of payload
if the program is loaded as PROG_TYPE_SOCKET_FILTER
and attached to a socket
return 0 -> DROP the packet
return -1 -> KEEP the packet and return it to user space (userspace
can read it from the socket_fd )
*/
当我运行这个例子时,我看到当我运行一个 UDP 数据包(例如 dig)或 icmp 数据包(ping)时,用户程序员确实没有收到数据包。
但是 ping 或 dig 程序不会丢失。
据我了解,这些非 TCP 数据包应该被丢弃(我希望 ping 或 dig 会失败),但事实并非如此。
那么是什么原因呢?
还有其他方法可以放弃 skb_buff 使用 ebpf/bcc 吗?