Skip to content

Commit d415b9e

Browse files
apconoleummakynes
authored andcommitted
netfilter: decouple nf_hook_entry and nf_hook_ops
During nfhook traversal we only need a very small subset of nf_hook_ops members. We need: - next element - hook function to call - hook function priv argument Bridge netfilter also needs 'thresh'; can be obtained via ->orig_ops. nf_hook_entry struct is now 32 bytes on x86_64. A followup patch will turn the run-time list into an array that only stores hook functions plus their priv arguments, eliminating the ->next element. Suggested-by: Florian Westphal <[email protected]> Signed-off-by: Aaron Conole <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 0aa8c57 commit d415b9e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/linux/netfilter.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,29 +75,31 @@ struct nf_hook_ops {
7575

7676
struct nf_hook_entry {
7777
struct nf_hook_entry __rcu *next;
78-
struct nf_hook_ops ops;
78+
nf_hookfn *hook;
79+
void *priv;
7980
const struct nf_hook_ops *orig_ops;
8081
};
8182

8283
static inline void
8384
nf_hook_entry_init(struct nf_hook_entry *entry, const struct nf_hook_ops *ops)
8485
{
8586
entry->next = NULL;
86-
entry->ops = *ops;
87+
entry->hook = ops->hook;
88+
entry->priv = ops->priv;
8789
entry->orig_ops = ops;
8890
}
8991

9092
static inline int
9193
nf_hook_entry_priority(const struct nf_hook_entry *entry)
9294
{
93-
return entry->ops.priority;
95+
return entry->orig_ops->priority;
9496
}
9597

9698
static inline int
9799
nf_hook_entry_hookfn(const struct nf_hook_entry *entry, struct sk_buff *skb,
98100
struct nf_hook_state *state)
99101
{
100-
return entry->ops.hook(entry->ops.priv, skb, state);
102+
return entry->hook(entry->priv, skb, state);
101103
}
102104

103105
static inline const struct nf_hook_ops *

0 commit comments

Comments
 (0)