Skip to content

Commit 26888df

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: core: remove synchronize_net call if nfqueue is used
since commit 960632e ("netfilter: convert hook list to an array") nfqueue no longer stores a pointer to the hook that caused the packet to be queued. Therefore no extra synchronize_net() call is needed after dropping the packets enqueued by the old rule blob. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 4e645b4 commit 26888df

File tree

5 files changed

+7
-19
lines changed

5 files changed

+7
-19
lines changed

include/net/netfilter/nf_queue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct nf_queue_entry {
2525
struct nf_queue_handler {
2626
int (*outfn)(struct nf_queue_entry *entry,
2727
unsigned int queuenum);
28-
unsigned int (*nf_hook_drop)(struct net *net);
28+
void (*nf_hook_drop)(struct net *net);
2929
};
3030

3131
void nf_register_queue_handler(struct net *net, const struct nf_queue_handler *qh);

net/netfilter/core.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *reg)
341341
{
342342
struct nf_hook_entries __rcu **pp;
343343
struct nf_hook_entries *p;
344-
unsigned int nfq;
345344

346345
pp = nf_hook_entry_head(net, reg);
347346
if (!pp)
@@ -364,10 +363,7 @@ void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *reg)
364363

365364
synchronize_net();
366365

367-
/* other cpu might still process nfqueue verdict that used reg */
368-
nfq = nf_queue_nf_hook_drop(net);
369-
if (nfq)
370-
synchronize_net();
366+
nf_queue_nf_hook_drop(net);
371367
kvfree(p);
372368
}
373369
EXPORT_SYMBOL(nf_unregister_net_hook);

net/netfilter/nf_internals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
int nf_queue(struct sk_buff *skb, struct nf_hook_state *state,
1111
const struct nf_hook_entries *entries, unsigned int index,
1212
unsigned int verdict);
13-
unsigned int nf_queue_nf_hook_drop(struct net *net);
13+
void nf_queue_nf_hook_drop(struct net *net);
1414

1515
/* nf_log.c */
1616
int __init netfilter_log_init(void);

net/netfilter/nf_queue.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,15 @@ void nf_queue_entry_get_refs(struct nf_queue_entry *entry)
9696
}
9797
EXPORT_SYMBOL_GPL(nf_queue_entry_get_refs);
9898

99-
unsigned int nf_queue_nf_hook_drop(struct net *net)
99+
void nf_queue_nf_hook_drop(struct net *net)
100100
{
101101
const struct nf_queue_handler *qh;
102-
unsigned int count = 0;
103102

104103
rcu_read_lock();
105104
qh = rcu_dereference(net->nf.queue_handler);
106105
if (qh)
107-
count = qh->nf_hook_drop(net);
106+
qh->nf_hook_drop(net);
108107
rcu_read_unlock();
109-
110-
return count;
111108
}
112109
EXPORT_SYMBOL_GPL(nf_queue_nf_hook_drop);
113110

net/netfilter/nfnetlink_queue.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -941,23 +941,18 @@ static struct notifier_block nfqnl_dev_notifier = {
941941
.notifier_call = nfqnl_rcv_dev_event,
942942
};
943943

944-
static unsigned int nfqnl_nf_hook_drop(struct net *net)
944+
static void nfqnl_nf_hook_drop(struct net *net)
945945
{
946946
struct nfnl_queue_net *q = nfnl_queue_pernet(net);
947-
unsigned int instances = 0;
948947
int i;
949948

950949
for (i = 0; i < INSTANCE_BUCKETS; i++) {
951950
struct nfqnl_instance *inst;
952951
struct hlist_head *head = &q->instance_table[i];
953952

954-
hlist_for_each_entry_rcu(inst, head, hlist) {
953+
hlist_for_each_entry_rcu(inst, head, hlist)
955954
nfqnl_flush(inst, NULL, 0);
956-
instances++;
957-
}
958955
}
959-
960-
return instances;
961956
}
962957

963958
static int

0 commit comments

Comments
 (0)