|
|
bacbc8 |
From 68c1ca177513a94f41ea974de9a48259e8ca5866 Mon Sep 17 00:00:00 2001
|
|
|
bacbc8 |
From: Florian Westphal <fw@strlen.de>
|
|
|
bacbc8 |
Date: Tue, 6 Nov 2018 16:06:26 +0100
|
|
|
bacbc8 |
Subject: [PATCH] xt: pass octx to translate function
|
|
|
bacbc8 |
|
|
|
bacbc8 |
We can't use it when no translation is available as libxtables will
|
|
|
bacbc8 |
use plain printf(), but when translation is available we can.
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Signed-off-by: Florian Westphal <fw@strlen.de>
|
|
|
bacbc8 |
(cherry picked from commit c15c2869168d71d07aca0221e1b37f0c5da54547)
|
|
|
bacbc8 |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
bacbc8 |
---
|
|
|
bacbc8 |
include/xt.h | 5 +++--
|
|
|
bacbc8 |
src/statement.c | 2 +-
|
|
|
bacbc8 |
src/xt.c | 6 +++---
|
|
|
bacbc8 |
3 files changed, 7 insertions(+), 6 deletions(-)
|
|
|
bacbc8 |
|
|
|
bacbc8 |
diff --git a/include/xt.h b/include/xt.h
|
|
|
bacbc8 |
index 753511e635080..549eb9fe41531 100644
|
|
|
bacbc8 |
--- a/include/xt.h
|
|
|
bacbc8 |
+++ b/include/xt.h
|
|
|
bacbc8 |
@@ -6,9 +6,10 @@ struct netlink_parse_ctx;
|
|
|
bacbc8 |
struct nftnl_expr;
|
|
|
bacbc8 |
struct rule_pp_ctx;
|
|
|
bacbc8 |
struct rule;
|
|
|
bacbc8 |
+struct output_ctx;
|
|
|
bacbc8 |
|
|
|
bacbc8 |
#ifdef HAVE_LIBXTABLES
|
|
|
bacbc8 |
-void xt_stmt_xlate(const struct stmt *stmt);
|
|
|
bacbc8 |
+void xt_stmt_xlate(const struct stmt *stmt, struct output_ctx *octx);
|
|
|
bacbc8 |
void xt_stmt_release(const struct stmt *stmt);
|
|
|
bacbc8 |
|
|
|
bacbc8 |
void netlink_parse_target(struct netlink_parse_ctx *ctx,
|
|
|
bacbc8 |
@@ -20,7 +21,7 @@ void netlink_parse_match(struct netlink_parse_ctx *ctx,
|
|
|
bacbc8 |
void stmt_xt_postprocess(struct rule_pp_ctx *rctx, struct stmt *stmt,
|
|
|
bacbc8 |
struct rule *rule);
|
|
|
bacbc8 |
#else
|
|
|
bacbc8 |
-static inline void xt_stmt_xlate(const struct stmt *stmt) {}
|
|
|
bacbc8 |
+static inline void xt_stmt_xlate(const struct stmt *stmt, struct output_ctx *octx) {}
|
|
|
bacbc8 |
static inline void xt_stmt_release(const struct stmt *stmt) {}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
#include <erec.h>
|
|
|
bacbc8 |
diff --git a/src/statement.c b/src/statement.c
|
|
|
bacbc8 |
index 1b889e77cca20..29b73f9fba4ae 100644
|
|
|
bacbc8 |
--- a/src/statement.c
|
|
|
bacbc8 |
+++ b/src/statement.c
|
|
|
bacbc8 |
@@ -780,7 +780,7 @@ struct stmt *fwd_stmt_alloc(const struct location *loc)
|
|
|
bacbc8 |
|
|
|
bacbc8 |
static void xt_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
|
|
|
bacbc8 |
{
|
|
|
bacbc8 |
- xt_stmt_xlate(stmt);
|
|
|
bacbc8 |
+ xt_stmt_xlate(stmt, octx);
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
static void xt_stmt_destroy(struct stmt *stmt)
|
|
|
bacbc8 |
diff --git a/src/xt.c b/src/xt.c
|
|
|
bacbc8 |
index 298a94d51e8a0..9b7d4c29194aa 100644
|
|
|
bacbc8 |
--- a/src/xt.c
|
|
|
bacbc8 |
+++ b/src/xt.c
|
|
|
bacbc8 |
@@ -26,7 +26,7 @@
|
|
|
bacbc8 |
#include <linux/netfilter_arp/arp_tables.h>
|
|
|
bacbc8 |
#include <linux/netfilter_bridge/ebtables.h>
|
|
|
bacbc8 |
|
|
|
bacbc8 |
-void xt_stmt_xlate(const struct stmt *stmt)
|
|
|
bacbc8 |
+void xt_stmt_xlate(const struct stmt *stmt, struct output_ctx *octx)
|
|
|
bacbc8 |
{
|
|
|
bacbc8 |
struct xt_xlate *xl = xt_xlate_alloc(10240);
|
|
|
bacbc8 |
|
|
|
bacbc8 |
@@ -40,7 +40,7 @@ void xt_stmt_xlate(const struct stmt *stmt)
|
|
|
bacbc8 |
};
|
|
|
bacbc8 |
|
|
|
bacbc8 |
stmt->xt.match->xlate(xl, ¶ms);
|
|
|
bacbc8 |
- printf("%s", xt_xlate_get(xl));
|
|
|
bacbc8 |
+ nft_print(octx, "%s", xt_xlate_get(xl));
|
|
|
bacbc8 |
} else if (stmt->xt.match->print) {
|
|
|
bacbc8 |
printf("#");
|
|
|
bacbc8 |
stmt->xt.match->print(&stmt->xt.entry,
|
|
|
bacbc8 |
@@ -57,7 +57,7 @@ void xt_stmt_xlate(const struct stmt *stmt)
|
|
|
bacbc8 |
};
|
|
|
bacbc8 |
|
|
|
bacbc8 |
stmt->xt.target->xlate(xl, ¶ms);
|
|
|
bacbc8 |
- printf("%s", xt_xlate_get(xl));
|
|
|
bacbc8 |
+ nft_print(octx, "%s", xt_xlate_get(xl));
|
|
|
bacbc8 |
} else if (stmt->xt.target->print) {
|
|
|
bacbc8 |
printf("#");
|
|
|
bacbc8 |
stmt->xt.target->print(NULL, stmt->xt.target->t, 0);
|
|
|
bacbc8 |
--
|
|
|
bacbc8 |
2.21.0
|
|
|
bacbc8 |
|