Skip to content

Commit d25e2e9

Browse files
ummakyneskuba-moo
authored andcommitted
netfilter: restore NF_INET_NUMHOOKS
This definition is used by the iptables legacy UAPI, restore it. Fixes: d3519cb ("netfilter: nf_tables: add inet ingress support") Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Tested-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5017273 commit d25e2e9

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

include/net/netfilter/nf_tables.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <net/netlink.h>
1515
#include <net/flow_offload.h>
1616

17+
#define NFT_MAX_HOOKS (NF_INET_INGRESS + 1)
18+
1719
struct module;
1820

1921
#define NFT_JUMP_STACK_SIZE 16
@@ -979,7 +981,7 @@ struct nft_chain_type {
979981
int family;
980982
struct module *owner;
981983
unsigned int hook_mask;
982-
nf_hookfn *hooks[NF_MAX_HOOKS];
984+
nf_hookfn *hooks[NFT_MAX_HOOKS];
983985
int (*ops_register)(struct net *net, const struct nf_hook_ops *ops);
984986
void (*ops_unregister)(struct net *net, const struct nf_hook_ops *ops);
985987
};

include/uapi/linux/netfilter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ enum nf_inet_hooks {
4545
NF_INET_FORWARD,
4646
NF_INET_LOCAL_OUT,
4747
NF_INET_POST_ROUTING,
48-
NF_INET_INGRESS,
49-
NF_INET_NUMHOOKS
48+
NF_INET_NUMHOOKS,
49+
NF_INET_INGRESS = NF_INET_NUMHOOKS,
5050
};
5151

5252
enum nf_dev_hooks {

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,7 @@ static int nft_chain_parse_hook(struct net *net,
18641864
if (IS_ERR(type))
18651865
return PTR_ERR(type);
18661866
}
1867-
if (hook->num > NF_MAX_HOOKS || !(type->hook_mask & (1 << hook->num)))
1867+
if (hook->num >= NFT_MAX_HOOKS || !(type->hook_mask & (1 << hook->num)))
18681868
return -EOPNOTSUPP;
18691869

18701870
if (type->type == NFT_CHAIN_T_NAT &&

0 commit comments

Comments
 (0)