Skip to content

Commit

Permalink
netfilter: nf_tables: add nft_flowtable_hooks_destroy()
Browse files Browse the repository at this point in the history
This patch adds a helper function destroy the flowtable hooks.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Pablo Neira Ayuso committed May 27, 2020
1 parent f938266 commit 389a2cb
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions net/netfilter/nf_tables_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -6339,6 +6339,16 @@ static int nft_register_flowtable_net_hooks(struct net *net,
return err;
}

static void nft_flowtable_hooks_destroy(struct list_head *hook_list)
{
struct nft_hook *hook, *next;

list_for_each_entry_safe(hook, next, hook_list, list) {
list_del_rcu(&hook->list);
kfree_rcu(hook, rcu);
}
}

static int nf_tables_newflowtable(struct net *net, struct sock *nlsk,
struct sk_buff *skb,
const struct nlmsghdr *nlh,
Expand Down Expand Up @@ -6433,10 +6443,7 @@ static int nf_tables_newflowtable(struct net *net, struct sock *nlsk,
&flowtable->hook_list,
flowtable);
if (err < 0) {
list_for_each_entry_safe(hook, next, &flowtable->hook_list, list) {
list_del_rcu(&hook->list);
kfree_rcu(hook, rcu);
}
nft_flowtable_hooks_destroy(&flowtable->hook_list);
goto err4;
}

Expand Down

0 comments on commit 389a2cb

Please sign in to comment.