Skip to content

Commit 9cff126

Browse files
committed
netfilter: nf_tables: __nft_expr_type_get() selects specific family type
In case that there are two types, prefer the family specify extension. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent b9c04ae commit 9cff126

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,14 +2009,17 @@ EXPORT_SYMBOL_GPL(nft_unregister_expr);
20092009
static const struct nft_expr_type *__nft_expr_type_get(u8 family,
20102010
struct nlattr *nla)
20112011
{
2012-
const struct nft_expr_type *type;
2012+
const struct nft_expr_type *type, *candidate = NULL;
20132013

20142014
list_for_each_entry(type, &nf_tables_expressions, list) {
2015-
if (!nla_strcmp(nla, type->name) &&
2016-
(!type->family || type->family == family))
2017-
return type;
2015+
if (!nla_strcmp(nla, type->name)) {
2016+
if (!type->family && !candidate)
2017+
candidate = type;
2018+
else if (type->family == family)
2019+
candidate = type;
2020+
}
20182021
}
2019-
return NULL;
2022+
return candidate;
20202023
}
20212024

20222025
#ifdef CONFIG_MODULES

0 commit comments

Comments
 (0)