netfilter: nf_tables: check the bind callback failed and unbind callback if hook register failed
Subsystems (2)
PATCH 1/1 netfilter: nf_tables: check the bind callback failed and unbind callback if hook register failed
From: wenxu <[email protected]>
Undo the callback binding before unregistering the existing hooks. It also should check err of the bind setup call
---
This patch is based on:
http://patchwork.ozlabs.org/patch/1195539/
net/netfilter/nf_tables_api.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
net/netfilter/nf_tables_api.c +11 -3
@@ -6001,12 +6001,20 @@ static int nft_register_flowtable_net_hooks(struct net *net, } } - flowtable->data.type->setup (&flowtable->data, hook->ops.dev, -FLOW_BLOCK_BIND ); - err =nf_register_net_hook (net, &hook->ops); + err = flowtable->data.type->setup (&flowtable->data, + hook->ops.dev, +FLOW_BLOCK_BIND );if (err <0 ) goto err_unregister_net_hooks; + err =nf_register_net_hook (net, &hook->ops); +if (err <0 ) { + flowtable->data.type->setup (&flowtable->data, + hook->ops.dev, +FLOW_BLOCK_UNBIND ); + goto err_unregister_net_hooks; + } + i++; }
Signature · 1 line
1.8.3.1
Pablo Neira Ayuso
maintainerQuoted 10 lines · On Fri, Nov 15, 2019 at 07:21:26PM +0800, [email protected] wrote:
From: wenxu <[email protected]>
Undo the callback binding before unregistering the existing hooks. It also should check err of the bind setup call
Fixes c29f74e0df7a ("netfilter: nf_flow_table: hardware offload support")Signed-off-by wenxu <[email protected]>---
This patch is based on:
http://patchwork.ozlabs.org/patch/1195539/
This is actually like this one:
https://patchwork.ozlabs.org/patch/1194046/
right?
Quoted 8 lines
net/netfilter/nf_tables_api.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)net/netfilter/nf_tables_api.c +0
-0
net/netfilter/nf_tables_api.c static int nft_register_flowtable_net_hooks(struct net *net, · line 6006
Quoted 9 lines
net/netfilter/nf_tables_api.c +3
-3@@ -6001,12 +6001,20 @@ static int nft_register_flowtable_net_hooks(struct net *net, } } - flowtable->data.type->setup (&flowtable->data, hook->ops.dev, -FLOW_BLOCK_BIND ); - err =nf_register_net_hook (net, &hook->ops); + err = flowtable->data.type->setup (&flowtable->data, + hook->ops.dev, +FLOW_BLOCK_BIND );
I'd rather not check for the return value. ->setup returns 0 unless you use anything else than FLOW_BLOCK_BIND or _UNBIND. Probably better turn nf_flow_table_block_setup void and add WARN_ON_ONCE() there.
Pablo Neira Ayuso
maintainerQuoted 12 lines · Pablo Neira Ayuso
Quoted 10 lines · On Fri, Nov 15, 2019 at 07:21:26PM +0800, [email protected] wrote:
From: wenxu <[email protected]>
Undo the callback binding before unregistering the existing hooks. It also should check err of the bind setup call
Fixes c29f74e0df7a ("netfilter: nf_flow_table: hardware offload support")Signed-off-by wenxu <[email protected]>---
This patch is based on:
http://patchwork.ozlabs.org/patch/1195539/
Quoted 5 lines
This is actually like this one:
https://patchwork.ozlabs.org/patch/1194046/
right?
I'm attaching the one I made based on yours that I posted yesterday.
From f070db9a7fb9ecb6d2fdbd4702eb5e29b2bd5f64 Mon Sep 17 00:00:00 2001
From: Pablo Neira Ayuso <[email protected]>
Date: Fri, 15 Nov 2019 00:22:55 +0100
Subject: [PATCH] netfilter: nf_tables: unbind callbacks if flowtable hook
registration fails
Undo the callback binding before unregistering the existing hooks.
--- net/netfilter/nf_tables_api.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +5 -1
@@ -6009,8 +6009,12 @@ static int nft_register_flowtable_net_hooks(struct net *net, flowtable->data.type->setup (&flowtable->data, hook->ops.dev,FLOW_BLOCK_BIND ); err =nf_register_net_hook (net, &hook->ops); -if (err <0 ) +if (err <0 ) { + flowtable->data.type->setup (&flowtable->data, + hook->ops.dev, +FLOW_BLOCK_UNBIND ); goto err_unregister_net_hooks; + } i++; }
Signature · 1 line
2.11.0
Quoted 12 lines · Pablo Neira Ayuso
Quoted 11 lines · Pablo Neira Ayuso
Quoted 10 lines · On Fri, Nov 15, 2019 at 07:21:26PM +0800, [email protected] wrote:
From: wenxu <[email protected]>
Undo the callback binding before unregistering the existing hooks. It also should check err of the bind setup call
Fixes c29f74e0df7a ("netfilter: nf_flow_table: hardware offload support")Signed-off-by wenxu <[email protected]>---
This patch is based on:
http://patchwork.ozlabs.org/patch/1195539/
Quoted 6 lines
Quoted 5 lines
This is actually like this one:
https://patchwork.ozlabs.org/patch/1194046/
right?
I'm attaching the one I made based on yours that I posted yesterday.
yes it is include this one.
Quoted 12 lines · Pablo Neira Ayuso
Quoted 12 lines
net/netfilter/nf_tables_api.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)net/netfilter/nf_tables_api.c +0
-0@@ -6001,12 +6001,20 @@ static int nft_register_flowtable_net_hooks(struct net *net, } }
Quoted 9 lines
net/netfilter/nf_tables_api.c static int nft_register_flowtable_net_hooks(struct net *net, · line 6006
Quoted 6 lines
net/netfilter/nf_tables_api.c +3
-3- flowtable->data.type->setup (&flowtable->data, hook->ops.dev, -FLOW_BLOCK_BIND ); - err =nf_register_net_hook (net, &hook->ops); + err = flowtable->data.type->setup (&flowtable->data, + hook->ops.dev, +FLOW_BLOCK_BIND );I'd rather not check for the return value. ->setup returns 0 unless you use anything else than
FLOW_BLOCK_BINDor_UNBIND. Probably better turnnf_flow_table_block_setupvoid and addWARN_ON_ONCE()there.
If BIND failed. It means hw-offload failed. But the flowtable is set as hw-offload.
Maybe it is not too make sense?
Pablo Neira Ayuso
maintainerQuoted 24 lines · wenxu
Quoted 12 lines · Pablo Neira Ayuso
Quoted 12 lines
net/netfilter/nf_tables_api.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)net/netfilter/nf_tables_api.c +0
-0@@ -6001,12 +6001,20 @@ static int nft_register_flowtable_net_hooks(struct net *net, } }Quoted 9 lines
net/netfilter/nf_tables_api.c static int nft_register_flowtable_net_hooks(struct net *net, · line 6006
Quoted 6 lines
net/netfilter/nf_tables_api.c +3
-3- flowtable->data.type->setup (&flowtable->data, hook->ops.dev, -FLOW_BLOCK_BIND ); - err =nf_register_net_hook (net, &hook->ops); + err = flowtable->data.type->setup (&flowtable->data, + hook->ops.dev, +FLOW_BLOCK_BIND );I'd rather not check for the return value. ->setup returns 0 unless you use anything else than
FLOW_BLOCK_BINDor_UNBIND. Probably better turnnf_flow_table_block_setupvoid and addWARN_ON_ONCE()there.
Quoted 3 lines
If BIND failed. It means hw-offload failed. But the flowtable is set as hw-offload.
Maybe it is not too make sense?
Oh right. Your patch:
https://patchwork.ozlabs.org/patch/1195554/
is actually better. I'll take this and I'll drop mine.
Thanks.