Skip to contentSkip to conversation

netfilter: restore NF_INET_NUMHOOKS

PATCH Applied Pablo Neira Ayuso 2 participants 2 messages Oct 14, 2020 – Oct 15, 2020

Subsystems (3)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: restore NF_INET_NUMHOOKS

This definition is used by the iptables legacy UAPI, restore it.

Fixes d3519cb89f6d ("netfilter: nf_tables: add inet ingress support")

---
@Jakub: if you please can take this into net-next, it is fixing fallout
from the inet ingress support. Thank you.

 include/net/netfilter/nf_tables.h | 4 +++-
 include/uapi/linux/netfilter.h    | 4 ++--
 net/netfilter/nf_tables_api.c     | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)
include/net/netfilter/nf_tables.h +3 -1
index 3965ce18226f..3f7e56b1171e 100644
@@ -14,6 +14,8 @@
 #include <net/netlink.h>
 #include <net/flow_offload.h>
 
+#define NFT_MAX_HOOKS	(NF_INET_INGRESS + 1)
+
 struct module;
 
 #define NFT_JUMP_STACK_SIZE	16
@@ -979,7 +981,7 @@ struct nft_chain_type {
 	int				family;
 	struct module			*owner;
 	unsigned int			hook_mask;
-	nf_hookfn			*hooks[NF_MAX_HOOKS];
+	nf_hookfn			*hooks[NFT_MAX_HOOKS];
 	int				(*ops_register)(struct net *net, const struct nf_hook_ops *ops);
 	void				(*ops_unregister)(struct net *net, const struct nf_hook_ops *ops);
 };
include/uapi/linux/netfilter.h +2 -2
index 6a6179af0d7c..ef9a44286e23 100644
@@ -45,8 +45,8 @@ enum nf_inet_hooks {
 	NF_INET_FORWARD,
 	NF_INET_LOCAL_OUT,
 	NF_INET_POST_ROUTING,
-	NF_INET_INGRESS,
-	NF_INET_NUMHOOKS
+	NF_INET_NUMHOOKS,
+	NF_INET_INGRESS = NF_INET_NUMHOOKS,
 };
 
 enum nf_dev_hooks {
net/netfilter/nf_tables_api.c +1 -1
index f22ad21d0230..7f1c184c00d2 100644
@@ -1864,7 +1864,7 @@ static int nft_chain_parse_hook(struct net *net,
 		if (IS_ERR(type))
 			return PTR_ERR(type);
 	}
-	if (hook->num > NF_MAX_HOOKS || !(type->hook_mask & (1 << hook->num)))
+	if (hook->num >= NFT_MAX_HOOKS || !(type->hook_mask & (1 << hook->num)))
 		return -EOPNOTSUPP;
 
 	if (type->type == NFT_CHAIN_T_NAT &&
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 9 lines · On Wed, 14 Oct 2020 21:34:32 +0200 Pablo Neira Ayuso wrote:

This definition is used by the iptables legacy UAPI, restore it.

Fixes d3519cb89f6d ("netfilter: nf_tables: add inet ingress support")

---
@Jakub: if you please can take this into net-next, it is fixing fallout
from the inet ingress support. Thank you.

Applied, thanks!