diff options
author | Aaron Conole <aconole@bytheb.org> | 2016-11-15 17:48:44 -0500 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-12-06 21:42:15 +0100 |
commit | 0aa8c57a04907a5d02068ff9f917629be97ea78d (patch) | |
tree | 80da65fdc51b442fc5aeddb99c60c3c32853e4dc /net/netfilter | |
parent | 834184b1f3a4635efbdfdae5fb437f109f6605fa (diff) | |
download | linux-0aa8c57a04907a5d02068ff9f917629be97ea78d.tar.gz linux-0aa8c57a04907a5d02068ff9f917629be97ea78d.tar.bz2 linux-0aa8c57a04907a5d02068ff9f917629be97ea78d.zip |
netfilter: introduce accessor functions for hook entries
This allows easier future refactoring.
Signed-off-by: Aaron Conole <aconole@bytheb.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/core.c | 10 | ||||
-rw-r--r-- | net/netfilter/nf_queue.c | 5 |
2 files changed, 6 insertions, 9 deletions
diff --git a/net/netfilter/core.c b/net/netfilter/core.c index de30e08d58f2..2bb46e2d8d30 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c @@ -102,15 +102,13 @@ int nf_register_net_hook(struct net *net, const struct nf_hook_ops *reg) if (!entry) return -ENOMEM; - entry->orig_ops = reg; - entry->ops = *reg; - entry->next = NULL; + nf_hook_entry_init(entry, reg); mutex_lock(&nf_hook_mutex); /* Find the spot in the list */ while ((p = nf_entry_dereference(*pp)) != NULL) { - if (reg->priority < p->orig_ops->priority) + if (reg->priority < nf_hook_entry_priority(p)) break; pp = &p->next; } @@ -140,7 +138,7 @@ void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *reg) mutex_lock(&nf_hook_mutex); while ((p = nf_entry_dereference(*pp)) != NULL) { - if (p->orig_ops == reg) { + if (nf_hook_entry_ops(p) == reg) { rcu_assign_pointer(*pp, p->next); break; } @@ -311,7 +309,7 @@ int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state, int ret; do { - verdict = entry->ops.hook(entry->ops.priv, skb, state); + verdict = nf_hook_entry_hookfn(entry, skb, state); switch (verdict & NF_VERDICT_MASK) { case NF_ACCEPT: entry = rcu_dereference(entry->next); diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c index 77cba9f6ccb6..4a7662486f44 100644 --- a/net/netfilter/nf_queue.c +++ b/net/netfilter/nf_queue.c @@ -185,7 +185,7 @@ static unsigned int nf_iterate(struct sk_buff *skb, do { repeat: - verdict = (*entryp)->ops.hook((*entryp)->ops.priv, skb, state); + verdict = nf_hook_entry_hookfn((*entryp), skb, state); if (verdict != NF_ACCEPT) { if (verdict != NF_REPEAT) return verdict; @@ -200,7 +200,6 @@ repeat: void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict) { struct nf_hook_entry *hook_entry = entry->hook; - struct nf_hook_ops *elem = &hook_entry->ops; struct sk_buff *skb = entry->skb; const struct nf_afinfo *afinfo; int err; @@ -209,7 +208,7 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict) /* Continue traversal iff userspace said ok... */ if (verdict == NF_REPEAT) - verdict = elem->hook(elem->priv, skb, &entry->state); + verdict = nf_hook_entry_hookfn(hook_entry, skb, &entry->state); if (verdict == NF_ACCEPT) { afinfo = nf_get_afinfo(entry->state.pf); |