summaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorPablo Neira Ayuso2018-03-27 11:53:06 +0200
committerPablo Neira Ayuso2018-03-30 11:29:18 +0200
commitcc07eeb0e5ee18895241460bdccf91a4952731f9 (patch)
treed13f7712413b05a12acdb22967d7c6e422daff1c /net/netfilter
parentnetfilter: nf_tables: rename struct nf_chain_type (diff)
downloadkernel-qcow2-linux-cc07eeb0e5ee18895241460bdccf91a4952731f9.tar.gz
kernel-qcow2-linux-cc07eeb0e5ee18895241460bdccf91a4952731f9.tar.xz
kernel-qcow2-linux-cc07eeb0e5ee18895241460bdccf91a4952731f9.zip
netfilter: nf_tables: nft_register_chain_type() returns void
Use WARN_ON() instead since it should not happen that neither family goes over NFPROTO_NUMPROTO nor there is already a chain of this type already registered. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/nf_tables_api.c14
-rw-r--r--net/netfilter/nf_tables_inet.c4
-rw-r--r--net/netfilter/nf_tables_netdev.c4
3 files changed, 9 insertions, 13 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index bf564f491085..9e4b1614ee39 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -859,22 +859,18 @@ static void nf_tables_table_destroy(struct nft_ctx *ctx)
kfree(ctx->table);
}
-int nft_register_chain_type(const struct nft_chain_type *ctype)
+void nft_register_chain_type(const struct nft_chain_type *ctype)
{
- int err = 0;
-
if (WARN_ON(ctype->family >= NFPROTO_NUMPROTO))
- return -EINVAL;
+ return;
nfnl_lock(NFNL_SUBSYS_NFTABLES);
- if (chain_type[ctype->family][ctype->type] != NULL) {
- err = -EBUSY;
- goto out;
+ if (WARN_ON(chain_type[ctype->family][ctype->type] != NULL)) {
+ nfnl_unlock(NFNL_SUBSYS_NFTABLES);
+ return;
}
chain_type[ctype->family][ctype->type] = ctype;
-out:
nfnl_unlock(NFNL_SUBSYS_NFTABLES);
- return err;
}
EXPORT_SYMBOL_GPL(nft_register_chain_type);
diff --git a/net/netfilter/nf_tables_inet.c b/net/netfilter/nf_tables_inet.c
index 0aefe66ce558..202c4219969b 100644
--- a/net/netfilter/nf_tables_inet.c
+++ b/net/netfilter/nf_tables_inet.c
@@ -59,7 +59,9 @@ static const struct nft_chain_type filter_inet = {
static int __init nf_tables_inet_init(void)
{
- return nft_register_chain_type(&filter_inet);
+ nft_register_chain_type(&filter_inet);
+
+ return 0;
}
static void __exit nf_tables_inet_exit(void)
diff --git a/net/netfilter/nf_tables_netdev.c b/net/netfilter/nf_tables_netdev.c
index 88ea959211ac..4c3835bca63e 100644
--- a/net/netfilter/nf_tables_netdev.c
+++ b/net/netfilter/nf_tables_netdev.c
@@ -112,9 +112,7 @@ static int __init nf_tables_netdev_init(void)
{
int ret;
- ret = nft_register_chain_type(&nft_filter_chain_netdev);
- if (ret)
- return ret;
+ nft_register_chain_type(&nft_filter_chain_netdev);
ret = register_netdevice_notifier(&nf_tables_netdev_notifier);
if (ret)