Skip to content
Commit e86e5138 authored by Yonghong Song's avatar Yonghong Song Committed by Daniel Borkmann
Browse files

tools/bpf: support __int128 in bpftool map pretty dumper



For formatted output, currently when json is enabled, the decimal
number is required. Similar to kernel bpffs printout,
for int128 numbers, only hex numbers are dumped, which are
quoted as strings.

The below is an example to show plain and json pretty print
based on the map in test_btf pretty print test.

  $ bpftool m s
  75: hash  name pprint_test_has  flags 0x0
        key 4B  value 112B  max_entries 4  memlock 4096B
  $ bpftool m d id 75
  ......
    {
        "key": 3,
        "value": {
            "ui32": 3,
            "ui16": 0,
            "si32": -3,
            "unused_bits2a": 0x3,
            "bits28": 0x3,
            "unused_bits2b": 0x3,
            "": {
                "ui64": 3,
                "ui8a": [3,0,0,0,0,0,0,0
                ]
            },
            "aenum": 3,
            "ui32b": 4,
            "bits2c": 0x1,
            "si128a": 0x3,
            "si128b": 0xfffffffd,
            "bits3": 0x3,
            "bits80": 0x10000000000000003,
            "ui128": 0x20000000000000003
        }
    },
  ......

  $ bptfool -p -j m d id 75
  ......
  {
        "key": ["0x03","0x00","0x00","0x00"
        ],
        "value": ["0x03","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                  "0xfd","0xff","0xff","0xff","0x0f","0x00","0x00","0xc0",
                  "0x03","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                  "0x03","0x00","0x00","0x00","0x04","0x00","0x00","0x00",
                  "0x01","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                  "0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                  "0x03","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                  "0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                  "0xfd","0xff","0xff","0xff","0x00","0x00","0x00","0x00",
                  "0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                  "0x1b","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                  "0x08","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                  "0x03","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                  "0x02","0x00","0x00","0x00","0x00","0x00","0x00","0x00"
        ],
        "formatted": {
            "key": 3,
            "value": {
                "ui32": 3,
                "ui16": 0,
                "si32": -3,
                "unused_bits2a": "0x3",
                "bits28": "0x3",
                "unused_bits2b": "0x3",
                "": {
                    "ui64": 3,
                    "ui8a": [3,0,0,0,0,0,0,0
                    ]
                },
                "aenum": 3,
                "ui32b": 4,
                "bits2c": "0x1",
                "si128a": "0x3",
                "si128b": "0xfffffffd",
                "bits3": "0x3",
                "bits80": "0x10000000000000003",
                "ui128": "0x20000000000000003"
            }
        }
    }
  ......

Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
Signed-off-by: default avatarYonghong Song <yhs@fb.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 4df3a1d0
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment