* [PATCH nf-next 1/2] netfilter: nf_tables_offload: move indirect flow_block callback logic to core
@ 2019-09-02 21:11 Pablo Neira Ayuso
2019-09-02 21:11 ` [PATCH nf-next 2/2] netfilter: nf_tables_offload: save one indent level in nft_indr_block_cb() Pablo Neira Ayuso
2019-09-08 16:23 ` [PATCH nf-next 1/2] netfilter: nf_tables_offload: move indirect flow_block callback logic to core Pablo Neira Ayuso
0 siblings, 2 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2019-09-02 21:11 UTC (permalink / raw)
To: netfilter-devel; +Cc: wenxu
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 <pablo@netfilter.org>
---
include/net/netfilter/nf_tables_offload.h | 3 +++
net/netfilter/nf_tables_api.c | 10 +++-------
net/netfilter/nf_tables_offload.c | 22 ++++++++++++++++++----
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/include/net/netfilter/nf_tables_offload.h b/include/net/netfilter/nf_tables_offload.h
index db104665a9e4..643152f4aef7 100644
--- a/include/net/netfilter/nf_tables_offload.h
+++ b/include/net/netfilter/nf_tables_offload.h
@@ -80,4 +80,7 @@ void nft_indr_block_get_and_ing_cmd(struct net_device *dev,
int nft_chain_offload_priority(struct nft_base_chain *basechain);
+void nft_offload_init(void);
+void nft_offload_exit(void);
+
#endif
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 6d00bef023c4..5ad60ffe027a 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -7602,11 +7602,6 @@ static struct pernet_operations nf_tables_net_ops = {
.exit = nf_tables_exit_net,
};
-static struct flow_indr_block_ing_entry block_ing_entry = {
- .cb = nft_indr_block_get_and_ing_cmd,
- .list = LIST_HEAD_INIT(block_ing_entry.list),
-};
-
static int __init nf_tables_module_init(void)
{
int err;
@@ -7638,7 +7633,8 @@ static int __init nf_tables_module_init(void)
goto err5;
nft_chain_route_init();
- flow_indr_add_block_ing_cb(&block_ing_entry);
+ nft_offload_init();
+
return err;
err5:
rhltable_destroy(&nft_objname_ht);
@@ -7655,7 +7651,7 @@ static int __init nf_tables_module_init(void)
static void __exit nf_tables_module_exit(void)
{
- flow_indr_del_block_ing_cb(&block_ing_entry);
+ nft_offload_exit();
nfnetlink_subsys_unregister(&nf_tables_subsys);
unregister_netdevice_notifier(&nf_tables_flowtable_notifier);
nft_chain_filter_fini();
diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
index d7c25c1ff66e..1e69bd7f9fe1 100644
--- a/net/netfilter/nf_tables_offload.c
+++ b/net/netfilter/nf_tables_offload.c
@@ -352,10 +352,9 @@ int nft_flow_rule_offload_commit(struct net *net)
return err;
}
-void nft_indr_block_get_and_ing_cmd(struct net_device *dev,
- flow_indr_block_bind_cb_t *cb,
- void *cb_priv,
- enum flow_block_command command)
+static void nft_indr_block_cb(struct net_device *dev,
+ flow_indr_block_bind_cb_t *cb, void *cb_priv,
+ enum flow_block_command command)
{
struct net *net = dev_net(dev);
const struct nft_table *table;
@@ -381,3 +380,18 @@ void nft_indr_block_get_and_ing_cmd(struct net_device *dev,
}
}
}
+
+static struct flow_indr_block_ing_entry block_ing_entry = {
+ .cb = nft_indr_block_cb,
+ .list = LIST_HEAD_INIT(block_ing_entry.list),
+};
+
+void nft_offload_init(void)
+{
+ flow_indr_add_block_ing_cb(&block_ing_entry);
+}
+
+void nft_offload_exit(void)
+{
+ flow_indr_del_block_ing_cb(&block_ing_entry);
+}
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH nf-next 2/2] netfilter: nf_tables_offload: save one indent level in nft_indr_block_cb()
2019-09-02 21:11 [PATCH nf-next 1/2] netfilter: nf_tables_offload: move indirect flow_block callback logic to core Pablo Neira Ayuso
@ 2019-09-02 21:11 ` Pablo Neira Ayuso
2019-09-08 16:23 ` [PATCH nf-next 1/2] netfilter: nf_tables_offload: move indirect flow_block callback logic to core Pablo Neira Ayuso
1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2019-09-02 21:11 UTC (permalink / raw)
To: netfilter-devel; +Cc: wenxu
Save one indent level in the nft_indr_block_cb() loop.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_offload.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
index 1e69bd7f9fe1..b2f169be2a37 100644
--- a/net/netfilter/nf_tables_offload.c
+++ b/net/netfilter/nf_tables_offload.c
@@ -354,8 +354,9 @@ int nft_flow_rule_offload_commit(struct net *net)
static void nft_indr_block_cb(struct net_device *dev,
flow_indr_block_bind_cb_t *cb, void *cb_priv,
- enum flow_block_command command)
+ enum flow_block_command cmd)
{
+ struct nft_base_chain *basechain;
struct net *net = dev_net(dev);
const struct nft_table *table;
const struct nft_chain *chain;
@@ -365,18 +366,15 @@ static void nft_indr_block_cb(struct net_device *dev,
continue;
list_for_each_entry_rcu(chain, &table->chains, list) {
- if (nft_is_base_chain(chain)) {
- struct nft_base_chain *basechain;
-
- basechain = nft_base_chain(chain);
- if (!strncmp(basechain->dev_name, dev->name,
- IFNAMSIZ)) {
- nft_indr_block_ing_cmd(dev, basechain,
- cb, cb_priv,
- command);
- return;
- }
- }
+ if (!nft_is_base_chain(chain))
+ continue;
+
+ basechain = nft_base_chain(chain);
+ if (strncmp(basechain->dev_name, dev->name, IFNAMSIZ))
+ continue;
+
+ nft_indr_block_ing_cmd(dev, basechain, cb, cb_priv, cmd);
+ return;
}
}
}
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH nf-next 1/2] netfilter: nf_tables_offload: move indirect flow_block callback logic to core
2019-09-02 21:11 [PATCH nf-next 1/2] netfilter: nf_tables_offload: move indirect flow_block callback logic to core Pablo Neira Ayuso
2019-09-02 21:11 ` [PATCH nf-next 2/2] netfilter: nf_tables_offload: save one indent level in nft_indr_block_cb() Pablo Neira Ayuso
@ 2019-09-08 16:23 ` Pablo Neira Ayuso
1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2019-09-08 16:23 UTC (permalink / raw)
To: netfilter-devel; +Cc: wenxu
On Mon, Sep 02, 2019 at 11:11:31PM +0200, Pablo Neira Ayuso wrote:
> 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().
I have applied this patch.
I'm going to keep back 2/2, so you can use __nft_offload_get_chain()
to fix nft_indr_block_cb() in one go.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-08 16:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-02 21:11 [PATCH nf-next 1/2] netfilter: nf_tables_offload: move indirect flow_block callback logic to core Pablo Neira Ayuso
2019-09-02 21:11 ` [PATCH nf-next 2/2] netfilter: nf_tables_offload: save one indent level in nft_indr_block_cb() Pablo Neira Ayuso
2019-09-08 16:23 ` [PATCH nf-next 1/2] netfilter: nf_tables_offload: move indirect flow_block callback logic to core Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).