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

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