mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
[NETFILTER]: nf_conntrack: use RCU for conntrack hash
Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
7d0742da1c
commit
76507f69c4
6 changed files with 73 additions and 43 deletions
|
|
@ -39,12 +39,14 @@ struct ct_iter_state {
|
|||
static struct hlist_node *ct_get_first(struct seq_file *seq)
|
||||
{
|
||||
struct ct_iter_state *st = seq->private;
|
||||
struct hlist_node *n;
|
||||
|
||||
for (st->bucket = 0;
|
||||
st->bucket < nf_conntrack_htable_size;
|
||||
st->bucket++) {
|
||||
if (!hlist_empty(&nf_conntrack_hash[st->bucket]))
|
||||
return nf_conntrack_hash[st->bucket].first;
|
||||
n = rcu_dereference(nf_conntrack_hash[st->bucket].first);
|
||||
if (n)
|
||||
return n;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -54,11 +56,11 @@ static struct hlist_node *ct_get_next(struct seq_file *seq,
|
|||
{
|
||||
struct ct_iter_state *st = seq->private;
|
||||
|
||||
head = head->next;
|
||||
head = rcu_dereference(head->next);
|
||||
while (head == NULL) {
|
||||
if (++st->bucket >= nf_conntrack_htable_size)
|
||||
return NULL;
|
||||
head = nf_conntrack_hash[st->bucket].first;
|
||||
head = rcu_dereference(nf_conntrack_hash[st->bucket].first);
|
||||
}
|
||||
return head;
|
||||
}
|
||||
|
|
@ -74,8 +76,9 @@ static struct hlist_node *ct_get_idx(struct seq_file *seq, loff_t pos)
|
|||
}
|
||||
|
||||
static void *ct_seq_start(struct seq_file *seq, loff_t *pos)
|
||||
__acquires(RCU)
|
||||
{
|
||||
read_lock_bh(&nf_conntrack_lock);
|
||||
rcu_read_lock();
|
||||
return ct_get_idx(seq, *pos);
|
||||
}
|
||||
|
||||
|
|
@ -86,8 +89,9 @@ static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
|
|||
}
|
||||
|
||||
static void ct_seq_stop(struct seq_file *s, void *v)
|
||||
__releases(RCU)
|
||||
{
|
||||
read_unlock_bh(&nf_conntrack_lock);
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static int ct_seq_show(struct seq_file *s, void *v)
|
||||
|
|
@ -226,6 +230,7 @@ static struct hlist_node *ct_expect_get_idx(struct seq_file *seq, loff_t pos)
|
|||
}
|
||||
|
||||
static void *exp_seq_start(struct seq_file *seq, loff_t *pos)
|
||||
__acquires(RCU)
|
||||
{
|
||||
rcu_read_lock();
|
||||
return ct_expect_get_idx(seq, *pos);
|
||||
|
|
@ -238,6 +243,7 @@ static void *exp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
|||
}
|
||||
|
||||
static void exp_seq_stop(struct seq_file *seq, void *v)
|
||||
__releases(RCU)
|
||||
{
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue