From: Anthony Lineham Subject: Distinguishing between forwarded/bridged packets and locally generated packets Date: Mon, 10 Apr 2017 20:49:02 +0000 Message-ID: <1491857342293.80482@alliedtelesis.co.nz> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: "netdev@vger.kernel.org" Return-path: Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:58846 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140AbdDJUtM (ORCPT ); Mon, 10 Apr 2017 16:49:12 -0400 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 5F399806CB for ; Tue, 11 Apr 2017 08:49:09 +1200 (NZST) Content-Language: en-NZ Sender: netdev-owner@vger.kernel.org List-ID: Hi,=0A= =0A= =0A= I'm trying to find a way to distinguish between a packet that is being forw= arded/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 driv= er. Forwarded/bridged packets are processed when received, but I need to ma= ke sure locally generated packets are processed too, and avoid reprocessing= the forwarded packets.=0A= =0A= Up until now we have been using the skb_iif field in the socket buffer to d= o 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 re= alised that in some situations this information is scrubbed from the skb (b= y skb_scrub_packet), for example when the packet is being sent over a PPP l= ink. =0A= =0A= 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 hav= e the socket the packet was generated by. In the forwarding case it would n= ot be set. It looks like there are some cases that don't quite conform to t= his, such as ARP's, but I can probably live with that.=0A= =0A= Can anyone comment on the suitability of this method or if there is a more = appropriate way to achieve this.=0A= Any information is greatly appreciated.=0A= =0A= Thanks,=0A= Anthony=0A= =0A= =0A= =0A= =0A= =0A= =0A=