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