Hi,

I'm trying to find a way to distinguish between a packet that is being 
forwarded/bridged and one that was locally generated by the host itself. I need 
to know this for a particular application at tx in an ethernet device driver. 
Forwarded/bridged packets are processed when received, but I need to make sure 
locally generated packets are processed too, and avoid reprocessing the 
forwarded packets.

Up until now we have been using the skb_iif field in the socket buffer to do 
this. The logic is that forwarded/bridged packet has a non-zero value in this 
field, indicating the incoming interface index and a locally generated packet 
has 0 as there is no incoming interface. However, we've recently realised that 
in some situations this information is scrubbed from the skb (by 
skb_scrub_packet), for example when the packet is being sent over a PPP link. 

I'm looking for an alternative method to use. Currently I'm thinking about 
using the sk field in the skb. In a locally generated packet this would have 
the socket the packet was generated by. In the forwarding case it would not be 
set. It looks like there are some cases that don't quite conform to this, such 
as ARP's, but I can probably live with that.

Can anyone comment on the suitability of this method or if there is a more 
appropriate way to achieve this.
Any information is greatly appreciated.

Thanks,
Anthony






Reply via email to