Skip to content

Commit 3474a2c

Browse files
committed
netfilter: nf_tables_offload: move indirect flow_block callback logic to core
Add nft_offload_init() and nft_offload_exit() function to deal with the init and the exit path of the offload infrastructure. Rename nft_indr_block_get_and_ing_cmd() to nft_indr_block_cb(). Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent b44492a commit 3474a2c

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

include/net/netfilter/nf_tables_offload.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ struct nft_rule;
6464
struct nft_flow_rule *nft_flow_rule_create(const struct nft_rule *rule);
6565
void nft_flow_rule_destroy(struct nft_flow_rule *flow);
6666
int nft_flow_rule_offload_commit(struct net *net);
67-
void nft_indr_block_get_and_ing_cmd(struct net_device *dev,
68-
flow_indr_block_bind_cb_t *cb,
69-
void *cb_priv,
70-
enum flow_block_command command);
7167

7268
#define NFT_OFFLOAD_MATCH(__key, __base, __field, __len, __reg) \
7369
(__reg)->base_offset = \
@@ -80,4 +76,7 @@ void nft_indr_block_get_and_ing_cmd(struct net_device *dev,
8076

8177
int nft_chain_offload_priority(struct nft_base_chain *basechain);
8278

79+
void nft_offload_init(void);
80+
void nft_offload_exit(void);
81+
8382
#endif

net/netfilter/nf_tables_api.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7669,11 +7669,6 @@ static struct pernet_operations nf_tables_net_ops = {
76697669
.exit = nf_tables_exit_net,
76707670
};
76717671

7672-
static struct flow_indr_block_ing_entry block_ing_entry = {
7673-
.cb = nft_indr_block_get_and_ing_cmd,
7674-
.list = LIST_HEAD_INIT(block_ing_entry.list),
7675-
};
7676-
76777672
static int __init nf_tables_module_init(void)
76787673
{
76797674
int err;
@@ -7705,7 +7700,8 @@ static int __init nf_tables_module_init(void)
77057700
goto err5;
77067701

77077702
nft_chain_route_init();
7708-
flow_indr_add_block_ing_cb(&block_ing_entry);
7703+
nft_offload_init();
7704+
77097705
return err;
77107706
err5:
77117707
rhltable_destroy(&nft_objname_ht);
@@ -7722,7 +7718,7 @@ static int __init nf_tables_module_init(void)
77227718

77237719
static void __exit nf_tables_module_exit(void)
77247720
{
7725-
flow_indr_del_block_ing_cb(&block_ing_entry);
7721+
nft_offload_exit();
77267722
nfnetlink_subsys_unregister(&nf_tables_subsys);
77277723
unregister_netdevice_notifier(&nf_tables_flowtable_notifier);
77287724
nft_chain_filter_fini();

net/netfilter/nf_tables_offload.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,9 @@ int nft_flow_rule_offload_commit(struct net *net)
354354
return err;
355355
}
356356

357-
void nft_indr_block_get_and_ing_cmd(struct net_device *dev,
358-
flow_indr_block_bind_cb_t *cb,
359-
void *cb_priv,
360-
enum flow_block_command command)
357+
static void nft_indr_block_cb(struct net_device *dev,
358+
flow_indr_block_bind_cb_t *cb, void *cb_priv,
359+
enum flow_block_command command)
361360
{
362361
struct net *net = dev_net(dev);
363362
const struct nft_table *table;
@@ -383,3 +382,18 @@ void nft_indr_block_get_and_ing_cmd(struct net_device *dev,
383382
}
384383
}
385384
}
385+
386+
static struct flow_indr_block_ing_entry block_ing_entry = {
387+
.cb = nft_indr_block_cb,
388+
.list = LIST_HEAD_INIT(block_ing_entry.list),
389+
};
390+
391+
void nft_offload_init(void)
392+
{
393+
flow_indr_add_block_ing_cb(&block_ing_entry);
394+
}
395+
396+
void nft_offload_exit(void)
397+
{
398+
flow_indr_del_block_ing_cb(&block_ing_entry);
399+
}

0 commit comments

Comments
 (0)