Blame SOURCES/0056-json-Simplify-non-tcpopt-exthdr-printing-a-bit.patch

cf8614
From 2026f7d056679508f8506fbba7f578aa15af7c05 Mon Sep 17 00:00:00 2001
cf8614
From: Phil Sutter <psutter@redhat.com>
cf8614
Date: Mon, 12 Jul 2021 16:32:27 +0200
cf8614
Subject: [PATCH] json: Simplify non-tcpopt exthdr printing a bit
cf8614
cf8614
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1979334
cf8614
Upstream Status: nftables commit fd81d3ec3ae8b
cf8614
cf8614
commit fd81d3ec3ae8b8d1d54a708d63b2dab2c8508c90
cf8614
Author: Phil Sutter <phil@nwl.cc>
cf8614
Date:   Tue May 4 13:18:11 2021 +0200
cf8614
cf8614
    json: Simplify non-tcpopt exthdr printing a bit
cf8614
cf8614
    This was just duplicate code apart from the object's name.
cf8614
cf8614
    Signed-off-by: Phil Sutter <phil@nwl.cc>
cf8614
---
cf8614
 src/json.c | 18 +++++++-----------
cf8614
 1 file changed, 7 insertions(+), 11 deletions(-)
cf8614
cf8614
diff --git a/src/json.c b/src/json.c
cf8614
index b77c6d2..a6d0716 100644
cf8614
--- a/src/json.c
cf8614
+++ b/src/json.c
cf8614
@@ -684,21 +684,17 @@ json_t *exthdr_expr_json(const struct expr *expr, struct output_ctx *octx)
cf8614
 
cf8614
 		return json_pack("{s:o}", "tcp option", root);
cf8614
 	}
cf8614
-	if (expr->exthdr.op == NFT_EXTHDR_OP_IPV4) {
cf8614
-		root = json_pack("{s:s}", "name", desc);
cf8614
 
cf8614
-		if (!is_exists)
cf8614
-			json_object_set_new(root, "field", json_string(field));
cf8614
-
cf8614
-		return json_pack("{s:o}", "ip option", root);
cf8614
-	}
cf8614
-
cf8614
-	root = json_pack("{s:s}",
cf8614
-			 "name", desc);
cf8614
+	root = json_pack("{s:s}", "name", desc);
cf8614
 	if (!is_exists)
cf8614
 		json_object_set_new(root, "field", json_string(field));
cf8614
 
cf8614
-	return json_pack("{s:o}", "exthdr", root);
cf8614
+	switch (expr->exthdr.op) {
cf8614
+	case NFT_EXTHDR_OP_IPV4:
cf8614
+		return json_pack("{s:o}", "ip option", root);
cf8614
+	default:
cf8614
+		return json_pack("{s:o}", "exthdr", root);
cf8614
+	}
cf8614
 }
cf8614
 
cf8614
 json_t *verdict_expr_json(const struct expr *expr, struct output_ctx *octx)
cf8614
-- 
cf8614
2.31.1
cf8614