Skip to content

Commit 21aa0a0

Browse files
Phil Sutterummakynes
authored andcommitted
netfilter: nf_tables: Introduce nft_register_flowtable_ops()
Facilitate binding and registering of a flowtable hook via a single function call. Signed-off-by: Phil Sutter <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent e225376 commit 21aa0a0

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8929,6 +8929,26 @@ static void nft_unregister_flowtable_net_hooks(struct net *net,
89298929
__nft_unregister_flowtable_net_hooks(net, flowtable, hook_list, false);
89308930
}
89318931

8932+
static int nft_register_flowtable_ops(struct net *net,
8933+
struct nft_flowtable *flowtable,
8934+
struct nf_hook_ops *ops)
8935+
{
8936+
int err;
8937+
8938+
err = flowtable->data.type->setup(&flowtable->data,
8939+
ops->dev, FLOW_BLOCK_BIND);
8940+
if (err < 0)
8941+
return err;
8942+
8943+
err = nf_register_net_hook(net, ops);
8944+
if (!err)
8945+
return 0;
8946+
8947+
flowtable->data.type->setup(&flowtable->data,
8948+
ops->dev, FLOW_BLOCK_UNBIND);
8949+
return err;
8950+
}
8951+
89328952
static int nft_register_flowtable_net_hooks(struct net *net,
89338953
struct nft_table *table,
89348954
struct list_head *hook_list,
@@ -8949,20 +8969,10 @@ static int nft_register_flowtable_net_hooks(struct net *net,
89498969
}
89508970
}
89518971

8952-
err = flowtable->data.type->setup(&flowtable->data,
8953-
hook->ops.dev,
8954-
FLOW_BLOCK_BIND);
8972+
err = nft_register_flowtable_ops(net, flowtable, &hook->ops);
89558973
if (err < 0)
89568974
goto err_unregister_net_hooks;
89578975

8958-
err = nf_register_net_hook(net, &hook->ops);
8959-
if (err < 0) {
8960-
flowtable->data.type->setup(&flowtable->data,
8961-
hook->ops.dev,
8962-
FLOW_BLOCK_UNBIND);
8963-
goto err_unregister_net_hooks;
8964-
}
8965-
89668976
i++;
89678977
}
89688978

0 commit comments

Comments
 (0)