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

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