Blame SOURCES/0005-monitor-Make-trace-events-respect-output_fp.patch

ad45ff
From 696fd8bbb2c654a1d16849fef0f0ae362739def4 Mon Sep 17 00:00:00 2001
ad45ff
From: Phil Sutter <psutter@redhat.com>
ad45ff
Date: Wed, 20 Jun 2018 09:22:00 +0200
ad45ff
Subject: [PATCH] monitor: Make trace events respect output_fp
ad45ff
ad45ff
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1504157
ad45ff
Upstream Status: nftables commit 657472843e7a7
ad45ff
ad45ff
commit 657472843e7a7a4bc7f756356e6636b1f197b745
ad45ff
Author: Phil Sutter <phil@nwl.cc>
ad45ff
Date:   Wed Feb 28 16:04:27 2018 +0100
ad45ff
ad45ff
    monitor: Make trace events respect output_fp
ad45ff
ad45ff
    Seems like this was incompletely converted, part of the output went to
ad45ff
    output_fp already.
ad45ff
ad45ff
    Signed-off-by: Phil Sutter <phil@nwl.cc>
ad45ff
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
ad45ff
---
ad45ff
 src/netlink.c | 38 +++++++++++++++++++++-----------------
ad45ff
 1 file changed, 21 insertions(+), 17 deletions(-)
ad45ff
ad45ff
diff --git a/src/netlink.c b/src/netlink.c
ad45ff
index 5d6f5ce..d839ded 100644
ad45ff
--- a/src/netlink.c
ad45ff
+++ b/src/netlink.c
ad45ff
@@ -2587,14 +2587,18 @@ static void netlink_events_cache_update(struct netlink_mon_handler *monh,
ad45ff
 	}
ad45ff
 }
ad45ff
 
ad45ff
-static void trace_print_hdr(const struct nftnl_trace *nlt)
ad45ff
+static void trace_print_hdr(const struct nftnl_trace *nlt,
ad45ff
+			    struct output_ctx *octx)
ad45ff
 {
ad45ff
-	printf("trace id %08x ", nftnl_trace_get_u32(nlt, NFTNL_TRACE_ID));
ad45ff
-	printf("%s ", family2str(nftnl_trace_get_u32(nlt, NFTNL_TRACE_FAMILY)));
ad45ff
+	nft_print(octx, "trace id %08x %s ",
ad45ff
+		  nftnl_trace_get_u32(nlt, NFTNL_TRACE_ID),
ad45ff
+		  family2str(nftnl_trace_get_u32(nlt, NFTNL_TRACE_FAMILY)));
ad45ff
 	if (nftnl_trace_is_set(nlt, NFTNL_TRACE_TABLE))
ad45ff
-		printf("%s ", nftnl_trace_get_str(nlt, NFTNL_TRACE_TABLE));
ad45ff
+		nft_print(octx, "%s ",
ad45ff
+			  nftnl_trace_get_str(nlt, NFTNL_TRACE_TABLE));
ad45ff
 	if (nftnl_trace_is_set(nlt, NFTNL_TRACE_CHAIN))
ad45ff
-		printf("%s ", nftnl_trace_get_str(nlt, NFTNL_TRACE_CHAIN));
ad45ff
+		nft_print(octx, "%s ",
ad45ff
+			  nftnl_trace_get_str(nlt, NFTNL_TRACE_CHAIN));
ad45ff
 }
ad45ff
 
ad45ff
 static void trace_print_expr(const struct nftnl_trace *nlt, unsigned int attr,
ad45ff
@@ -2611,7 +2615,7 @@ static void trace_print_expr(const struct nftnl_trace *nlt, unsigned int attr,
ad45ff
 	rel  = relational_expr_alloc(&netlink_location, OP_EQ, lhs, rhs);
ad45ff
 
ad45ff
 	expr_print(rel, octx);
ad45ff
-	printf(" ");
ad45ff
+	nft_print(octx, " ");
ad45ff
 	expr_free(rel);
ad45ff
 }
ad45ff
 
ad45ff
@@ -2661,12 +2665,12 @@ static void trace_print_rule(const struct nftnl_trace *nlt,
ad45ff
 	if (!rule)
ad45ff
 		return;
ad45ff
 
ad45ff
-	trace_print_hdr(nlt);
ad45ff
-	printf("rule ");
ad45ff
+	trace_print_hdr(nlt, octx);
ad45ff
+	nft_print(octx, "rule ");
ad45ff
 	rule_print(rule, octx);
ad45ff
-	printf(" (");
ad45ff
+	nft_print(octx, " (");
ad45ff
 	trace_print_verdict(nlt, octx);
ad45ff
-	printf(")\n");
ad45ff
+	nft_print(octx, ")\n");
ad45ff
 }
ad45ff
 
ad45ff
 static void trace_gen_stmts(struct list_head *stmts,
ad45ff
@@ -2775,9 +2779,9 @@ static void trace_print_packet(const struct nftnl_trace *nlt,
ad45ff
 	uint32_t nfproto;
ad45ff
 	struct stmt *stmt, *next;
ad45ff
 
ad45ff
-	trace_print_hdr(nlt);
ad45ff
+	trace_print_hdr(nlt, octx);
ad45ff
 
ad45ff
-	printf("packet: ");
ad45ff
+	nft_print(octx, "packet: ");
ad45ff
 	if (nftnl_trace_is_set(nlt, NFTNL_TRACE_IIF))
ad45ff
 		trace_print_expr(nlt, NFTNL_TRACE_IIF,
ad45ff
 				 meta_expr_alloc(&netlink_location,
ad45ff
@@ -2813,10 +2817,10 @@ static void trace_print_packet(const struct nftnl_trace *nlt,
ad45ff
 
ad45ff
 	list_for_each_entry_safe(stmt, next, &stmts, list) {
ad45ff
 		stmt_print(stmt, octx);
ad45ff
-		printf(" ");
ad45ff
+		nft_print(octx, " ");
ad45ff
 		stmt_free(stmt);
ad45ff
 	}
ad45ff
-	printf("\n");
ad45ff
+	nft_print(octx, "\n");
ad45ff
 }
ad45ff
 
ad45ff
 static int netlink_events_trace_cb(const struct nlmsghdr *nlh, int type,
ad45ff
@@ -2844,11 +2848,11 @@ static int netlink_events_trace_cb(const struct nlmsghdr *nlh, int type,
ad45ff
 		break;
ad45ff
 	case NFT_TRACETYPE_POLICY:
ad45ff
 	case NFT_TRACETYPE_RETURN:
ad45ff
-		trace_print_hdr(nlt);
ad45ff
+		trace_print_hdr(nlt, monh->ctx->octx);
ad45ff
 
ad45ff
 		if (nftnl_trace_is_set(nlt, NFTNL_TRACE_VERDICT)) {
ad45ff
 			trace_print_verdict(nlt, monh->ctx->octx);
ad45ff
-			printf(" ");
ad45ff
+			nft_mon_print(monh, " ");
ad45ff
 		}
ad45ff
 
ad45ff
 		if (nftnl_trace_is_set(nlt, NFTNL_TRACE_MARK))
ad45ff
@@ -2856,7 +2860,7 @@ static int netlink_events_trace_cb(const struct nlmsghdr *nlh, int type,
ad45ff
 					 meta_expr_alloc(&netlink_location,
ad45ff
 							 NFT_META_MARK),
ad45ff
 					 monh->ctx->octx);
ad45ff
-		printf("\n");
ad45ff
+		nft_mon_print(monh, "\n");
ad45ff
 		break;
ad45ff
 	}
ad45ff
 
ad45ff
-- 
ad45ff
1.8.3.1
ad45ff