Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+30 -30
+1 -1
include/net/netfilter/nf_tables.h
··· 970 970 char *name; 971 971 }; 972 972 973 - int nft_register_chain_type(const struct nft_chain_type *); 973 + void nft_register_chain_type(const struct nft_chain_type *); 974 974 void nft_unregister_chain_type(const struct nft_chain_type *); 975 975 976 976 int nft_register_expr(struct nft_expr_type *);
+3 -1
net/bridge/netfilter/nf_tables_bridge.c
··· 63 63 64 64 static int __init nf_tables_bridge_init(void) 65 65 { 66 - return nft_register_chain_type(&filter_bridge); 66 + nft_register_chain_type(&filter_bridge); 67 + 68 + return 0; 67 69 } 68 70 69 71 static void __exit nf_tables_bridge_exit(void)
+3 -1
net/ipv4/netfilter/nf_tables_arp.c
··· 42 42 43 43 static int __init nf_tables_arp_init(void) 44 44 { 45 - return nft_register_chain_type(&filter_arp); 45 + nft_register_chain_type(&filter_arp); 46 + 47 + return 0; 46 48 } 47 49 48 50 static void __exit nf_tables_arp_exit(void)
+3 -1
net/ipv4/netfilter/nf_tables_ipv4.c
··· 51 51 52 52 static int __init nf_tables_ipv4_init(void) 53 53 { 54 - return nft_register_chain_type(&filter_ipv4); 54 + nft_register_chain_type(&filter_ipv4); 55 + 56 + return 0; 55 57 } 56 58 57 59 static void __exit nf_tables_ipv4_exit(void)
+1 -5
net/ipv4/netfilter/nft_chain_nat_ipv4.c
··· 86 86 87 87 static int __init nft_chain_nat_init(void) 88 88 { 89 - int err; 90 - 91 - err = nft_register_chain_type(&nft_chain_nat_ipv4); 92 - if (err < 0) 93 - return err; 89 + nft_register_chain_type(&nft_chain_nat_ipv4); 94 90 95 91 return 0; 96 92 }
+3 -1
net/ipv4/netfilter/nft_chain_route_ipv4.c
··· 71 71 72 72 static int __init nft_chain_route_init(void) 73 73 { 74 - return nft_register_chain_type(&nft_chain_route_ipv4); 74 + nft_register_chain_type(&nft_chain_route_ipv4); 75 + 76 + return 0; 75 77 } 76 78 77 79 static void __exit nft_chain_route_exit(void)
+3 -1
net/ipv6/netfilter/nf_tables_ipv6.c
··· 49 49 50 50 static int __init nf_tables_ipv6_init(void) 51 51 { 52 - return nft_register_chain_type(&filter_ipv6); 52 + nft_register_chain_type(&filter_ipv6); 53 + 54 + return 0; 53 55 } 54 56 55 57 static void __exit nf_tables_ipv6_exit(void)
+1 -5
net/ipv6/netfilter/nft_chain_nat_ipv6.c
··· 84 84 85 85 static int __init nft_chain_nat_ipv6_init(void) 86 86 { 87 - int err; 88 - 89 - err = nft_register_chain_type(&nft_chain_nat_ipv6); 90 - if (err < 0) 91 - return err; 87 + nft_register_chain_type(&nft_chain_nat_ipv6); 92 88 93 89 return 0; 94 90 }
+3 -1
net/ipv6/netfilter/nft_chain_route_ipv6.c
··· 73 73 74 74 static int __init nft_chain_route_init(void) 75 75 { 76 - return nft_register_chain_type(&nft_chain_route_ipv6); 76 + nft_register_chain_type(&nft_chain_route_ipv6); 77 + 78 + return 0; 77 79 } 78 80 79 81 static void __exit nft_chain_route_exit(void)
+5 -9
net/netfilter/nf_tables_api.c
··· 859 859 kfree(ctx->table); 860 860 } 861 861 862 - int nft_register_chain_type(const struct nft_chain_type *ctype) 862 + void nft_register_chain_type(const struct nft_chain_type *ctype) 863 863 { 864 - int err = 0; 865 - 866 864 if (WARN_ON(ctype->family >= NFPROTO_NUMPROTO)) 867 - return -EINVAL; 865 + return; 868 866 869 867 nfnl_lock(NFNL_SUBSYS_NFTABLES); 870 - if (chain_type[ctype->family][ctype->type] != NULL) { 871 - err = -EBUSY; 872 - goto out; 868 + if (WARN_ON(chain_type[ctype->family][ctype->type] != NULL)) { 869 + nfnl_unlock(NFNL_SUBSYS_NFTABLES); 870 + return; 873 871 } 874 872 chain_type[ctype->family][ctype->type] = ctype; 875 - out: 876 873 nfnl_unlock(NFNL_SUBSYS_NFTABLES); 877 - return err; 878 874 } 879 875 EXPORT_SYMBOL_GPL(nft_register_chain_type); 880 876
+3 -1
net/netfilter/nf_tables_inet.c
··· 59 59 60 60 static int __init nf_tables_inet_init(void) 61 61 { 62 - return nft_register_chain_type(&filter_inet); 62 + nft_register_chain_type(&filter_inet); 63 + 64 + return 0; 63 65 } 64 66 65 67 static void __exit nf_tables_inet_exit(void)
+1 -3
net/netfilter/nf_tables_netdev.c
··· 112 112 { 113 113 int ret; 114 114 115 - ret = nft_register_chain_type(&nft_filter_chain_netdev); 116 - if (ret) 117 - return ret; 115 + nft_register_chain_type(&nft_filter_chain_netdev); 118 116 119 117 ret = register_netdevice_notifier(&nf_tables_netdev_notifier); 120 118 if (ret)