[PATCH nftables 1/2] xt: pass octx to translate function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can't use it when no translation is available as libxtables will
use plain printf(), but when translation is available we can.

Signed-off-by: Florian Westphal <fw@xxxxxxxxx>
---
 include/xt.h    | 5 +++--
 src/statement.c | 2 +-
 src/xt.c        | 6 +++---
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/xt.h b/include/xt.h
index 753511e63508..549eb9fe4153 100644
--- a/include/xt.h
+++ b/include/xt.h
@@ -6,9 +6,10 @@ struct netlink_parse_ctx;
 struct nftnl_expr;
 struct rule_pp_ctx;
 struct rule;
+struct output_ctx;
 
 #ifdef HAVE_LIBXTABLES
-void xt_stmt_xlate(const struct stmt *stmt);
+void xt_stmt_xlate(const struct stmt *stmt, struct output_ctx *octx);
 void xt_stmt_release(const struct stmt *stmt);
 
 void netlink_parse_target(struct netlink_parse_ctx *ctx,
@@ -20,7 +21,7 @@ void netlink_parse_match(struct netlink_parse_ctx *ctx,
 void stmt_xt_postprocess(struct rule_pp_ctx *rctx, struct stmt *stmt,
 			 struct rule *rule);
 #else
-static inline void xt_stmt_xlate(const struct stmt *stmt) {}
+static inline void xt_stmt_xlate(const struct stmt *stmt, struct output_ctx *octx) {}
 static inline void xt_stmt_release(const struct stmt *stmt) {}
 
 #include <erec.h>
diff --git a/src/statement.c b/src/statement.c
index 1eaaf58511f0..07e174610493 100644
--- a/src/statement.c
+++ b/src/statement.c
@@ -832,7 +832,7 @@ struct stmt *tproxy_stmt_alloc(const struct location *loc)
 
 static void xt_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
 {
-	xt_stmt_xlate(stmt);
+	xt_stmt_xlate(stmt, octx);
 }
 
 static void xt_stmt_destroy(struct stmt *stmt)
diff --git a/src/xt.c b/src/xt.c
index 74763d58cafd..5606cafed1e5 100644
--- a/src/xt.c
+++ b/src/xt.c
@@ -26,7 +26,7 @@
 #include <linux/netfilter_arp/arp_tables.h>
 #include <linux/netfilter_bridge/ebtables.h>
 
-void xt_stmt_xlate(const struct stmt *stmt)
+void xt_stmt_xlate(const struct stmt *stmt, struct output_ctx *octx)
 {
 	struct xt_xlate *xl = xt_xlate_alloc(10240);
 
@@ -40,7 +40,7 @@ void xt_stmt_xlate(const struct stmt *stmt)
 			};
 
 			stmt->xt.match->xlate(xl, &params);
-			printf("%s", xt_xlate_get(xl));
+			nft_print(octx, "%s", xt_xlate_get(xl));
 		} else if (stmt->xt.match->print) {
 			printf("#");
 			stmt->xt.match->print(&stmt->xt.entry,
@@ -57,7 +57,7 @@ void xt_stmt_xlate(const struct stmt *stmt)
 			};
 
 			stmt->xt.target->xlate(xl, &params);
-			printf("%s", xt_xlate_get(xl));
+			nft_fprint(octx, "%s", xt_xlate_get(xl));
 		} else if (stmt->xt.target->print) {
 			printf("#");
 			stmt->xt.target->print(NULL, stmt->xt.target->t, 0);
-- 
2.18.1




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux