]>
Commit | Line | Data |
---|---|---|
bcd4f083 GKH |
1 | From jesse@nicira.com Tue Dec 7 11:49:39 2010 |
2 | From: Jesse Gross <jesse@nicira.com> | |
3 | Date: Mon, 8 Nov 2010 13:23:01 -0800 | |
4 | Subject: [stable] [PATCH 2.6.36 stable] vlan: Avoid hwaccel vlan packets when vid not used. | |
5 | To: stable@kernel.org | |
6 | Cc: netdev@vger.kernel.org, David Miller <davem@davemloft.net> | |
7 | Message-ID: <1289251381-6671-1-git-send-email-jesse@nicira.com> | |
8 | ||
9 | From: Jesse Gross <jesse@nicira.com> | |
10 | ||
11 | [This patch applies only to 2.6.36 stable. The problem was introduced | |
12 | in that release and is already fixed by larger changes to the vlan | |
13 | code in 2.6.37.] | |
14 | ||
15 | Normally hardware accelerated vlan packets are quickly dropped if | |
16 | there is no corresponding vlan device configured. The one exception | |
17 | is promiscuous mode, where we allow all of these packets through so | |
18 | they can be picked up by tcpdump. However, this behavior causes a | |
19 | crash if we actually try to receive these packets. This fixes that | |
20 | crash by ignoring packets with vids not corresponding to a configured | |
21 | device in the vlan hwaccel routines and then dropping them before they | |
22 | get to consumers in the network stack. | |
23 | ||
24 | ||
25 | Reported-by: Ben Greear <greearb@candelatech.com> | |
26 | Tested-by: Nikola Ciprich <extmaillist@linuxbox.cz> | |
27 | Signed-off-by: Jesse Gross <jesse@nicira.com> | |
28 | Acked-by: David Miller <davem@davemloft.net> | |
29 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
30 | ||
31 | --- | |
32 | net/8021q/vlan_core.c | 3 +++ | |
2d4e186d GKH |
33 | net/core/dev.c | 10 ++++++++++ |
34 | 2 files changed, 13 insertions(+) | |
bcd4f083 GKH |
35 | |
36 | --- a/net/8021q/vlan_core.c | |
37 | +++ b/net/8021q/vlan_core.c | |
38 | @@ -43,6 +43,9 @@ int vlan_hwaccel_do_receive(struct sk_bu | |
39 | struct net_device *dev = skb->dev; | |
40 | struct vlan_rx_stats *rx_stats; | |
41 | ||
42 | + if (unlikely(!is_vlan_dev(dev))) | |
43 | + return 0; | |
44 | + | |
45 | skb->dev = vlan_dev_info(dev)->real_dev; | |
46 | netif_nit_deliver(skb); | |
47 | ||
48 | --- a/net/core/dev.c | |
49 | +++ b/net/core/dev.c | |
2d4e186d | 50 | @@ -2891,6 +2891,15 @@ static int __netif_receive_skb(struct sk |
bcd4f083 GKH |
51 | ncls: |
52 | #endif | |
53 | ||
54 | + /* If we got this far with a hardware accelerated VLAN tag, it means | |
55 | + * that we were put in promiscuous mode but nobody is interested in | |
2d4e186d | 56 | + * this vid. Drop the packet now to prevent it from getting propagated |
bcd4f083 GKH |
57 | + * to other parts of the stack that won't know how to deal with packets |
58 | + * tagged in this manner. | |
59 | + */ | |
2d4e186d GKH |
60 | + if (unlikely(vlan_tx_tag_present(skb))) |
61 | + goto bypass; | |
bcd4f083 GKH |
62 | + |
63 | /* Handle special case of bridge or macvlan */ | |
64 | rx_handler = rcu_dereference(skb->dev->rx_handler); | |
65 | if (rx_handler) { | |
2d4e186d GKH |
66 | @@ -2927,6 +2936,7 @@ ncls: |
67 | } | |
68 | } | |
69 | ||
70 | +bypass: | |
71 | if (pt_prev) { | |
72 | ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev); | |
73 | } else { |