Skip to content

Commit 05abe44

Browse files
committed
netfilter: nf_tables: allow to register flowtable with no devices
A flowtable might be composed of dynamic interfaces only. Such dynamic interfaces might show up at a later stage. This patch allows users to register a flowtable with no devices. Once the dynamic interface becomes available, the user adds the dynamic devices to the flowtable. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent abadb2f commit 05abe44

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,8 +1724,6 @@ static int nf_tables_parse_netdev_hooks(struct net *net,
17241724
goto err_hook;
17251725
}
17261726
}
1727-
if (!n)
1728-
return -EINVAL;
17291727

17301728
return 0;
17311729

@@ -1762,6 +1760,9 @@ static int nft_chain_parse_netdev(struct net *net,
17621760
hook_list);
17631761
if (err < 0)
17641762
return err;
1763+
1764+
if (list_empty(hook_list))
1765+
return -EINVAL;
17651766
} else {
17661767
return -EINVAL;
17671768
}
@@ -6209,8 +6210,7 @@ static int nft_flowtable_parse_hook(const struct nft_ctx *ctx,
62096210
return err;
62106211

62116212
if (!tb[NFTA_FLOWTABLE_HOOK_NUM] ||
6212-
!tb[NFTA_FLOWTABLE_HOOK_PRIORITY] ||
6213-
!tb[NFTA_FLOWTABLE_HOOK_DEVS])
6213+
!tb[NFTA_FLOWTABLE_HOOK_PRIORITY])
62146214
return -EINVAL;
62156215

62166216
hooknum = ntohl(nla_get_be32(tb[NFTA_FLOWTABLE_HOOK_NUM]));
@@ -6219,11 +6219,13 @@ static int nft_flowtable_parse_hook(const struct nft_ctx *ctx,
62196219

62206220
priority = ntohl(nla_get_be32(tb[NFTA_FLOWTABLE_HOOK_PRIORITY]));
62216221

6222-
err = nf_tables_parse_netdev_hooks(ctx->net,
6223-
tb[NFTA_FLOWTABLE_HOOK_DEVS],
6224-
&flowtable_hook->list);
6225-
if (err < 0)
6226-
return err;
6222+
if (tb[NFTA_FLOWTABLE_HOOK_DEVS]) {
6223+
err = nf_tables_parse_netdev_hooks(ctx->net,
6224+
tb[NFTA_FLOWTABLE_HOOK_DEVS],
6225+
&flowtable_hook->list);
6226+
if (err < 0)
6227+
return err;
6228+
}
62276229

62286230
flowtable_hook->priority = priority;
62296231
flowtable_hook->num = hooknum;

0 commit comments

Comments
 (0)