1. 18 4月, 2018 1 次提交
    • Q
      tools: bpftool: make it easier to feed hex bytes to bpftool · 0c90f224
      Quentin Monnet 提交于
      bpftool uses hexadecimal values when it dumps map contents:
      
          # bpftool map dump id 1337
          key: ff 13 37 ff  value: a1 b2 c3 d4 ff ff ff ff
          Found 1 element
      
      In order to lookup or update values with bpftool, the natural reflex is
      then to copy and paste the values to the command line, and to try to run
      something like:
      
          # bpftool map update id 1337 key ff 13 37 ff \
                  value 00 00 00 00 00 00 1a 2b
          Error: error parsing byte: ff
      
      bpftool complains, because it uses strtoul() with a 0 base to parse the
      bytes, and that without a "0x" prefix, the bytes are considered as
      decimal values (or even octal if they start with "0").
      
      To feed hexadecimal values instead, one needs to add "0x" prefixes
      everywhere necessary:
      
          # bpftool map update id 1337 key 0xff 0x13 0x37 0xff \
                  value 0 0 0 0 0 0 0x1a 0x2b
      
      To make it easier to use hexadecimal values, add an optional "hex"
      keyword to put after "key" or "value" to tell bpftool to consider the
      digits as hexadecimal. We can now do:
      
          # bpftool map update id 1337 key hex ff 13 37 ff \
                  value hex 0 0 0 0 0 0 1a 2b
      
      Without the "hex" keyword, the bytes are still parsed according to
      normal integer notation (decimal if no prefix, or hexadecimal or octal
      if "0x" or "0" prefix is used, respectively).
      
      The patch also add related documentation and bash completion for the
      "hex" keyword.
      Suggested-by: NDaniel Borkmann <daniel@iogearbox.net>
      Suggested-by: NDavid Beckett <david.beckett@netronome.com>
      Signed-off-by: NQuentin Monnet <quentin.monnet@netronome.com>
      Acked-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      0c90f224
  2. 25 3月, 2018 1 次提交
  3. 20 1月, 2018 1 次提交
  4. 19 1月, 2018 1 次提交
  5. 04 1月, 2018 1 次提交
  6. 23 12月, 2017 2 次提交
  7. 11 11月, 2017 2 次提交
    • P
      tools: bpftool: optionally show filenames of pinned objects · c541b734
      Prashant Bhole 提交于
      Making it optional to show file names of pinned objects because
      it scans complete bpf-fs filesystem which is costly.
      Added option -f|--bpffs. Documentation updated.
      Signed-off-by: NPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c541b734
    • 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
  8. 24 10月, 2017 4 次提交
  9. 22 10月, 2017 2 次提交
  10. 05 10月, 2017 1 次提交