]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc: Change of json format in tc-fw
authorTakanori Hirano <me@hrntknr.net>
Sun, 11 Feb 2024 01:38:48 +0000 (01:38 +0000)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 19 Feb 2024 18:08:49 +0000 (10:08 -0800)
In the case of a process such as mapping a json to a structure,
it can be difficult if the keys have the same name but different types.
Since handle is used in hex string, change it to fw.

Signed-off-by: Takanori Hirano <me@hrntknr.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/f_fw.c

index fe99cd42eb6cceb91c29966b66bf29325b629fbe..5e72e526b175373f15274bacf4cfc9c706ba0ee3 100644 (file)
--- a/tc/f_fw.c
+++ b/tc/f_fw.c
@@ -124,16 +124,16 @@ static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
        if (handle || tb[TCA_FW_MASK]) {
                __u32 mark = 0, mask = 0;
 
-               open_json_object("handle");
+               open_json_object("fw");
                if (handle)
                        mark = handle;
                if (tb[TCA_FW_MASK] &&
                    (mask = rta_getattr_u32(tb[TCA_FW_MASK])) != 0xFFFFFFFF) {
-                       print_hex(PRINT_ANY, "mark", "handle 0x%x", mark);
-                       print_hex(PRINT_ANY, "mask", "/0x%x ", mask);
+                       print_0xhex(PRINT_ANY, "mark", "handle 0x%x", mark);
+                       print_0xhex(PRINT_ANY, "mask", "/0x%x ", mask);
                } else {
-                       print_hex(PRINT_ANY, "mark", "handle 0x%x ", mark);
-                       print_hex(PRINT_JSON, "mask", NULL, 0xFFFFFFFF);
+                       print_0xhex(PRINT_ANY, "mark", "handle 0x%x ", mark);
+                       print_0xhex(PRINT_JSON, "mask", NULL, 0xFFFFFFFF);
                }
                close_json_object();
        }
@@ -155,7 +155,7 @@ static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
        }
 
        if (tb[TCA_FW_ACT]) {
-               print_string(PRINT_FP, NULL, "\n", "");
+               print_nl();
                tc_print_action(f, tb[TCA_FW_ACT], 0);
        }
        return 0;