netfilter: nf_tables: nft_register_chain_type() returns void
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 27 Mar 2018 09:53:06 +0000 (11:53 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 30 Mar 2018 09:29:18 +0000 (11:29 +0200)
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>
12 files changed:
include/net/netfilter/nf_tables.h
net/bridge/netfilter/nf_tables_bridge.c
net/ipv4/netfilter/nf_tables_arp.c
net/ipv4/netfilter/nf_tables_ipv4.c
net/ipv4/netfilter/nft_chain_nat_ipv4.c
net/ipv4/netfilter/nft_chain_route_ipv4.c
net/ipv6/netfilter/nf_tables_ipv6.c
net/ipv6/netfilter/nft_chain_nat_ipv6.c
net/ipv6/netfilter/nft_chain_route_ipv6.c
net/netfilter/nf_tables_api.c
net/netfilter/nf_tables_inet.c
net/netfilter/nf_tables_netdev.c

index 4a304997c304b8697d9f128e5500abb0d9b53c48..1f7148fe05044de4d34caadfe052f84935ccf953 100644 (file)
@@ -970,7 +970,7 @@ struct nft_table {
        char                            *name;
 };
 
-int nft_register_chain_type(const struct nft_chain_type *);
+void nft_register_chain_type(const struct nft_chain_type *);
 void nft_unregister_chain_type(const struct nft_chain_type *);
 
 int nft_register_expr(struct nft_expr_type *);
index 73a1ec556a0ae13ba0dc4825d4cebcf05e029ffa..ffb8580dfdacf644b3f1db14427ef1df1ece5900 100644 (file)
@@ -63,7 +63,9 @@ static const struct nft_chain_type filter_bridge = {
 
 static int __init nf_tables_bridge_init(void)
 {
-       return nft_register_chain_type(&filter_bridge);
+       nft_register_chain_type(&filter_bridge);
+
+       return 0;
 }
 
 static void __exit nf_tables_bridge_exit(void)
index 5b0be2a10b695e20fc80950caf574a67c6579ea0..c2ee642087434557d9db91a161b14815db307f0f 100644 (file)
@@ -42,7 +42,9 @@ static const struct nft_chain_type filter_arp = {
 
 static int __init nf_tables_arp_init(void)
 {
-       return nft_register_chain_type(&filter_arp);
+       nft_register_chain_type(&filter_arp);
+
+       return 0;
 }
 
 static void __exit nf_tables_arp_exit(void)
index 13bae5cfa257e027405560a230ff160bc238fa24..c09667de0d689488df70c0c49145aa4125769c0b 100644 (file)
@@ -51,7 +51,9 @@ static const struct nft_chain_type filter_ipv4 = {
 
 static int __init nf_tables_ipv4_init(void)
 {
-       return nft_register_chain_type(&filter_ipv4);
+       nft_register_chain_type(&filter_ipv4);
+
+       return 0;
 }
 
 static void __exit nf_tables_ipv4_exit(void)
index 167f377eb1cb5e3493991c0835cab759255ed66a..9864f5b3279c047d69d009f396bbe4cd6707f366 100644 (file)
@@ -86,11 +86,7 @@ static const struct nft_chain_type nft_chain_nat_ipv4 = {
 
 static int __init nft_chain_nat_init(void)
 {
-       int err;
-
-       err = nft_register_chain_type(&nft_chain_nat_ipv4);
-       if (err < 0)
-               return err;
+       nft_register_chain_type(&nft_chain_nat_ipv4);
 
        return 0;
 }
index 48cf1f892314a1dd5cadc09dd34ade2f5a37b6bf..7d82934c46f424bdbd8e0c0280b082c43858567f 100644 (file)
@@ -71,7 +71,9 @@ static const struct nft_chain_type nft_chain_route_ipv4 = {
 
 static int __init nft_chain_route_init(void)
 {
-       return nft_register_chain_type(&nft_chain_route_ipv4);
+       nft_register_chain_type(&nft_chain_route_ipv4);
+
+       return 0;
 }
 
 static void __exit nft_chain_route_exit(void)
index d99f9ac6f1b6e438192500d685ef8e4ec793a4d1..496f694534571c572cf497469c5de0f00282cc03 100644 (file)
@@ -49,7 +49,9 @@ static const struct nft_chain_type filter_ipv6 = {
 
 static int __init nf_tables_ipv6_init(void)
 {
-       return nft_register_chain_type(&filter_ipv6);
+       nft_register_chain_type(&filter_ipv6);
+
+       return 0;
 }
 
 static void __exit nf_tables_ipv6_exit(void)
index c498aaa8056b9e947093336d8e2aff9aa92dae37..c95d9a97d425e20a6f6bf5a5c96901a35462d958 100644 (file)
@@ -84,11 +84,7 @@ static const struct nft_chain_type nft_chain_nat_ipv6 = {
 
 static int __init nft_chain_nat_ipv6_init(void)
 {
-       int err;
-
-       err = nft_register_chain_type(&nft_chain_nat_ipv6);
-       if (err < 0)
-               return err;
+       nft_register_chain_type(&nft_chain_nat_ipv6);
 
        return 0;
 }
index d5c7fdc342560ccf680f4aa8080aedf70900037b..da3f1f8cb325cbdcb26665abe21fd818384769e1 100644 (file)
@@ -73,7 +73,9 @@ static const struct nft_chain_type nft_chain_route_ipv6 = {
 
 static int __init nft_chain_route_init(void)
 {
-       return nft_register_chain_type(&nft_chain_route_ipv6);
+       nft_register_chain_type(&nft_chain_route_ipv6);
+
+       return 0;
 }
 
 static void __exit nft_chain_route_exit(void)
index bf564f49108535bfd3144a42e4a5c82cc5ffc928..9e4b1614ee3933d6df60c470b8d513ed1dacb572 100644 (file)
@@ -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);
 
index 0aefe66ce5585ad1a3e0a17b57b30491cffbee34..202c4219969bac7250e06f90f88ddae1f21ebee4 100644 (file)
@@ -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)
index 88ea959211acb511912f49cfbee14a3c11186249..4c3835bca63e7abaced9a73edae4df0feb62a18a 100644 (file)
@@ -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)