tools: bpftool: change time format for program 'loaded at:' information
authorQuentin Monnet <quentin.monnet@netronome.com>
Tue, 1 May 2018 20:18:38 +0000 (21:18 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 1 May 2018 21:24:20 +0000 (14:24 -0700)
commita3fe1f6f2adaa01c620793666d489a584211ecba
treeca21fadefa8b75bd133df1c68fc8d03e5bc4bd65
parentc0dd967818a2b8106771a7c9fb7ef48d7be8a9d4
tools: bpftool: change time format for program 'loaded at:' information

To make eBPF program load time easier to parse from "bpftool prog"
output for machines, change the time format used by the program. The
format now differs for plain and JSON version:

- Plain version uses a string formatted according to ISO 8601.
- JSON uses the number of seconds since the Epoch, wich is less friendly
  for humans but even easier to process.

Example output:

    # ./bpftool prog
    41298: xdp  tag a04f5eef06a7f555 dev foo
            loaded_at 2018-04-18T17:19:47+0100  uid 0
            xlated 16B  not jited  memlock 4096B

    # ./bpftool prog -p
    [{
            "id": 41298,
            "type": "xdp",
            "tag": "a04f5eef06a7f555",
            "gpl_compatible": false,
            "dev": {
                "ifindex": 14,
                "ns_dev": 3,
                "ns_inode": 4026531993,
                "ifname": "foo"
            },
            "loaded_at": 1524068387,
            "uid": 0,
            "bytes_xlated": 16,
            "jited": false,
            "bytes_memlock": 4096
        }
    ]

Previously, "Apr 18/17:19" would be used at both places.

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/bpf/bpftool/prog.c