Skip to content

Commit 001389b

Browse files
Eric Dumazetdavem330
authored andcommitted
netfilter: {ip,ip6,arp}_tables: avoid lockdep false positive
After commit 24b36f0 (netfilter: {ip,ip6,arp}_tables: dont block bottom half more than necessary), lockdep can raise a warning because we attempt to lock a spinlock with BH enabled, while the same lock is usually locked by another cpu in a softirq context. Disable again BH to avoid these lockdep warnings. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Diagnosed-by: David S. Miller <davem@davemloft.net> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5ca6f7c commit 001389b

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

net/ipv4/netfilter/arp_tables.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,13 +735,15 @@ static void get_counters(const struct xt_table_info *t,
735735
if (cpu == curcpu)
736736
continue;
737737
i = 0;
738+
local_bh_disable();
738739
xt_info_wrlock(cpu);
739740
xt_entry_foreach(iter, t->entries[cpu], t->size) {
740741
ADD_COUNTER(counters[i], iter->counters.bcnt,
741742
iter->counters.pcnt);
742743
++i;
743744
}
744745
xt_info_wrunlock(cpu);
746+
local_bh_enable();
745747
}
746748
put_cpu();
747749
}

net/ipv4/netfilter/ip_tables.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,13 +909,15 @@ get_counters(const struct xt_table_info *t,
909909
if (cpu == curcpu)
910910
continue;
911911
i = 0;
912+
local_bh_disable();
912913
xt_info_wrlock(cpu);
913914
xt_entry_foreach(iter, t->entries[cpu], t->size) {
914915
ADD_COUNTER(counters[i], iter->counters.bcnt,
915916
iter->counters.pcnt);
916917
++i; /* macro does multi eval of i */
917918
}
918919
xt_info_wrunlock(cpu);
920+
local_bh_enable();
919921
}
920922
put_cpu();
921923
}

net/ipv6/netfilter/ip6_tables.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,13 +922,15 @@ get_counters(const struct xt_table_info *t,
922922
if (cpu == curcpu)
923923
continue;
924924
i = 0;
925+
local_bh_disable();
925926
xt_info_wrlock(cpu);
926927
xt_entry_foreach(iter, t->entries[cpu], t->size) {
927928
ADD_COUNTER(counters[i], iter->counters.bcnt,
928929
iter->counters.pcnt);
929930
++i;
930931
}
931932
xt_info_wrunlock(cpu);
933+
local_bh_enable();
932934
}
933935
put_cpu();
934936
}

0 commit comments

Comments
 (0)