【发布时间】:2020-04-24 13:42:31
【问题描述】:
我正在运行密件抄送示例/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 吗?
【问题讨论】:
-
您的问题中的某些内容我不清楚。 1)数据包是否被丢弃(你说 UDP/ICMP 数据包被丢弃)或没有(你添加你希望 ping/dig 失败但它毕竟工作,所以大概数据包没有被丢弃?) 2)你的意思是“是无论如何还有其他方法可以删除 skb_buff 使用 ebpf/bcc”,请您改写一下吗?
标签: python linux-kernel bpf ebpf bcc-bpf