fix stats in __ip_conntrack_confirm
Subsystems (2)
PATCH 1/1 fix stats in __ip_conntrack_confirm
Hi,
I've been discussing this with Eric. __ip_conntrack_confirm is entered from both process context and net_rx_softirq context and "++" operations aren't atomic.
So net_rx_softirq can preempt the calling process while incrementing the stats. I think that we can fix this moving both CONNTRACK_STAT_INC to the locked section.
regards,
Pablo
Signed-off-by Pablo Neira Ayuso <[email protected]>
===== net/ipv4/netfilter/ip_conntrack_core.c 1.62 vs edited =====
net/ipv4/netfilter/ip_conntrack_core.c +3 -2
@@ -490,13 +490,14 @@add_timer (&ct->timeout);atomic_inc (&ct->ct_general.use);set_bit (IPS_CONFIRMED_BIT , &ct->status); -WRITE_UNLOCK (&ip_conntrack_lock);CONNTRACK_STAT_INC (insert); +WRITE_UNLOCK (&ip_conntrack_lock);return NF_ACCEPT ; } -WRITE_UNLOCK (&ip_conntrack_lock);CONNTRACK_STAT_INC (insert_failed); +WRITE_UNLOCK (&ip_conntrack_lock); +return NF_DROP ; }
Patrick McHardy
AppliedQuoted 3 lines · Pablo Neira
So
net_rx_softirqcan preempt the calling process while incrementing the stats. I think that we can fix this moving bothCONNTRACK_STAT_INCto the locked section.
Applied, thanks Pablo.
Regards
Patrick