From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
To: pablo@netfilter.org, kaber@trash.net
Cc: netfilter-devel@vger.kernel.org,
Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Subject: [RFC 3/3] netfilter: nftables: Return preferably given family expression if any
Date: Thu, 27 Mar 2014 11:19:32 +0200 [thread overview]
Message-ID: <1395911972-17259-4-git-send-email-tomasz.bursztyka@linux.intel.com> (raw)
In-Reply-To: <1395911972-17259-1-git-send-email-tomasz.bursztyka@linux.intel.com>
Currently, when looking up for the proper expression type, what comes
first is returned. Which might end up to be a non-family tight type.
Instead, if a specific family type exist, it will be better to return
this one.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
---
net/netfilter/nf_tables_api.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index adce01e..83de6c1 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1117,14 +1117,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;
-
- list_for_each_entry(type, &nf_tables_expressions, list) {
- if (!nla_strcmp(nla, type->name) &&
- (!type->family || type->family == family))
- return type;
+ const struct nft_expr_type *test, *type = NULL;
+
+ list_for_each_entry(test, &nf_tables_expressions, list) {
+ if (!nla_strcmp(nla, test->name)) {
+ if (test->family == family)
+ return test;
+ if (!test->family)
+ type = test;
+ }
}
- return NULL;
+ return type;
}
static const struct nft_expr_type *nft_expr_type_get(u8 family,
--
1.8.3.2
next prev parent reply other threads:[~2014-03-27 9:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-27 9:19 [RFC 0/3] Add support for meta keys, bridge family specific Tomasz Bursztyka
2014-03-27 9:19 ` [RFC 1/3] netfilter: nf_tables: Make public core function of META expression Tomasz Bursztyka
2014-03-27 9:19 ` [RFC 2/3] netfilter: nf_tables: Add meta expression key for bridge interface name Tomasz Bursztyka
2014-04-08 8:06 ` Pablo Neira Ayuso
2014-04-08 8:20 ` Tomasz Bursztyka
2014-04-08 8:34 ` Pablo Neira Ayuso
2014-04-08 9:04 ` Tomasz Bursztyka
2014-03-27 9:19 ` Tomasz Bursztyka [this message]
2014-03-27 9:26 ` [RFC 3/3] netfilter: nftables: Return preferably given family expression if any Patrick McHardy
2014-03-27 11:00 ` Tomasz Bursztyka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395911972-17259-4-git-send-email-tomasz.bursztyka@linux.intel.com \
--to=tomasz.bursztyka@linux.intel.com \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).