From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Pirko Subject: Re: [PATCH net 1/2] net: dev_queue_xmit_nit: fix skb->vlan_tci field value Date: Tue, 8 Jan 2013 21:22:08 +0100 Message-ID: <20130108202208.GE1621@minipsycho.orion> References: <1357671093-9605-1-git-send-email-dborkman@redhat.com> <1357671093-9605-2-git-send-email-dborkman@redhat.com> <1357675492.18156.420.camel@edumazet-glaptop> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Daniel Borkmann , David Miller , netdev@vger.kernel.org, Ani Sinha , Jiri Pirko To: Eric Dumazet Return-path: Received: from mail-wi0-f172.google.com ([209.85.212.172]:42102 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753283Ab3AHUWM (ORCPT ); Tue, 8 Jan 2013 15:22:12 -0500 Received: by mail-wi0-f172.google.com with SMTP id o1so71693wic.11 for ; Tue, 08 Jan 2013 12:22:11 -0800 (PST) Content-Disposition: inline In-Reply-To: <1357675492.18156.420.camel@edumazet-glaptop> Sender: netdev-owner@vger.kernel.org List-ID: Tue, Jan 08, 2013 at 09:04:52PM CET, eric.dumazet@gmail.com wrote: >On Tue, 2013-01-08 at 19:51 +0100, Daniel Borkmann wrote: >> VLAN packets that are locally injected through taps will loose their >> skb->vlan_tci value when they pass dev_hard_start_xmit and get looped >> back to a packet sniffer via dev_queue_xmit_nit. Besides others, this >> meta data is used in Linux socket filtering for VLANs. Tested with a >> VLAN ancillary ops filter. >> >> Patch is based on a previous version by Jiri Pirko. >> >> Cc: Eric Dumazet >> Cc: Ani Sinha >> Cc: Jiri Pirko >> Reported-by: Paul Pearce >> Signed-off-by: Daniel Borkmann >> --- >> net/core/dev.c | 13 +++++++++++++ >> 1 file changed, 13 insertions(+) >> >> diff --git a/net/core/dev.c b/net/core/dev.c >> index 515473e..723dcd0 100644 >> --- a/net/core/dev.c >> +++ b/net/core/dev.c >> @@ -1775,6 +1775,19 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) >> struct packet_type *ptype; >> struct sk_buff *skb2 = NULL; >> struct packet_type *pt_prev = NULL; >> + struct ethhdr *ehdr; >> + >> + /* Network taps could make use of skb->vlan_tci, which got wiped >> + * out. Hence, we need to reset it correctly. >> + */ >> + skb_reset_mac_header(skb); >> + ehdr = eth_hdr(skb); >> + >> + if (ehdr->h_proto == __constant_htons(ETH_P_8021Q)) { >> + skb2 = vlan_untag(skb); >> + if (likely(skb2)) >> + skb = skb2; >> + } >> >> rcu_read_lock(); >> list_for_each_entry_rcu(ptype, &ptype_all, list) { > >This patch is wrong (it adds a leak), and not needed. > >If a packet has no vlan_tci, its for a good reason. > >We want sniffer see the packet content as is. The issue is that for exmaple in af_packet the function packet_rcv() expects vlan_tci to be filled out as that is on RX path ensured by __netif_receive_skb(). However on TX path, dev_queue_xmit_nit() is called with vlan_tci cleaned in case the device does not have TX vlan accel enabled. This patch is trying to fix this difference. > > > >-- >To unsubscribe from this list: send the line "unsubscribe netdev" in >the body of a message to majordomo@vger.kernel.org >More majordomo info at http://vger.kernel.org/majordomo-info.html