diff options
author | Florian Westphal <fw@strlen.de> | 2021-04-21 09:51:01 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-04-26 03:20:39 +0200 |
commit | 1ef4d6d1af2d0c0c7c9b391365a3894bea291e34 (patch) | |
tree | dbb725d692760415b8349f0625929973a6ffc399 /net | |
parent | 7716bf090e97aec45e97907ec6a382e4610bdd8f (diff) | |
download | linux-1ef4d6d1af2d0c0c7c9b391365a3894bea291e34.tar.gz linux-1ef4d6d1af2d0c0c7c9b391365a3894bea291e34.tar.bz2 linux-1ef4d6d1af2d0c0c7c9b391365a3894bea291e34.zip |
netfilter: x_tables: add xt_find_table
This will be used to obtain the xt_table struct given address family and
table name.
Followup patches will reduce the number of direct accesses to the xt_table
structures via net->ipv{4,6}.ip(6)table_{nat,mangle,...} pointers, then
remove them.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/x_tables.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index b7f8d2ed3cc2..1caba9507228 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1199,6 +1199,23 @@ void xt_free_table_info(struct xt_table_info *info) } EXPORT_SYMBOL(xt_free_table_info); +struct xt_table *xt_find_table(struct net *net, u8 af, const char *name) +{ + struct xt_pernet *xt_net = net_generic(net, xt_pernet_id); + struct xt_table *t; + + mutex_lock(&xt[af].mutex); + list_for_each_entry(t, &xt_net->tables[af], list) { + if (strcmp(t->name, name) == 0) { + mutex_unlock(&xt[af].mutex); + return t; + } + } + mutex_unlock(&xt[af].mutex); + return NULL; +} +EXPORT_SYMBOL(xt_find_table); + /* Find table by name, grabs mutex & ref. Returns ERR_PTR on error. */ struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af, const char *name) |