summaryrefslogtreecommitdiffstats
path: root/net/netfilter/nf_tables_api.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2015-06-15 12:12:01 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2015-06-15 23:02:35 +0200
commit835b803377f5f11f9ccf234f70ed667a82605c45 (patch)
treec37020898a8d31211877daef0fc7609bc118c878 /net/netfilter/nf_tables_api.c
parentd8ee8f7c56b267751f95a1f0b4a75618909c07ac (diff)
downloadop-kernel-dev-835b803377f5f11f9ccf234f70ed667a82605c45.zip
op-kernel-dev-835b803377f5f11f9ccf234f70ed667a82605c45.tar.gz
netfilter: nf_tables_netdev: unregister hooks on net_device removal
In case the net_device is gone, we have to unregister the hooks and put back the reference on the net_device object. Once it comes back, register them again. This also covers the device rename case. This patch also adds a new flag to indicate that the basechain is disabled, so their hooks are not registered. This flag is used by the netdev family to handle the case where the net_device object is gone. Currently this flag is not exposed to userspace. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter/nf_tables_api.c')
-rw-r--r--net/netfilter/nf_tables_api.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index c66dc62..cfe6368 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -127,17 +127,25 @@ static void nft_trans_destroy(struct nft_trans *trans)
kfree(trans);
}
-static int nft_register_basechain(struct nft_base_chain *basechain,
- unsigned int hook_nops)
+int nft_register_basechain(struct nft_base_chain *basechain,
+ unsigned int hook_nops)
{
+ if (basechain->flags & NFT_BASECHAIN_DISABLED)
+ return 0;
+
return nf_register_hooks(basechain->ops, hook_nops);
}
+EXPORT_SYMBOL_GPL(nft_register_basechain);
-static void nft_unregister_basechain(struct nft_base_chain *basechain,
- unsigned int hook_nops)
+void nft_unregister_basechain(struct nft_base_chain *basechain,
+ unsigned int hook_nops)
{
+ if (basechain->flags & NFT_BASECHAIN_DISABLED)
+ return;
+
nf_unregister_hooks(basechain->ops, hook_nops);
}
+EXPORT_SYMBOL_GPL(nft_unregister_basechain);
static int nf_tables_register_hooks(const struct nft_table *table,
struct nft_chain *chain,
OpenPOWER on IntegriCloud