Skip to content
  1. Jan 22, 2022
  2. Jan 21, 2022
    • Di Zhu's avatar
      selftests: bpf: test BPF_PROG_QUERY for progs attached to sockmap · 820e6e22
      Di Zhu authored
      
      
      Add test for querying progs attached to sockmap. we use an existing
      libbpf query interface to query prog cnt before and after progs
      attaching to sockmap and check whether the queried prog id is right.
      
      Signed-off-by: default avatarDi Zhu <zhudi2@huawei.com>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/r/20220119014005.1209-2-zhudi2@huawei.com
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      820e6e22
    • Di Zhu's avatar
      bpf: support BPF_PROG_QUERY for progs attached to sockmap · 748cd572
      Di Zhu authored
      
      
      Right now there is no way to query whether BPF programs are
      attached to a sockmap or not.
      
      we can use the standard interface in libbpf to query, such as:
      bpf_prog_query(mapFd, BPF_SK_SKB_STREAM_PARSER, 0, NULL, ...);
      the mapFd is the fd of sockmap.
      
      Signed-off-by: default avatarDi Zhu <zhudi2@huawei.com>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/r/20220119014005.1209-1-zhudi2@huawei.com
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      748cd572
    • Alexei Starovoitov's avatar
      Merge branch 'libbpf: streamline netlink-based XDP APIs' · 3f712d46
      Alexei Starovoitov authored
      
      
      Andrii Nakryiko says:
      
      ====================
      
      Revamp existing low-level XDP APIs provided by libbpf to follow more
      consistent naming (new APIs follow bpf_tc_xxx() approach where it makes
      sense) and be extensible without ABI breakages (OPTS-based). See patch #1 for
      details, remaining patches switch bpftool, selftests/bpf and samples/bpf to
      new APIs.
      ====================
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      3f712d46
    • Andrii Nakryiko's avatar
      samples/bpf: adapt samples/bpf to bpf_xdp_xxx() APIs · d4e34bfc
      Andrii Nakryiko authored
      
      
      Use new bpf_xdp_*() APIs across all XDP-related BPF samples.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220120061422.2710637-5-andrii@kernel.org
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      d4e34bfc
    • Andrii Nakryiko's avatar
      selftests/bpf: switch to new libbpf XDP APIs · 54435652
      Andrii Nakryiko authored
      
      
      Switch to using new bpf_xdp_*() APIs across all selftests. Take
      advantage of a more straightforward and user-friendly semantics of
      old_prog_fd (0 means "don't care") in few places.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220120061422.2710637-4-andrii@kernel.org
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      54435652
    • Andrii Nakryiko's avatar
      bpftool: use new API for attaching XDP program · c86575ec
      Andrii Nakryiko authored
      
      
      Switch to new bpf_xdp_attach() API to avoid deprecation warnings.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220120061422.2710637-3-andrii@kernel.org
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      c86575ec
    • Andrii Nakryiko's avatar
      libbpf: streamline low-level XDP APIs · c359821a
      Andrii Nakryiko authored
      
      
      Introduce 4 new netlink-based XDP APIs for attaching, detaching, and
      querying XDP programs:
        - bpf_xdp_attach;
        - bpf_xdp_detach;
        - bpf_xdp_query;
        - bpf_xdp_query_id.
      
      These APIs replace bpf_set_link_xdp_fd, bpf_set_link_xdp_fd_opts,
      bpf_get_link_xdp_id, and bpf_get_link_xdp_info APIs ([0]). The latter
      don't follow a consistent naming pattern and some of them use
      non-extensible approaches (e.g., struct xdp_link_info which can't be
      modified without breaking libbpf ABI).
      
      The approach I took with these low-level XDP APIs is similar to what we
      did with low-level TC APIs. There is a nice duality of bpf_tc_attach vs
      bpf_xdp_attach, and so on. I left bpf_xdp_attach() to support detaching
      when -1 is specified for prog_fd for generality and convenience, but
      bpf_xdp_detach() is preferred due to clearer naming and associated
      semantics. Both bpf_xdp_attach() and bpf_xdp_detach() accept the same
      opts struct allowing to specify expected old_prog_fd.
      
      While doing the refactoring, I noticed that old APIs require users to
      specify opts with old_fd == -1 to declare "don't care about already
      attached XDP prog fd" condition. Otherwise, FD 0 is assumed, which is
      essentially never an intended behavior. So I made this behavior
      consistent with other kernel and libbpf APIs, in which zero FD means "no
      FD". This seems to be more in line with the latest thinking in BPF land
      and should cause less user confusion, hopefully.
      
      For querying, I left two APIs, both more generic bpf_xdp_query()
      allowing to query multiple IDs and attach mode, but also
      a specialization of it, bpf_xdp_query_id(), which returns only requested
      prog_id. Uses of prog_id returning bpf_get_link_xdp_id() were so
      prevalent across selftests and samples, that it seemed a very common use
      case and using bpf_xdp_query() for doing it felt very cumbersome with
      a highly branches if/else chain based on flags and attach mode.
      
      Old APIs are scheduled for deprecation in libbpf 0.8 release.
      
        [0] Closes: https://github.com/libbpf/libbpf/issues/309
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Link: https://lore.kernel.org/r/20220120061422.2710637-2-andrii@kernel.org
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      c359821a
    • Alexei Starovoitov's avatar
      Merge branch 'libbpf: deprecate legacy BPF map definitions' · 1713e33b
      Alexei Starovoitov authored
      
      
      Andrii Nakryiko says:
      
      ====================
      
      Officially deprecate legacy BPF map definitions in libbpf. They've been slated
      for deprecation for a while in favor of more powerful BTF-defined map
      definitions and this patch set adds warnings and a way to enforce this in
      libbpf through LIBBPF_STRICT_MAP_DEFINITIONS strict mode flag.
      
      Selftests are fixed up and updated, BPF documentation is updated, bpftool's
      strict mode usage is adjusted to avoid breaking users unnecessarily.
      
      v1->v2:
        - replace missed bpf_map_def case in Documentation/bpf/btf.rst (Alexei).
      ====================
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      1713e33b
    • Andrii Nakryiko's avatar
      docs/bpf: update BPF map definition example · 96c85308
      Andrii Nakryiko authored
      
      
      Use BTF-defined map definition in the documentation example.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220120060529.1890907-5-andrii@kernel.org
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      96c85308
    • Andrii Nakryiko's avatar
      libbpf: deprecate legacy BPF map definitions · 93b8952d
      Andrii Nakryiko authored
      
      
      Enact deprecation of legacy BPF map definition in SEC("maps") ([0]). For
      the definitions themselves introduce LIBBPF_STRICT_MAP_DEFINITIONS flag
      for libbpf strict mode. If it is set, error out on any struct
      bpf_map_def-based map definition. If not set, libbpf will print out
      a warning for each legacy BPF map to raise awareness that it goes away.
      
      For any use of BPF_ANNOTATE_KV_PAIR() macro providing a legacy way to
      associate BTF key/value type information with legacy BPF map definition,
      warn through libbpf's pr_warn() error message (but don't fail BPF object
      open).
      
      BPF-side struct bpf_map_def is marked as deprecated. User-space struct
      bpf_map_def has to be used internally in libbpf, so it is left
      untouched. It should be enough for bpf_map__def() to be marked
      deprecated to raise awareness that it goes away.
      
      bpftool is an interesting case that utilizes libbpf to open BPF ELF
      object to generate skeleton. As such, even though bpftool itself uses
      full on strict libbpf mode (LIBBPF_STRICT_ALL), it has to relax it a bit
      for BPF map definition handling to minimize unnecessary disruptions. So
      opt-out of LIBBPF_STRICT_MAP_DEFINITIONS for bpftool. User's code that
      will later use generated skeleton will make its own decision whether to
      enforce LIBBPF_STRICT_MAP_DEFINITIONS or not.
      
      There are few tests in selftests/bpf that are consciously using legacy
      BPF map definitions to test libbpf functionality. For those, temporary
      opt out of LIBBPF_STRICT_MAP_DEFINITIONS mode for the duration of those
      tests.
      
        [0] Closes: https://github.com/libbpf/libbpf/issues/272
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220120060529.1890907-4-andrii@kernel.org
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      93b8952d
    • Andrii Nakryiko's avatar
      selftests/bpf: convert remaining legacy map definitions · ccc3f569
      Andrii Nakryiko authored
      
      
      Converted few remaining legacy BPF map definition to BTF-defined ones.
      For the remaining two bpf_map_def-based legacy definitions that we want
      to keep for testing purposes until libbpf 1.0 release, guard them in
      pragma to suppres deprecation warnings which will be added in libbpf in
      the next commit.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220120060529.1890907-3-andrii@kernel.org
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      ccc3f569
    • Andrii Nakryiko's avatar
      selftests/bpf: fail build on compilation warning · 32b34294
      Andrii Nakryiko authored
      
      
      It's very easy to miss compilation warnings without -Werror, which is
      not set for selftests. libbpf and bpftool are already strict about this,
      so make selftests/bpf also treat compilation warnings as errors to catch
      such regressions early.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220120060529.1890907-2-andrii@kernel.org
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      32b34294
    • Kumar Kartikeya Dwivedi's avatar
      selftests/bpf: Do not fail build if CONFIG_NF_CONNTRACK=m/n · 1058b6a7
      Kumar Kartikeya Dwivedi authored
      
      
      Some users have complained that selftests fail to build when
      CONFIG_NF_CONNTRACK=m. It would be useful to allow building as long as
      it is set to module or built-in, even though in case of building as
      module, user would need to load it before running the selftest. Note
      that this also allows building selftest when CONFIG_NF_CONNTRACK is
      disabled.
      
      Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20220120164932.2798544-1-memxor@gmail.com
      1058b6a7
    • Felix Maurer's avatar
      selftests: bpf: Fix bind on used port · 8c0be063
      Felix Maurer authored
      The bind_perm BPF selftest failed when port 111/tcp was already in use
      during the test. To fix this, the test now runs in its own network name
      space.
      
      To use unshare, it is necessary to reorder the includes. The style of
      the includes is adapted to be consistent with the other prog_tests.
      
      v2: Replace deprecated CHECK macro with ASSERT_OK
      
      Fixes: 8259fdeb
      
       ("selftests/bpf: Verify that rebinding to port < 1024 from BPF works")
      Signed-off-by: default avatarFelix Maurer <fmaurer@redhat.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/bpf/551ee65533bb987a43f93d88eaf2368b416ccd32.1642518457.git.fmaurer@redhat.com
      8c0be063
    • Andrii Nakryiko's avatar
      Merge branch 'rely on ASSERT marcos in xdp_bpf2bpf.c/xdp_adjust_tail.c' · 38f033a1
      Andrii Nakryiko authored
      
      
      Lorenzo Bianconi says:
      
      ====================
      
      Rely on ASSERT* macros and get rid of deprecated CHECK ones in xdp_bpf2bpf and
      xdp_adjust_tail bpf selftests.
      This is a preliminary series for XDP multi-frags support.
      
      Changes since v1:
      - run each ASSERT test separately
      - drop unnecessary return statements
      - drop unnecessary if condition in test_xdp_bpf2bpf()
      ====================
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      38f033a1
    • Lorenzo Bianconi's avatar
      bpf: selftests: Get rid of CHECK macro in xdp_bpf2bpf.c · fa6fde35
      Lorenzo Bianconi authored
      
      
      Rely on ASSERT* macros and get rid of deprecated CHECK ones in
      xdp_bpf2bpf bpf selftest.
      
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/df7e5098465016e27d91f2c69a376a35d63a7621.1642679130.git.lorenzo@kernel.org
      fa6fde35
    • Lorenzo Bianconi's avatar
      bpf: selftests: Get rid of CHECK macro in xdp_adjust_tail.c · 791cad02
      Lorenzo Bianconi authored
      
      
      Rely on ASSERT* macros and get rid of deprecated CHECK ones in
      xdp_adjust_tail bpf selftest.
      
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/c0ab002ffa647a20ec9e584214bf0d4373142b54.1642679130.git.lorenzo@kernel.org
      791cad02
  3. Jan 20, 2022
    • Alexei Starovoitov's avatar
      Merge branch 'bpf: allow cgroup progs to export custom retval to userspace' · 4e950747
      Alexei Starovoitov authored
      
      
      YiFei Zhu says:
      
      ====================
      
      Right now, most cgroup hooks are best used for permission checks. They
      can only reject a syscall with -EPERM, so a cause of a rejection, if
      the rejected by eBPF cgroup hooks, is ambiguous to userspace.
      Additionally, if the syscalls are implemented in eBPF, all permission
      checks and the implementation has to happen within the same filter,
      as programs executed later in the series of progs are unaware of the
      return values return by the previous progs.
      
      This patch series adds two helpers, bpf_get_retval and bpf_set_retval,
      that allows hooks to get/set the return value of syscall to userspace.
      This also allows later progs to retrieve retval set by previous progs.
      
      For legacy programs that rejects a syscall without setting the retval,
      for backwards compatibility, if a prog rejects without itself or a
      prior prog setting retval to an -err, the retval is set by the kernel
      to -EPERM.
      
      For getsockopt hooks that has ctx->retval, this variable mirrors that
      that accessed by the helpers.
      
      Additionally, the following user-visible behavior for getsockopt
      hooks has changed:
        - If a prior filter rejected the syscall, it will be visible
          in ctx->retval.
        - Attempting to change the retval arbitrarily is now allowed and
          will not cause an -EFAULT.
        - If kernel rejects a getsockopt syscall before running the hooks,
          the error will be visible in ctx->retval. Returning 0 from the
          prog will not overwrite the error to -EPERM unless there is an
          explicit call of bpf_set_retval(-EPERM)
      
      Tests have been added in this series to test the behavior of the helper
      with cgroup setsockopt getsockopt hooks.
      
      Patch 1 changes the API of macros to prepare for the next patch and
        should be a no-op.
      Patch 2 moves ctx->retval to a struct pointed to by current
        task_struct.
      Patch 3 implements the helpers.
      Patch 4 tests the behaviors of the helpers.
      Patch 5 updates a test after the test broke due to the visible changes.
      
      v1 -> v2:
        - errno -> retval
        - split one helper to get & set helpers
        - allow retval to be set arbitrarily in the general case
        - made the helper retval and context retval mirror each other
      ====================
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      4e950747
    • YiFei Zhu's avatar
      selftests/bpf: Update sockopt_sk test to the use bpf_set_retval · 1080ef5c
      YiFei Zhu authored
      
      
      The tests would break without this patch, because at one point it calls
        getsockopt(fd, SOL_TCP, TCP_ZEROCOPY_RECEIVE, &buf, &optlen)
      This getsockopt receives the kernel-set -EINVAL. Prior to this patch
      series, the eBPF getsockopt hook's -EPERM would override kernel's
      -EINVAL, however, after this patch series, return 0's automatic
      -EPERM will not; the eBPF prog has to explicitly bpf_set_retval(-EPERM)
      if that is wanted.
      
      I also removed the explicit mentions of EPERM in the comments in the
      prog.
      
      Signed-off-by: default avatarYiFei Zhu <zhuyifei@google.com>
      Reviewed-by: default avatarStanislav Fomichev <sdf@google.com>
      Link: https://lore.kernel.org/r/4f20b77cb46812dbc2bdcd7e3fa87c7573bde55e.1639619851.git.zhuyifei@google.com
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      1080ef5c
    • YiFei Zhu's avatar
      selftests/bpf: Test bpf_{get,set}_retval behavior with cgroup/sockopt · b8bff6f8
      YiFei Zhu authored
      
      
      The tests checks how different ways of interacting with the helpers
      (getting retval, setting EUNATCH, EISCONN, and legacy reject
      returning 0 without setting retval), produce different results in
      both the setsockopt syscall and the retval returned by the helper.
      A few more tests verify the interaction between the retval of the
      helper and the retval in getsockopt context.
      
      Signed-off-by: default avatarYiFei Zhu <zhuyifei@google.com>
      Reviewed-by: default avatarStanislav Fomichev <sdf@google.com>
      Link: https://lore.kernel.org/r/43ec60d679ae3f4f6fd2460559c28b63cb93cd12.1639619851.git.zhuyifei@google.com
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      b8bff6f8
    • YiFei Zhu's avatar
      bpf: Add cgroup helpers bpf_{get,set}_retval to get/set syscall return value · b44123b4
      YiFei Zhu authored
      
      
      The helpers continue to use int for retval because all the hooks
      are int-returning rather than long-returning. The return value of
      bpf_set_retval is int for future-proofing, in case in the future
      there may be errors trying to set the retval.
      
      After the previous patch, if a program rejects a syscall by
      returning 0, an -EPERM will be generated no matter if the retval
      is already set to -err. This patch change it being forced only if
      retval is not -err. This is because we want to support, for
      example, invoking bpf_set_retval(-EINVAL) and return 0, and have
      the syscall return value be -EINVAL not -EPERM.
      
      For BPF_PROG_CGROUP_INET_EGRESS_RUN_ARRAY, the prior behavior is
      that, if the return value is NET_XMIT_DROP, the packet is silently
      dropped. We preserve this behavior for backward compatibility
      reasons, so even if an errno is set, the errno does not return to
      caller. However, setting a non-err to retval cannot propagate so
      this is not allowed and we return a -EFAULT in that case.
      
      Signed-off-by: default avatarYiFei Zhu <zhuyifei@google.com>
      Reviewed-by: default avatarStanislav Fomichev <sdf@google.com>
      Link: https://lore.kernel.org/r/b4013fd5d16bed0b01977c1fafdeae12e1de61fb.1639619851.git.zhuyifei@google.com
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      b44123b4
    • YiFei Zhu's avatar
      bpf: Move getsockopt retval to struct bpf_cg_run_ctx · c4dcfdd4
      YiFei Zhu authored
      
      
      The retval value is moved to struct bpf_cg_run_ctx for ease of access
      in different prog types with different context structs layouts. The
      helper implementation (to be added in a later patch in the series) can
      simply perform a container_of from current->bpf_ctx to retrieve
      bpf_cg_run_ctx.
      
      Unfortunately, there is no easy way to access the current task_struct
      via the verifier BPF bytecode rewrite, aside from possibly calling a
      helper, so a pointer to current task is added to struct bpf_sockopt_kern
      so that the rewritten BPF bytecode can access struct bpf_cg_run_ctx with
      an indirection.
      
      For backward compatibility, if a getsockopt program rejects a syscall
      by returning 0, an -EPERM will be generated, by having the
      BPF_PROG_RUN_ARRAY_CG family macros automatically set the retval to
      -EPERM. Unlike prior to this patch, this -EPERM will be visible to
      ctx->retval for any other hooks down the line in the prog array.
      
      Additionally, the restriction that getsockopt filters can only set
      the retval to 0 is removed, considering that certain getsockopt
      implementations may return optlen. Filters are now able to set the
      value arbitrarily.
      
      Signed-off-by: default avatarYiFei Zhu <zhuyifei@google.com>
      Reviewed-by: default avatarStanislav Fomichev <sdf@google.com>
      Link: https://lore.kernel.org/r/73b0325f5c29912ccea7ea57ec1ed4d388fc1d37.1639619851.git.zhuyifei@google.com
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      c4dcfdd4
    • YiFei Zhu's avatar
      bpf: Make BPF_PROG_RUN_ARRAY return -err instead of allow boolean · f10d0596
      YiFei Zhu authored
      
      
      Right now BPF_PROG_RUN_ARRAY and related macros return 1 or 0
      for whether the prog array allows or rejects whatever is being
      hooked. The caller of these macros then return -EPERM or continue
      processing based on thw macro's return value. Unforunately this is
      inflexible, since -EPERM is the only err that can be returned.
      
      This patch should be a no-op; it prepares for the next patch. The
      returning of the -EPERM is moved to inside the macros, so the outer
      functions are directly returning what the macros returned if they
      are non-zero.
      
      Signed-off-by: default avatarYiFei Zhu <zhuyifei@google.com>
      Reviewed-by: default avatarStanislav Fomichev <sdf@google.com>
      Link: https://lore.kernel.org/r/788abcdca55886d1f43274c918eaa9f792a9f33b.1639619851.git.zhuyifei@google.com
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      f10d0596
    • Kui-Feng Lee's avatar
      libbpf: Improve btf__add_btf() with an additional hashmap for strings. · d81283d2
      Kui-Feng Lee authored
      
      
      Add a hashmap to map the string offsets from a source btf to the
      string offsets from a target btf to reduce overheads.
      
      btf__add_btf() calls btf__add_str() to add strings from a source to a
      target btf.  It causes many string comparisons, and it is a major
      hotspot when adding a big btf.  btf__add_str() uses strcmp() to check
      if a hash entry is the right one.  The extra hashmap here compares
      offsets of strings, that are much cheaper.  It remembers the results
      of btf__add_str() for later uses to reduce the cost.
      
      We are parallelizing BTF encoding for pahole by creating separated btf
      instances for worker threads.  These per-thread btf instances will be
      added to the btf instance of the main thread by calling btf__add_str()
      to deduplicate and write out.  With this patch and -j4, the running
      time of pahole drops to about 6.0s from 6.6s.
      
      The following lines are the summary of 'perf stat' w/o the change.
      
             6.668126396 seconds time elapsed
      
            13.451054000 seconds user
             0.715520000 seconds sys
      
      The following lines are the summary w/ the change.
      
             5.986973919 seconds time elapsed
      
            12.939903000 seconds user
             0.724152000 seconds sys
      
      V4 fixes a bug of error checking against the pointer returned by
      hashmap__new().
      
      [v3] https://lore.kernel.org/bpf/20220118232053.2113139-1-kuifeng@fb.com/
      [v2] https://lore.kernel.org/bpf/20220114193713.461349-1-kuifeng@fb.com/
      
      Signed-off-by: default avatarKui-Feng Lee <kuifeng@fb.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20220119180214.255634-1-kuifeng@fb.com
      d81283d2
    • Usama Arif's avatar
      bpf/scripts: Raise an exception if the correct number of sycalls are not generated · 0ba3929e
      Usama Arif authored
      
      
      Currently the syscalls rst and subsequently man page are auto-generated
      using function documentation present in bpf.h. If the documentation for the
      syscall is missing or doesn't follow a specific format, then that syscall
      is not dumped in the auto-generated rst.
      
      This patch checks the number of syscalls documented within the header file
      with those present as part of the enum bpf_cmd and raises an Exception if
      they don't match. It is not needed with the currently documented upstream
      syscalls, but can help in debugging when developing new syscalls when
      there might be missing or misformatted documentation.
      
      The function helper_number_check is moved to the Printer parent
      class and renamed to elem_number_check as all the most derived children
      classes are using this function now.
      
      Signed-off-by: default avatarUsama Arif <usama.arif@bytedance.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Reviewed-by: default avatarQuentin Monnet <quentin@isovalent.com>
      Link: https://lore.kernel.org/bpf/20220119114442.1452088-3-usama.arif@bytedance.com
      0ba3929e