Skip to content

Commit

Permalink
netfilter: nf_tables: nft_register_chain_type() returns void
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pablo Neira Ayuso committed Mar 30, 2018
1 parent 32537e9 commit cc07eeb
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion include/net/netfilter/nf_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
4 changes: 3 additions & 1 deletion net/bridge/netfilter/nf_tables_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion net/ipv4/netfilter/nf_tables_arp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion net/ipv4/netfilter/nf_tables_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions net/ipv4/netfilter/nft_chain_nat_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion net/ipv4/netfilter/nft_chain_route_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion net/ipv6/netfilter/nf_tables_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions net/ipv6/netfilter/nft_chain_nat_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion net/ipv6/netfilter/nft_chain_route_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 5 additions & 9 deletions net/netfilter/nf_tables_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion net/netfilter/nf_tables_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions net/netfilter/nf_tables_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cc07eeb

Please sign in to comment.