public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Dave Jones <davej@redhat.com>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	Chris Wedgwood <reviews@ml.cw.f00f.org>,
	Michael Krufky <mkrufky@linuxtv.org>,
	Chuck Ebbert <cebbert@redhat.com>,
	Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
	Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
	Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Patrick McHardy <kaber@trash.net>,
	"David S. Miller" <davem@davemloft.net>,
	Jesse Brandeburg <jesse.brandeburg@intel.com>
Subject: [patch 11/41] net: fix packet socket delivery in rx irq handler
Date: Wed, 4 Feb 2009 10:46:10 -0800	[thread overview]
Message-ID: <20090204184610.GL25246@kroah.com> (raw)
In-Reply-To: <20090204184539.GA25246@kroah.com>

[-- Attachment #1: net-fix-packet-socket-delivery-in-rx-irq-handler.patch --]
[-- Type: text/plain, Size: 5006 bytes --]

2.6.27-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Patrick McHardy <kaber@trash.net>

commit 9b22ea560957de1484e6b3e8538f7eef202e3596 upstream.

The changes to deliver hardware accelerated VLAN packets to packet
sockets (commit bc1d0411) caused a warning for non-NAPI drivers.
The __vlan_hwaccel_rx() function is called directly from the drivers
RX function, for non-NAPI drivers that means its still in RX IRQ
context:

[   27.779463] ------------[ cut here ]------------
[   27.779509] WARNING: at kernel/softirq.c:136 local_bh_enable+0x37/0x81()
...
[   27.782520]  [<c0264755>] netif_nit_deliver+0x5b/0x75
[   27.782590]  [<c02bba83>] __vlan_hwaccel_rx+0x79/0x162
[   27.782664]  [<f8851c1d>] atl1_intr+0x9a9/0xa7c [atl1]
[   27.782738]  [<c0155b17>] handle_IRQ_event+0x23/0x51
[   27.782808]  [<c015692e>] handle_edge_irq+0xc2/0x102
[   27.782878]  [<c0105fd5>] do_IRQ+0x4d/0x64

Split hardware accelerated VLAN reception into two parts to fix this:

- __vlan_hwaccel_rx just stores the VLAN TCI and performs the VLAN
  device lookup, then calls netif_receive_skb()/netif_rx()

- vlan_hwaccel_do_receive(), which is invoked by netif_receive_skb()
  in softirq context, performs the real reception and delivery to
  packet sockets.

Reported-and-tested-by: Ramon Casellas <ramon.casellas@cttc.es>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 include/linux/if_vlan.h |    7 +++++++
 net/8021q/vlan_core.c   |   46 +++++++++++++++++++++++++++++++++-------------
 net/core/dev.c          |    3 +++
 3 files changed, 43 insertions(+), 13 deletions(-)

--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -114,6 +114,8 @@ extern u16 vlan_dev_vlan_id(const struct
 
 extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
 			     u16 vlan_tci, int polling);
+extern int vlan_hwaccel_do_receive(struct sk_buff *skb);
+
 #else
 static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
 {
@@ -133,6 +135,11 @@ static inline int __vlan_hwaccel_rx(stru
 	BUG();
 	return NET_XMIT_SUCCESS;
 }
+
+static inline int vlan_hwaccel_do_receive(struct sk_buff *skb)
+{
+	return 0;
+}
 #endif
 
 /**
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -3,11 +3,20 @@
 #include <linux/if_vlan.h>
 #include "vlan.h"
 
+struct vlan_hwaccel_cb {
+	struct net_device	*dev;
+};
+
+static inline struct vlan_hwaccel_cb *vlan_hwaccel_cb(struct sk_buff *skb)
+{
+	return (struct vlan_hwaccel_cb *)skb->cb;
+}
+
 /* VLAN rx hw acceleration helper.  This acts like netif_{rx,receive_skb}(). */
 int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
 		      u16 vlan_tci, int polling)
 {
-	struct net_device_stats *stats;
+	struct vlan_hwaccel_cb *cb = vlan_hwaccel_cb(skb);
 
 	if (skb_bond_should_drop(skb)) {
 		dev_kfree_skb_any(skb);
@@ -15,23 +24,35 @@ int __vlan_hwaccel_rx(struct sk_buff *sk
 	}
 
 	skb->vlan_tci = vlan_tci;
+	cb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK);
+
+	return (polling ? netif_receive_skb(skb) : netif_rx(skb));
+}
+EXPORT_SYMBOL(__vlan_hwaccel_rx);
+
+int vlan_hwaccel_do_receive(struct sk_buff *skb)
+{
+	struct vlan_hwaccel_cb *cb = vlan_hwaccel_cb(skb);
+	struct net_device *dev = cb->dev;
+	struct net_device_stats *stats;
+
 	netif_nit_deliver(skb);
 
-	skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK);
-	if (skb->dev == NULL) {
-		dev_kfree_skb_any(skb);
-		/* Not NET_RX_DROP, this is not being dropped
-		 * due to congestion. */
-		return NET_RX_SUCCESS;
+	if (dev == NULL) {
+		kfree_skb(skb);
+		return -1;
 	}
-	skb->dev->last_rx = jiffies;
+
+	skb->dev = dev;
+	skb->priority = vlan_get_ingress_priority(dev, skb->vlan_tci);
 	skb->vlan_tci = 0;
 
-	stats = &skb->dev->stats;
+	dev->last_rx = jiffies;
+
+	stats = &dev->stats;
 	stats->rx_packets++;
 	stats->rx_bytes += skb->len;
 
-	skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tci);
 	switch (skb->pkt_type) {
 	case PACKET_BROADCAST:
 		break;
@@ -43,13 +64,12 @@ int __vlan_hwaccel_rx(struct sk_buff *sk
 		 * This allows the VLAN to have a different MAC than the
 		 * underlying device, and still route correctly. */
 		if (!compare_ether_addr(eth_hdr(skb)->h_dest,
-					skb->dev->dev_addr))
+					dev->dev_addr))
 			skb->pkt_type = PACKET_HOST;
 		break;
 	};
-	return (polling ? netif_receive_skb(skb) : netif_rx(skb));
+	return 0;
 }
-EXPORT_SYMBOL(__vlan_hwaccel_rx);
 
 struct net_device *vlan_dev_real_dev(const struct net_device *dev)
 {
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2187,6 +2187,9 @@ int netif_receive_skb(struct sk_buff *sk
 	int ret = NET_RX_DROP;
 	__be16 type;
 
+	if (skb->vlan_tci && vlan_hwaccel_do_receive(skb))
+		return NET_RX_SUCCESS;
+
 	/* if we've gotten here through NAPI, check netpoll */
 	if (netpoll_receive_skb(skb))
 		return NET_RX_DROP;


  parent reply	other threads:[~2009-02-04 18:55 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090204184029.881610776@mini.kroah.org>
2009-02-04 18:45 ` [patch 00/41] 2.6.27-stable review Greg KH
2009-02-04 18:45   ` [patch 01/41] cifs: make sure we allocate enough storage for socket address Greg KH
2009-02-04 18:45   ` [patch 02/41] ixgb: fix bug when freeing resources Greg KH
2009-02-04 18:45   ` [patch 03/41] m68knommu: set NO_DMA Greg KH
2009-02-04 18:45   ` [patch 04/41] sata_mv: fix 8-port timeouts on 508x/6081 chips Greg KH
2009-02-04 18:45   ` [patch 05/41] x86: use early clobbers in usercopy*.c Greg KH
2009-02-04 18:46   ` [patch 06/41] Add enable_ms to jsm driver Greg KH
2009-02-04 18:46   ` [patch 07/41] fbdev/atyfb: Fix DSP config on some PowerMacs & PowerBooks Greg KH
2009-02-04 23:51     ` Benjamin Herrenschmidt
2009-02-05  0:02       ` Greg KH
2009-02-05  9:23         ` Benjamin Herrenschmidt
2009-02-06 12:05       ` David Woodhouse
2009-02-06 13:48         ` Risto Suominen
2009-02-07  2:50         ` Benjamin Herrenschmidt
2009-02-04 18:46   ` [patch 08/41] Fix memory corruption in console selection Greg KH
2009-02-04 18:46   ` [patch 09/41] Input: atkbd - broaden the Dell DMI signatures Greg KH
2009-02-04 18:46   ` [patch 10/41] Input: atkbd - Samsung NC10 key repeat fix Greg KH
2009-02-04 18:46   ` Greg KH [this message]
2009-02-04 18:46   ` [patch 12/41] nfsd: Ensure nfsv4 calls the underlying filesystem on LOCKT Greg KH
2009-02-04 18:46   ` [patch 13/41] nfsd: only set file_lock.fl_lmops in nfsd4_lockt if a stateowner is found Greg KH
2009-02-04 18:46   ` [patch 14/41] PCI: irq and pci_ids patch for Intel Tigerpoint DeviceIDs Greg KH
2009-02-04 18:46   ` [patch 15/41] sata_nv: rename nv_nf2_hardreset() Greg KH
2009-02-04 18:46   ` [patch 16/41] sata_nv: fix MCP5x reset Greg KH
2009-02-04 18:46   ` [patch 17/41] sata_nv: ck804 has borked hardreset too Greg KH
2009-02-04 18:46   ` [patch 18/41] USB: isp1760: Fix probe in PCI glue code Greg KH
2009-02-04 18:46   ` [patch 19/41] x86: fix page attribute corruption with cpa() Greg KH
2009-02-04 18:46   ` [patch 20/41] cpuidle: update the last_state acpi cpuidle reflecting actual state entered Greg KH
2009-02-04 18:46   ` [patch 21/41] cpuidle: upon BIOS bug, default to default_idle rather than polling Greg KH
2009-02-04 18:46   ` [patch 22/41] cpuidle: use last_state which can reflect the actual state entered Greg KH
2009-02-04 18:46   ` [patch 23/41] cpuidle: Add decaying history logic to menu idle predictor Greg KH
2009-02-04 18:46   ` [patch 24/41] ACPI: Avoid array address overflow when _CST MWAIT hint bits are set Greg KH
2009-02-04 18:46   ` [patch 25/41] ACPI: Attach the ACPI device to the ACPI handle as early as possible Greg KH
2009-02-04 18:46   ` [patch 26/41] ACPICA: Fixed a couple memory leaks associated with "implicit return" Greg KH
2009-02-04 18:46   ` [patch 27/41] ACPICA: Add check for invalid handle in acpi_get_object_info Greg KH
2009-02-04 18:46   ` [patch 28/41] ACPI: Change acpi_evaluate_integer to support 64-bit on 32-bit kernels Greg KH
2009-02-04 18:46   ` [patch 29/41] ACPI: Fix compiler warnings introduced by 32 to 64 bit acpi conversions Greg KH
2009-02-04 18:46   ` [patch 30/41] ACPI EC: Fix regression due to use of uninitialized variable Greg KH
2009-02-05  8:08     ` Thomas Renninger
2009-02-05 15:06       ` Thomas Renninger
2009-02-05 17:30         ` Greg KH
2009-02-05 17:30       ` Greg KH
2009-02-04 18:46   ` [patch 31/41] ACPICA: Fix wrong resource descriptor length for 64-bit build Greg KH
2009-02-04 18:46   ` [patch 32/41] asus-laptop: Add support for P30/P35 Greg KH
2009-02-04 18:46   ` [patch 33/41] asus-laptop: Fix the led behavior with value > 1 Greg KH
2009-02-10 20:24     ` Pavel Machek
2009-02-10 20:57       ` Greg KH
2009-02-12  8:58         ` Pavel Machek
2009-02-12  9:15           ` Corentin Chary
2009-02-04 18:46   ` [patch 34/41] video: always update the brightness when poking "brightness" Greg KH
2009-02-04 18:46   ` [patch 35/41] dont load asus-acpi if model is not supported Greg KH
2009-02-04 18:47   ` [patch 36/41] Newly inserted battery might differ from one just removed, so Greg KH
2009-02-04 18:47   ` [patch 37/41] ACPI: Do not modify SCI_EN directly Greg KH
2009-02-04 18:47   ` [patch 38/41] ACPI suspend: Blacklist HP xw4600 Workstation for old code ordering Greg KH
2009-02-04 18:47   ` [patch 39/41] dlm: initialize file_lock struct in GETLK before copying conflicting lock Greg KH
2009-02-04 18:47   ` [patch 40/41] sata_mv: Fix chip type for Hightpoint RocketRaid 1740/1742 Greg KH
2009-02-04 18:47   ` [patch 41/41] ACPICA: Allow multiple backslash prefix in namepaths Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090204184610.GL25246@kroah.com \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=cavokz@gmail.com \
    --cc=cebbert@redhat.com \
    --cc=chuckw@quantumlinux.com \
    --cc=davej@redhat.com \
    --cc=davem@davemloft.net \
    --cc=eteo@redhat.com \
    --cc=jake@lwn.net \
    --cc=jesse.brandeburg@intel.com \
    --cc=jmforbes@linuxtx.org \
    --cc=kaber@trash.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkrufky@linuxtv.org \
    --cc=rbranco@la.checkpoint.com \
    --cc=rdunlap@xenotime.net \
    --cc=reviews@ml.cw.f00f.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=w@1wt.eu \
    --cc=zwane@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox