1. 24 Apr, 2024 25 commits
  2. 22 Apr, 2024 2 commits
  3. 21 Apr, 2024 2 commits
  4. 20 Apr, 2024 7 commits
  5. 18 Apr, 2024 1 commit
  6. 17 Apr, 2024 2 commits
    • Quentin Deslandes's avatar
      libbpf: Fix dump of subsequent char arrays · e739e01d
      Quentin Deslandes authored
      When dumping a character array, libbpf will watch for a '\0' and set
      is_array_terminated=true if found. This prevents libbpf from printing
      the remaining characters of the array, treating it as a nul-terminated
      string.
      
      However, once this flag is set, it's never reset, leading to subsequent
      characters array not being printed properly:
      
      .str_multi = (__u8[2][16])[
          [
              'H',
              'e',
              'l',
          ],
      ],
      
      This patch saves the is_array_terminated flag and restores its
      default (false) value before looping over the elements of an array,
      then restores it afterward. This way, libbpf's behavior is unchanged
      when dumping the characters of an array, but subsequent arrays are
      printed properly:
      
      .str_multi = (__u8[2][16])[
          [
              'H',
              'e',
              'l',
          ],
          [
              'l',
              'o',
          ],
      ],
      Signed-off-by: default avatarQuentin Deslandes <qde@naccy.de>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20240413211258.134421-3-qde@naccy.de
      e739e01d
    • Quentin Deslandes's avatar
      libbpf: Fix misaligned array closing bracket · 9213e529
      Quentin Deslandes authored
      In btf_dump_array_data(), libbpf will call btf_dump_dump_type_data() for
      each element. For an array of characters, each element will be
      processed the following way:
      
      - btf_dump_dump_type_data() is called to print the character
      - btf_dump_data_pfx() prefixes the current line with the proper number
        of indentations
      - btf_dump_int_data() is called to print the character
      - After the last character is printed, btf_dump_dump_type_data() calls
        btf_dump_data_pfx() before writing the closing bracket
      
      However, for an array containing characters, btf_dump_int_data() won't
      print any '\0' and subsequent characters. This leads to situations where
      the line prefix is written, no character is added, then the prefix is
      written again before adding the closing bracket:
      
      (struct sk_metadata){
          .str_array = (__u8[14])[
              'H',
              'e',
              'l',
              'l',
              'o',
                      ],
      
      This change solves this issue by printing the '\0' character, which
      has two benefits:
      
      - The bracket closing the array is properly aligned
      - It's clear from a user point of view that libbpf uses '\0' as a
        terminator for arrays of characters.
      Signed-off-by: default avatarQuentin Deslandes <qde@naccy.de>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20240413211258.134421-2-qde@naccy.de
      9213e529
  7. 16 Apr, 2024 1 commit
    • Quentin Monnet's avatar
      bpftool: Address minor issues in bash completion · ad2d22b6
      Quentin Monnet authored
      This commit contains a series of clean-ups and fixes for bpftool's bash
      completion file:
      
      - Make sure all local variables are declared as such.
      - Make sure variables are initialised before being read.
      - Update ELF section ("maps" -> ".maps") for looking up map names in
        object files.
      - Fix call to _init_completion.
      - Move definition for MAP_TYPE and PROG_TYPE higher up in the scope to
        avoid defining them multiple times, reuse MAP_TYPE where relevant.
      - Simplify completion for "duration" keyword in "bpftool prog profile".
      - Fix completion for "bpftool struct_ops register" and "bpftool link
        (pin|detach)" where we would repeatedly suggest file names instead of
        suggesting just one name.
      - Fix completion for "bpftool iter pin ... map MAP" to account for the
        "map" keyword.
      - Add missing "detach" suggestion for "bpftool link".
      Signed-off-by: default avatarQuentin Monnet <qmo@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20240413011427.14402-3-qmo@kernel.org
      ad2d22b6