Is there any information in the struct skbuff
to distinguish between the forwarding traffic (bridge forwarding and ip forwarding) and locally originated traffic? We want to treat these two kinds of traffic differently in the network driver because the forwarding traffic do not require cache invalidation on the whole packet size.
Any suggestions are appreciated. Thank you very much!
Advertisement
Answer
Yes it’s possible, you can try to follow the life cycle of a receiving packet by looking at all calls from this function ip_rcv_finish
(http://lxr.free-electrons.com/source/net/ipv4/ip_input.c?v=3.3#L317).
The struct struct sk_buff
contain a pointer to the destination entry :
struct dst_entry *dst;
which contain a function pointer :
int (*input)(struct sk_buff*);
to call for the input packet, in the case of local packet the kernel call ip_local_deliver
function and for the forwarding packet it calls ip_forward
function.
I think that you can, check like this for local and forwarded packets:
– Local :
/* struct sk_buff *skb : Entry packet */ if (((struct rtable *)skb->dst)->rt_type == RTN_LOCAL) { /* This packet is to consume locally */ }
– Forward :
if (((struct rtable *)skb->dst)->rt_type == RTN_UNICAST) { /* This packet will be forwarded */ }