Skip to contentSkip to conversation

iproute2 - ip -d -j tuntap outputs malformed JSON

BUG Zhengyi Fu 2 participants 3 messages Nov 21, 2025 – Nov 23, 2025

Subsystems (2)
lore
Share & tools
lore

Zhengyi Fu

author
#0 lore raw

Hi iproute2 maintainers,

    $ sudo ip -d -j tuntap
    [{"ifname":"tun0","flags":["tun","persist"],"processes":["name":"ssh","pid":86812]}]

The “processes” value looks like it should be an array of objects, so the inner braces seem to be missing:

    [{"ifname":"tun0","flags":["tun","persist"],"processes":[{"name":"ssh","pid":86812}]}]

Could you confirm whether this is a formatting bug or if the output is intentionally flattened?

Thanks!

#1 lore raw
Quoted 8 lines · On Fri, 21 Nov 2025 12:25:41 +0800 Zhengyi Fu <[email protected]> wrote:

Hi iproute2 maintainers,

    $ sudo ip -d -j tuntap
    [{"ifname":"tun0","flags":["tun","persist"],"processes":["name":"ssh","pid":86812]}]

The “processes” value looks like it should be an array of objects, so the inner braces seem to be missing:

Quoted 7 lines
    [{"ifname":"tun0","flags":["tun","persist"],"processes":[{"name":"ssh","pid":86812}]}]

Could you confirm whether this is a formatting bug or if the output is intentionally flattened?

Thanks!

It should be an array of objects. You can confirm by seeing the output with multiple processes.

Does this fix it?

ip/iptuntap.c +2 -0
index b7018a6f..6718ec6c 100644
@@ -314,6 +314,7 @@ static void show_processes(const char *name)
                                   !strcmp(name, value)) {
                                SPRINT_BUF(pname);
 
+                               open_json_object(NULL);
                                if (get_task_name(pid, pname, sizeof(pname)))
                                        print_string(PRINT_ANY, "name",
                                                     "%s", "<NULL>");
@@ -322,6 +323,7 @@ static void show_processes(const char *name)
                                                     "%s", pname);
 
                                print_uint(PRINT_ANY, "pid", "(%d)", pid);
+                               close_json_object();
                        }
 
                        free(key);
author
#2 lore raw
Quoted 47 lines · Stephen Hemminger
Quoted 10 lines · On Fri, 21 Nov 2025 12:25:41 +0800 Zhengyi Fu <[email protected]> wrote:

Hi iproute2 maintainers,

    $ sudo ip -d -j tuntap

[{"ifname":"tun0","flags":["tun","persist"],"processes":["name":"ssh","pid":86812]}]

The “processes” value looks like it should be an array of objects, so the inner braces seem to be missing:

Quoted 7 lines

[{"ifname":"tun0","flags":["tun","persist"],"processes":[{"name":"ssh","pid":86812}]}]

Could you confirm whether this is a formatting bug or if the output is intentionally flattened?

Thanks!

It should be an array of objects. You can confirm by seeing the output with multiple processes.

Does this fix it?

ip/iptuntap.c +1 -0
index b7018a6f..6718ec6c 100644
@@ -314,6 +314,7 @@ static void show_processes(const char *name)
                                   !strcmp(name, value)) {
                                SPRINT_BUF(pname);
 
+                               open_json_object(NULL);
                                if (get_task_name(pid, pname, 
 sizeof(pname)))
                                        print_string(PRINT_ANY, "name",
                                                     "%s", "<NULL>");
ip/iptuntap.c +1 -0
@@ -322,6 +323,7 @@ static void show_processes(const char *name)
                                                     "%s", pname);
 
                                print_uint(PRINT_ANY, "pid", "(%d)", 
 pid);
+                               close_json_object();
                        }
 
Quoted 1 line
                        free(key);

Yes, it does. Thanks!