Skip to content

Commit fe19c04

Browse files
committed
netfilter: nf_tables: remove nhooks field from struct nft_af_info
We already validate the hook through bitmask, so this check is superfluous. When removing this, this patch is also fixing a bug in the new flowtable codebase, since ctx->afi points to the table family instead of the netdev family which is where the flowtable is really hooked in. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 61ad640 commit fe19c04

File tree

8 files changed

+1
-12
lines changed

8 files changed

+1
-12
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,15 +973,13 @@ enum nft_af_flags {
973973
*
974974
* @list: used internally
975975
* @family: address family
976-
* @nhooks: number of hooks in this family
977976
* @owner: module owner
978977
* @tables: used internally
979978
* @flags: family flags
980979
*/
981980
struct nft_af_info {
982981
struct list_head list;
983982
int family;
984-
unsigned int nhooks;
985983
struct module *owner;
986984
struct list_head tables;
987985
u32 flags;

net/bridge/netfilter/nf_tables_bridge.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ nft_do_chain_bridge(void *priv,
4444

4545
static struct nft_af_info nft_af_bridge __read_mostly = {
4646
.family = NFPROTO_BRIDGE,
47-
.nhooks = NF_BR_NUMHOOKS,
4847
.owner = THIS_MODULE,
4948
};
5049

net/ipv4/netfilter/nf_tables_arp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ nft_do_chain_arp(void *priv,
2929

3030
static struct nft_af_info nft_af_arp __read_mostly = {
3131
.family = NFPROTO_ARP,
32-
.nhooks = NF_ARP_NUMHOOKS,
3332
.owner = THIS_MODULE,
3433
};
3534

net/ipv4/netfilter/nf_tables_ipv4.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ static unsigned int nft_do_chain_ipv4(void *priv,
3232

3333
static struct nft_af_info nft_af_ipv4 __read_mostly = {
3434
.family = NFPROTO_IPV4,
35-
.nhooks = NF_INET_NUMHOOKS,
3635
.owner = THIS_MODULE,
3736
};
3837

net/ipv6/netfilter/nf_tables_ipv6.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ static unsigned int nft_do_chain_ipv6(void *priv,
3030

3131
static struct nft_af_info nft_af_ipv6 __read_mostly = {
3232
.family = NFPROTO_IPV6,
33-
.nhooks = NF_INET_NUMHOOKS,
3433
.owner = THIS_MODULE,
3534
};
3635

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,9 +1328,6 @@ static int nft_chain_parse_hook(struct net *net,
13281328
return -EINVAL;
13291329

13301330
hook->num = ntohl(nla_get_be32(ha[NFTA_HOOK_HOOKNUM]));
1331-
if (hook->num >= afi->nhooks)
1332-
return -EINVAL;
1333-
13341331
hook->priority = ntohl(nla_get_be32(ha[NFTA_HOOK_PRIORITY]));
13351332

13361333
type = chain_type[afi->family][NFT_CHAIN_T_DEFAULT];
@@ -4993,7 +4990,7 @@ static int nf_tables_flowtable_parse_hook(const struct nft_ctx *ctx,
49934990
return -EINVAL;
49944991

49954992
hooknum = ntohl(nla_get_be32(tb[NFTA_FLOWTABLE_HOOK_NUM]));
4996-
if (hooknum >= ctx->afi->nhooks)
4993+
if (hooknum != NF_NETDEV_INGRESS)
49974994
return -EINVAL;
49984995

49994996
priority = ntohl(nla_get_be32(tb[NFTA_FLOWTABLE_HOOK_PRIORITY]));

net/netfilter/nf_tables_inet.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ static unsigned int nft_do_chain_inet(void *priv, struct sk_buff *skb,
4040

4141
static struct nft_af_info nft_af_inet __read_mostly = {
4242
.family = NFPROTO_INET,
43-
.nhooks = NF_INET_NUMHOOKS,
4443
.owner = THIS_MODULE,
4544
};
4645

net/netfilter/nf_tables_netdev.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ nft_do_chain_netdev(void *priv, struct sk_buff *skb,
4040

4141
static struct nft_af_info nft_af_netdev __read_mostly = {
4242
.family = NFPROTO_NETDEV,
43-
.nhooks = NF_NETDEV_NUMHOOKS,
4443
.owner = THIS_MODULE,
4544
.flags = NFT_AF_NEEDS_DEV,
4645
};

0 commit comments

Comments
 (0)