netfilter: nf_tables: __nft_expr_type_get() selects specific family type
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 5 Jul 2019 20:59:05 +0000 (22:59 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 5 Jul 2019 21:50:45 +0000 (23:50 +0200)
In case that there are two types, prefer the family specify extension.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index 582f4e475d6773475df8194535ea95deb8e11929..5e97bf64975a002b716c77e0c4681d2404602797 100644 (file)
@@ -2009,14 +2009,17 @@ EXPORT_SYMBOL_GPL(nft_unregister_expr);
 static const struct nft_expr_type *__nft_expr_type_get(u8 family,
                                                       struct nlattr *nla)
 {
-       const struct nft_expr_type *type;
+       const struct nft_expr_type *type, *candidate = NULL;
 
        list_for_each_entry(type, &nf_tables_expressions, list) {
-               if (!nla_strcmp(nla, type->name) &&
-                   (!type->family || type->family == family))
-                       return type;
+               if (!nla_strcmp(nla, type->name)) {
+                       if (!type->family && !candidate)
+                               candidate = type;
+                       else if (type->family == family)
+                               candidate = type;
+               }
        }
-       return NULL;
+       return candidate;
 }
 
 #ifdef CONFIG_MODULES