1. 17 Jan, 2020 1 commit
  2. 16 Jan, 2020 3 commits
  3. 15 Jan, 2020 22 commits
  4. 14 Jan, 2020 9 commits
  5. 10 Jan, 2020 5 commits
    • Andrii Nakryiko's avatar
      selftests/bpf: Add BPF_PROG, BPF_KPROBE, and BPF_KRETPROBE macros · ac065870
      Andrii Nakryiko authored
      Streamline BPF_TRACE_x macro by moving out return type and section attribute
      definition out of macro itself. That makes those function look in source code
      similar to other BPF programs. Additionally, simplify its usage by determining
      number of arguments automatically (so just single BPF_TRACE vs a family of
      BPF_TRACE_1, BPF_TRACE_2, etc). Also, allow more natural function argument
      syntax without commas inbetween argument type and name.
      
      Given this helper is useful not only for tracing tp_btf/fenty/fexit programs,
      but could be used for LSM programs and others following the same pattern,
      rename BPF_TRACE macro into more generic BPF_PROG. Existing BPF_TRACE_x
      usages in selftests are converted to new BPF_PROG macro.
      
      Following the same pattern, define BPF_KPROBE and BPF_KRETPROBE macros for
      nicer usage of kprobe/kretprobe arguments, respectively. BPF_KRETPROBE, adopts
      same convention used by fexit programs, that last defined argument is probed
      function's return result.
      
      v4->v5:
      - fix test_overhead test (__set_task_comm is void) (Alexei);
      
      v3->v4:
      - rebased and fixed one more BPF_TRACE_x occurence (Alexei);
      
      v2->v3:
      - rename to shorter and as generic BPF_PROG (Alexei);
      
      v1->v2:
      - verified GCC handles pragmas as expected;
      - added descriptions to macros;
      - converted new STRUCT_OPS selftest to BPF_HANDLER (worked as expected);
      - added original context as 'ctx' parameter, for cases where it has to be
        passed into BPF helpers. This might cause an accidental naming collision,
        unfortunately, but at least it's easy to work around. Fortunately, this
        situation produces quite legible compilation error:
      
      progs/bpf_dctcp.c:46:6: error: redefinition of 'ctx' with a different type: 'int' vs 'unsigned long long *'
              int ctx = 123;
                  ^
      progs/bpf_dctcp.c:42:6: note: previous definition is here
      void BPF_HANDLER(dctcp_init, struct sock *sk)
           ^
      ./bpf_trace_helpers.h:58:32: note: expanded from macro 'BPF_HANDLER'
      ____##name(unsigned long long *ctx, ##args)
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Link: https://lore.kernel.org/bpf/20200110211634.1614739-1-andriin@fb.com
      ac065870
    • Andrii Nakryiko's avatar
      libbpf: Poison kernel-only integer types · 1d1a3bcf
      Andrii Nakryiko authored
      It's been a recurring issue with types like u32 slipping into libbpf source
      code accidentally. This is not detected during builds inside kernel source
      tree, but becomes a compilation error in libbpf's Github repo. Libbpf is
      supposed to use only __{s,u}{8,16,32,64} typedefs, so poison {s,u}{8,16,32,64}
      explicitly in every .c file. Doing that in a bit more centralized way, e.g.,
      inside libbpf_internal.h breaks selftests, which are both using kernel u32 and
      libbpf_internal.h.
      
      This patch also fixes a new u32 occurence in libbpf.c, added recently.
      
      Fixes: 590a0088 ("bpf: libbpf: Add STRUCT_OPS support")
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Link: https://lore.kernel.org/bpf/20200110181916.271446-1-andriin@fb.com
      1d1a3bcf
    • Daniel Borkmann's avatar
      Merge branch 'bpf-global-funcs' · 7a2d070f
      Daniel Borkmann authored
      Alexei Starovoitov says:
      
      ====================
      Introduce static vs global functions and function by function verification.
      This is another step toward dynamic re-linking (or replacement) of global
      functions. See patch 2 for details.
      
      v2->v3:
      - cleaned up a check spotted by Song.
      - rebased and dropped patch 2 that was trying to improve BTF based on ELF.
      - added one more unit test for scalar return value from global func.
      
      v1->v2:
      - addressed review comments from Song, Andrii, Yonghong
      - fixed memory leak in error path
      - added modified ctx check
      - added more tests in patch 7
      ====================
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      7a2d070f
    • Alexei Starovoitov's avatar
      selftests/bpf: Add unit tests for global functions · 360301a6
      Alexei Starovoitov authored
      test_global_func[12] - check 512 stack limit.
      test_global_func[34] - check 8 frame call chain limit.
      test_global_func5    - check that non-ctx pointer cannot be passed into
                             a function that expects context.
      test_global_func6    - check that ctx pointer is unmodified.
      test_global_func7    - check that global function returns scalar.
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20200110064124.1760511-7-ast@kernel.org
      360301a6
    • Alexei Starovoitov's avatar
      selftests/bpf: Modify a test to check global functions · e528d1c0
      Alexei Starovoitov authored
      Make two static functions in test_xdp_noinline.c global:
      before: processed 2790 insns
      after: processed 2598 insns
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20200110064124.1760511-6-ast@kernel.org
      e528d1c0