From: Patrick McHardy <kaber@trash.net>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH] meta: don't print meta keyword for unqualified meta stmts
Date: Mon, 12 Jan 2015 13:19:09 +0000 [thread overview]
Message-ID: <1421068749-9365-1-git-send-email-kaber@trash.net> (raw)
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
src/meta.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/meta.c b/src/meta.c
index 6ff5fc8..6689ead 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -415,22 +415,28 @@ static const struct meta_template meta_templates[] = {
BYTEORDER_HOST_ENDIAN),
};
-static void meta_expr_print(const struct expr *expr)
+static bool meta_key_is_qualified(enum nft_meta_keys key)
{
- switch (expr->meta.key) {
+ switch (key) {
case NFT_META_LEN:
case NFT_META_NFPROTO:
case NFT_META_L4PROTO:
case NFT_META_PROTOCOL:
case NFT_META_PRIORITY:
- printf("meta %s", meta_templates[expr->meta.key].token);
- break;
+ return true;
default:
- printf("%s", meta_templates[expr->meta.key].token);
- break;
+ return false;
}
}
+static void meta_expr_print(const struct expr *expr)
+{
+ if (meta_key_is_qualified(expr->meta.key))
+ printf("meta %s", meta_templates[expr->meta.key].token);
+ else
+ printf("%s", meta_templates[expr->meta.key].token);
+}
+
static bool meta_expr_cmp(const struct expr *e1, const struct expr *e2)
{
return e1->meta.key == e2->meta.key;
@@ -529,7 +535,11 @@ struct expr *meta_expr_alloc(const struct location *loc, enum nft_meta_keys key)
static void meta_stmt_print(const struct stmt *stmt)
{
- printf("meta %s set ", meta_templates[stmt->meta.key].token);
+ if (meta_key_is_qualified(stmt->meta.key))
+ printf("meta %s set ", meta_templates[stmt->meta.key].token);
+ else
+ printf("%s set ", meta_templates[stmt->meta.key].token);
+
expr_print(stmt->meta.expr);
}
--
2.1.0
reply other threads:[~2015-01-12 13:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1421068749-9365-1-git-send-email-kaber@trash.net \
--to=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).