mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
netfilter: convert hook list to an array
This converts the storage and layout of netfilter hook entries from a linked list to an array. After this commit, hook entries will be stored adjacent in memory. The next pointer is no longer required. The ops pointers are stored at the end of the array as they are only used in the register/unregister path and in the legacy br_netfilter code. nf_unregister_net_hooks() is slower than needed as it just calls nf_unregister_net_hook in a loop (i.e. at least n synchronize_net() calls), this will be addressed in followup patch. Test setup: - ixgbe 10gbit - netperf UDP_STREAM, 64 byte packets - 5 hooks: (raw + mangle prerouting, mangle+filter input, inet filter): empty mangle and raw prerouting, mangle and filter input hooks: 353.9 this patch: 364.2 Signed-off-by: Aaron Conole <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
This commit is contained in:
parent
5fd02ebe65
commit
960632ece6
9 changed files with 307 additions and 134 deletions
|
|
@ -985,22 +985,25 @@ int br_nf_hook_thresh(unsigned int hook, struct net *net,
|
|||
int (*okfn)(struct net *, struct sock *,
|
||||
struct sk_buff *))
|
||||
{
|
||||
struct nf_hook_entry *elem;
|
||||
const struct nf_hook_entries *e;
|
||||
struct nf_hook_state state;
|
||||
struct nf_hook_ops **ops;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
for (elem = rcu_dereference(net->nf.hooks[NFPROTO_BRIDGE][hook]);
|
||||
elem && nf_hook_entry_priority(elem) <= NF_BR_PRI_BRNF;
|
||||
elem = rcu_dereference(elem->next))
|
||||
;
|
||||
|
||||
if (!elem)
|
||||
e = rcu_dereference(net->nf.hooks[NFPROTO_BRIDGE][hook]);
|
||||
if (!e)
|
||||
return okfn(net, sk, skb);
|
||||
|
||||
ops = nf_hook_entries_get_hook_ops(e);
|
||||
for (i = 0; i < e->num_hook_entries &&
|
||||
ops[i]->priority <= NF_BR_PRI_BRNF; i++)
|
||||
;
|
||||
|
||||
nf_hook_state_init(&state, hook, NFPROTO_BRIDGE, indev, outdev,
|
||||
sk, net, okfn);
|
||||
|
||||
ret = nf_hook_slow(skb, &state, elem);
|
||||
ret = nf_hook_slow(skb, &state, e, i);
|
||||
if (ret == 1)
|
||||
ret = okfn(net, sk, skb);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue