1. 14 12月, 2017 1 次提交
  2. 11 11月, 2017 2 次提交
    • P
      tools: bpftool: show filenames of pinned objects · 4990f1f4
      Prashant Bhole 提交于
      Added support to show filenames of pinned objects.
      
      For example:
      
      root@test# ./bpftool prog
      3: tracepoint  name tracepoint__irq  tag f677a7dd722299a3
          loaded_at Oct 26/11:39  uid 0
          xlated 160B  not jited  memlock 4096B  map_ids 4
          pinned /sys/fs/bpf/softirq_prog
      
      4: tracepoint  name tracepoint__irq  tag ea5dc530d00b92b6
          loaded_at Oct 26/11:39  uid 0
          xlated 392B  not jited  memlock 4096B  map_ids 4,6
      
      root@test# ./bpftool --json --pretty prog
      [{
              "id": 3,
              "type": "tracepoint",
              "name": "tracepoint__irq",
              "tag": "f677a7dd722299a3",
              "loaded_at": "Oct 26/11:39",
              "uid": 0,
              "bytes_xlated": 160,
              "jited": false,
              "bytes_memlock": 4096,
              "map_ids": [4
              ],
              "pinned": ["/sys/fs/bpf/softirq_prog"
              ]
          },{
              "id": 4,
              "type": "tracepoint",
              "name": "tracepoint__irq",
              "tag": "ea5dc530d00b92b6",
              "loaded_at": "Oct 26/11:39",
              "uid": 0,
              "bytes_xlated": 392,
              "jited": false,
              "bytes_memlock": 4096,
              "map_ids": [4,6
              ],
              "pinned": []
          }
      ]
      
      root@test# ./bpftool map
      4: hash  name start  flags 0x0
          key 4B  value 16B  max_entries 10240  memlock 1003520B
          pinned /sys/fs/bpf/softirq_map1
      5: hash  name iptr  flags 0x0
          key 4B  value 8B  max_entries 10240  memlock 921600B
      
      root@test# ./bpftool --json --pretty map
      [{
              "id": 4,
              "type": "hash",
              "name": "start",
              "flags": 0,
              "bytes_key": 4,
              "bytes_value": 16,
              "max_entries": 10240,
              "bytes_memlock": 1003520,
              "pinned": ["/sys/fs/bpf/softirq_map1"
              ]
          },{
              "id": 5,
              "type": "hash",
              "name": "iptr",
              "flags": 0,
              "bytes_key": 4,
              "bytes_value": 8,
              "max_entries": 10240,
              "bytes_memlock": 921600,
              "pinned": []
          }
      ]
      Signed-off-by: NPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4990f1f4
    • P
      tools: bpftool: open pinned object without type check · 18527196
      Prashant Bhole 提交于
      This was needed for opening any file in bpf-fs without knowing
      its object type
      Signed-off-by: NPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      18527196
  3. 05 11月, 2017 1 次提交
  4. 26 10月, 2017 1 次提交
  5. 24 10月, 2017 2 次提交
    • Q
      tools: bpftool: turn err() and info() macros into functions · 9a5ab8bf
      Quentin Monnet 提交于
      Turn err() and info() macros into functions.
      
      In order to avoid naming conflicts with variables in the code, rename
      them as p_err() and p_info() respectively.
      
      The behavior of these functions is similar to the one of the macros for
      plain output. However, when JSON output is requested, these macros
      return a JSON-formatted "error" object instead of printing a message to
      stderr.
      
      To handle error messages correctly with JSON, a modification was brought
      to their behavior nonetheless: the functions now append a end-of-line
      character at the end of the message. This way, we can remove end-of-line
      characters at the end of the argument strings, and not have them in the
      JSON output.
      
      All error messages are formatted to hold in a single call to p_err(), in
      order to produce a single JSON field.
      Signed-off-by: NQuentin Monnet <quentin.monnet@netronome.com>
      Acked-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9a5ab8bf
    • Q
      tools: bpftool: add JSON output for `bpftool prog dump xlated *` command · f05e2c32
      Quentin Monnet 提交于
      Add a new printing function to dump translated eBPF instructions as
      JSON. As for plain output, opcodes are printed only on request (when
      `opcodes` is provided on the command line).
      
      The disassembled output is generated by the same code that is used by
      the kernel verifier.
      
      Example output:
      
          $ bpftool --json --pretty prog dump xlated id 1
          [{
                  "disasm": "(bf) r6 = r1"
              },{
                  "disasm": "(61) r7 = *(u32 *)(r6 +16)"
              },{
                  "disasm": "(95) exit"
              }
          ]
      
          $ bpftool --json --pretty prog dump xlated id 1 opcodes
          [{
                  "disasm": "(bf) r6 = r1",
                  "opcodes": {
                      "code": "0xbf",
                      "src_reg": "0x1",
                      "dst_reg": "0x6",
                      "off": ["0x00","0x00"
                      ],
                      "imm": ["0x00","0x00","0x00","0x00"
                      ]
                  }
              },{
                  "disasm": "(61) r7 = *(u32 *)(r6 +16)",
                  "opcodes": {
                      "code": "0x61",
                      "src_reg": "0x6",
                      "dst_reg": "0x7",
                      "off": ["0x10","0x00"
                      ],
                      "imm": ["0x00","0x00","0x00","0x00"
                      ]
                  }
              },{
                  "disasm": "(95) exit",
                  "opcodes": {
                      "code": "0x95",
                      "src_reg": "0x0",
                      "dst_reg": "0x0",
                      "off": ["0x00","0x00"
                      ],
                      "imm": ["0x00","0x00","0x00","0x00"
                      ]
                  }
              }
          ]
      Signed-off-by: NQuentin Monnet <quentin.monnet@netronome.com>
      Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f05e2c32
  6. 05 10月, 2017 1 次提交