struct skbuff中是否有任何信息可以区分转发流量(网桥转发和ip转发)和本地发起的流量?我们希望在网络驱动程序中区别对待这两种流量,因为转发流量不需要对整个数据包大小进行缓存失效。
如有任何建议,欢迎光临。非常感谢!
发布于 2012-08-25 00:28:01
是的,您可以通过查看此函数ip_rcv_finish (http://lxr.free-electrons.com/source/net/ipv4/ip_input.c?v=3.3#L317)的所有调用来尝试跟踪接收数据包的生命周期。
结构struct sk_buff包含指向目标条目的指针:
struct dst_entry *dst;它包含一个函数指针:
int (*input)(struct sk_buff*);为了调用输入包,在本地包的情况下,内核调用ip_local_deliver函数,对于转发包,它调用ip_forward函数。
我认为您可以像这样检查本地和转发的数据包:
-本地:
/* struct sk_buff *skb : Entry packet */
if (((struct rtable *)skb->dst)->rt_type == RTN_LOCAL)
{
/* This packet is to consume locally */
}-转发:
if (((struct rtable *)skb->dst)->rt_type == RTN_UNICAST)
{
/* This packet will be forwarded */
}https://stackoverflow.com/questions/12104105
复制相似问题