netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] meta: don't print meta keyword for unqualified meta stmts
@ 2015-01-12 13:19 Patrick McHardy
  0 siblings, 0 replies; only message in thread
From: Patrick McHardy @ 2015-01-12 13:19 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-01-12 13:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-12 13:19 [PATCH] meta: don't print meta keyword for unqualified meta stmts Patrick McHardy

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).