Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html