From: Pablo Neira Ayuso <pa...@netfilter.org>

Since pernet hooks, we need to register the hook for each netnamespace space.

Signed-off-by: Pablo Neira Ayuso <pa...@netfilter.org>
Signed-off-by: Eric W Biederman <ebied...@xmission.com>
---
 net/netfilter/nf_tables_api.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index ce996362083f..ed9ef9925166 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -130,20 +130,24 @@ static void nft_trans_destroy(struct nft_trans *trans)
 int nft_register_basechain(struct nft_base_chain *basechain,
                           unsigned int hook_nops)
 {
+       struct net *net = read_pnet(&basechain->pnet);
+
        if (basechain->flags & NFT_BASECHAIN_DISABLED)
                return 0;
 
-       return nf_register_hooks(&init_net, basechain->ops, hook_nops);
+       return nf_register_hooks(net, basechain->ops, hook_nops);
 }
 EXPORT_SYMBOL_GPL(nft_register_basechain);
 
 void nft_unregister_basechain(struct nft_base_chain *basechain,
                              unsigned int hook_nops)
 {
+       struct net *net = read_pnet(&basechain->pnet);
+
        if (basechain->flags & NFT_BASECHAIN_DISABLED)
                return;
 
-       nf_unregister_hooks(&init_net, basechain->ops, hook_nops);
+       nf_unregister_hooks(net, basechain->ops, hook_nops);
 }
 EXPORT_SYMBOL_GPL(nft_unregister_basechain);
 
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to