@@ -111,28 +111,17 @@ struct nf_hook_entry {
void *priv;
};
-struct nf_hook_entries_rcu_head {
- struct rcu_head head;
- void *allocation;
-};
-
struct nf_hook_entries {
u16 num_hook_entries;
+ struct rcu_head rcu;
/* padding */
struct nf_hook_entry hooks[];
/* trailer: pointers to original orig_ops of each hook,
- * followed by rcu_head and scratch space used for freeing
- * the structure via call_rcu.
*
* This is not part of struct nf_hook_entry since its only
* needed in slow path (hook register/unregister):
* const struct nf_hook_ops *orig_ops[]
- *
- * For the same reason, we store this at end -- its
- * only needed when a hook is deleted, not during
- * packet path processing:
- * struct nf_hook_entries_rcu_head head
*/
};
@@ -52,8 +52,7 @@ static struct nf_hook_entries *allocate_hook_entries_size(u16 num)
struct nf_hook_entries *e;
size_t alloc = sizeof(*e) +
sizeof(struct nf_hook_entry) * num +
- sizeof(struct nf_hook_ops *) * num +
- sizeof(struct nf_hook_entries_rcu_head);
+ sizeof(struct nf_hook_ops *) * num;
if (num == 0)
return NULL;
@@ -64,28 +63,12 @@ static struct nf_hook_entries *allocate_hook_entries_size(u16 num)
return e;
}
-static void __nf_hook_entries_free(struct rcu_head *h)
-{
- struct nf_hook_entries_rcu_head *head;
-
- head = container_of(h, struct nf_hook_entries_rcu_head, head);
- kvfree(head->allocation);
-}
-
static void nf_hook_entries_free(struct nf_hook_entries *e)
{
- struct nf_hook_entries_rcu_head *head;
- struct nf_hook_ops **ops;
- unsigned int num;
-
if (!e)
return;
- num = e->num_hook_entries;
- ops = nf_hook_entries_get_hook_ops(e);
- head = (void *)&ops[num];
- head->allocation = e;
- call_rcu(&head->head, __nf_hook_entries_free);
+ kvfree_rcu(e, rcu);
}
static unsigned int accept_all(void *priv,