summaryrefslogtreecommitdiffstats
path: root/net-ebtables-Work-around-per-cpu-assumptions.patch
blob: 552cd26e57000d90b97097d742a1a2b8c6a4767d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From da28556e0ab3bcdc550d6b2b975d0f6e8d2198ff Mon Sep 17 00:00:00 2001
From: Luis Claudio R. Goncalves <lclaudio@uudg.org>
Date: Sat, 27 Nov 2010 13:04:05 -0200
Subject: [PATCH] net: ebtables: Work around per cpu assumptions

commit a1026af461530b4f0a875c4bdffac4137b2db549 in tip.

I have been seeing several variations of this BUG message:

  BUG: using smp_processor_id() in preemptible [00000000] code: ...
  caller is ebt_do_table+0x94/0x60c [ebtables]

Disable preemption while fetching and using the ID of the current CPU.

Signed-off-by: "Luis Claudio R. Goncalves" <lclaudio@uudg.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 net/bridge/netfilter/ebtables.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index f0865fd..2f566fd 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -177,7 +177,7 @@ unsigned int ebt_do_table (unsigned int hook, struct sk_buff *skb,
    const struct net_device *in, const struct net_device *out,
    struct ebt_table *table)
 {
-	int i, nentries;
+	int i, nentries, cpu;
 	struct ebt_entry *point;
 	struct ebt_counter *counter_base, *cb_base;
 	const struct ebt_entry_target *t;
@@ -198,12 +198,14 @@ unsigned int ebt_do_table (unsigned int hook, struct sk_buff *skb,
 
 	read_lock_bh(&table->lock);
 	private = table->private;
-	cb_base = COUNTER_BASE(private->counters, private->nentries,
-	   smp_processor_id());
+	preempt_disable_rt();
+	cpu = smp_processor_id();
+	cb_base = COUNTER_BASE(private->counters, private->nentries, cpu);
 	if (private->chainstack)
-		cs = private->chainstack[smp_processor_id()];
+		cs = private->chainstack[cpu];
 	else
 		cs = NULL;
+	preempt_enable_rt();
 	chaininfo = private->hook_entry[hook];
 	nentries = private->hook_entry[hook]->nentries;
 	point = (struct ebt_entry *)(private->hook_entry[hook]->data);
-- 
1.7.0.4