1. 14 Dec, 2021 1 commit
  2. 25 Nov, 2021 2 commits
  3. 07 Nov, 2021 1 commit
  4. 28 Oct, 2021 1 commit
  5. 08 Sep, 2021 1 commit
  6. 08 Jun, 2021 1 commit
  7. 08 Apr, 2021 1 commit
  8. 01 Apr, 2021 3 commits
  9. 30 Mar, 2021 1 commit
    • Maciej Fijalkowski's avatar
      libbpf: xsk: Use bpf_link · 10397994
      Maciej Fijalkowski authored
      
      Currently, if there are multiple xdpsock instances running on a single
      interface and in case one of the instances is terminated, the rest of
      them are left in an inoperable state due to the fact of unloaded XDP
      prog from interface.
      
      Consider the scenario below:
      
      // load xdp prog and xskmap and add entry to xskmap at idx 10
      $ sudo ./xdpsock -i ens801f0 -t -q 10
      
      // add entry to xskmap at idx 11
      $ sudo ./xdpsock -i ens801f0 -t -q 11
      
      terminate one of the processes and another one is unable to work due to
      the fact that the XDP prog was unloaded from interface.
      
      To address that, step away from setting bpf prog in favour of bpf_link.
      This means that refcounting of BPF resources will be done automatically
      by bpf_link itself.
      
      Provide backward compatibility by checking if underlying system is
      bpf_link capable. Do this by looking up/creating bpf_link on loopback
      device. If it failed in any way, stick with netlink-based XDP prog.
      therwise, use bpf_link-based logic.
      
      When setting up BPF resources during xsk socket creation, check whether
      bpf_link for a given ifindex already exists via set of calls to
      bpf_link_get_next_id -> bpf_link_get_fd_by_id -> bpf_obj_get_info_by_fd
      and comparing the ifindexes from bpf_link and xsk socket.
      
      For case where resources exist but they are not AF_XDP related, bail out
      and ask user to remove existing prog and then retry.
      
      Lastly, do a bit of refactoring within __xsk_setup_xdp_prog and pull out
      existing code branches based on prog_id value onto separate functions
      that are responsible for resource initialization if prog_id was 0 and
      for lookup existing resources for non-zero prog_id as that implies that
      XDP program is present on the underlying net device. This in turn makes
      it easier to follow, especially the teardown part of both branches.
      Signed-off-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210329224316.17793-7-maciej.fijalkowski@intel.com
      10397994
  10. 04 Mar, 2021 1 commit
  11. 12 Feb, 2021 1 commit
  12. 25 Jan, 2021 1 commit
  13. 04 Dec, 2020 1 commit
  14. 03 Dec, 2020 1 commit
  15. 04 Nov, 2020 2 commits
  16. 07 Oct, 2020 1 commit
  17. 15 Sep, 2020 1 commit
    • Yonghong Song's avatar
      libbpf: Fix a compilation error with xsk.c for ubuntu 16.04 · d317b0a8
      Yonghong Song authored
      When syncing latest libbpf repo to bcc, ubuntu 16.04 (4.4.0 LTS kernel)
      failed compilation for xsk.c:
        In file included from /tmp/debuild.0jkauG/bcc/src/cc/libbpf/src/xsk.c:23:0:
        /tmp/debuild.0jkauG/bcc/src/cc/libbpf/src/xsk.c: In function ‘xsk_get_ctx’:
        /tmp/debuild.0jkauG/bcc/src/cc/libbpf/include/linux/list.h:81:9: warning: implicit
        declaration of function ‘container_of’ [-Wimplicit-function-declaration]
                 container_of(ptr, type, member)
                 ^
        /tmp/debuild.0jkauG/bcc/src/cc/libbpf/include/linux/list.h:83:9: note: in expansion
        of macro ‘list_entry’
                 list_entry((ptr)->next, type, member)
        ...
        src/cc/CMakeFiles/bpf-static.dir/build.make:209: recipe for target
        'src/cc/CMakeFiles/bpf-static.dir/libbpf/src/xsk.c.o' failed
      
      Commit 2f6324a3 ("libbpf: Support shared umems between queues and devices")
      added include file <linux/list.h>, which uses macro "container_of".
      xsk.c file also includes <linux/ethtool.h> before <linux/list.h>.
      
      In a more recent distro kernel, <linux/ethtool.h> includes <linux/kernel.h>
      which contains the macro definition for "container_of". So compilation is all fine.
      But in ubuntu 16.04 kernel, <linux/ethtool.h> does not contain <linux/kernel.h>
      which caused the above compilation error.
      
      Let explicitly add <linux/kernel.h> in xsk.c to avoid compilation error
      in old distro's.
      
      Fixes: 2f6324a3
      
       ("libbpf: Support shared umems between queues and devices")
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20200914223210.1831262-1-yhs@fb.com
      d317b0a8
  18. 31 Aug, 2020 1 commit
  19. 19 Aug, 2020 1 commit
  20. 28 Mar, 2020 1 commit
  21. 10 Jan, 2020 1 commit
  22. 19 Nov, 2019 1 commit
  23. 11 Nov, 2019 2 commits
  24. 07 Nov, 2019 1 commit
  25. 29 Oct, 2019 2 commits
  26. 23 Oct, 2019 1 commit
  27. 21 Oct, 2019 1 commit
  28. 09 Oct, 2019 1 commit
  29. 30 Sep, 2019 1 commit
    • Yonghong Song's avatar
      libbpf: handle symbol versioning properly for libbpf.a · 1bd63524
      Yonghong Song authored
      bcc uses libbpf repo as a submodule. It brings in libbpf source
      code and builds everything together to produce shared libraries.
      With latest libbpf, I got the following errors:
        /bin/ld: libbcc_bpf.so.0.10.0: version node not found for symbol xsk_umem__create@LIBBPF_0.0.2
        /bin/ld: failed to set dynamic section sizes: Bad value
        collect2: error: ld returned 1 exit status
        make[2]: *** [src/cc/libbcc_bpf.so.0.10.0] Error 1
      
      In xsk.c, we have
        asm(".symver xsk_umem__create_v0_0_2, xsk_umem__create@LIBBPF_0.0.2");
        asm(".symver xsk_umem__create_v0_0_4, xsk_umem__create@@LIBBPF_0.0.4");
      The linker thinks the built is for LIBBPF but cannot find proper version
      LIBBPF_0.0.2/4, so emit errors.
      
      I also confirmed that using libbpf.a to produce a shared library also
      has issues:
        -bash-4.4$ cat t.c
        extern void *xsk_umem__create;
        void * test() { return xsk_umem__create; }
        -bash-4.4$ gcc -c -fPIC t.c
        -bash-4.4$ gcc -shared t.o libbpf.a -o t.so
        /bin/ld: t.so: version node not found for symbol xsk_umem__create@LIBBPF_0.0.2
        /bin/ld: failed to set dynamic section sizes: Bad value
        collect2: error: ld returned 1 exit status
        -bash-4.4$
      
      Symbol versioning does happens in commonly used libraries, e.g., elfutils
      and glibc. For static libraries, for a versioned symbol, the old definitions
      will be ignored, and the symbol will be an alias to the latest definition.
      For example, glibc sched_setaffinity is versioned.
        -bash-4.4$ readelf -s /usr/lib64/libc.so.6 | grep sched_setaffinity
           756: 000000000013d3d0    13 FUNC    GLOBAL DEFAULT   13 sched_setaffinity@GLIBC_2.3.3
           757: 00000000000e2e70   455 FUNC    GLOBAL DEFAULT   13 sched_setaffinity@@GLIBC_2.3.4
          1800: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS sched_setaffinity.c
          4228: 00000000000e2e70   455 FUNC    LOCAL  DEFAULT   13 __sched_setaffinity_new
          4648: 000000000013d3d0    13 FUNC    LOCAL  DEFAULT   13 __sched_setaffinity_old
          7338: 000000000013d3d0    13 FUNC    GLOBAL DEFAULT   13 sched_setaffinity@GLIBC_2
          7380: 00000000000e2e70   455 FUNC    GLOBAL DEFAULT   13 sched_setaffinity@@GLIBC_
        -bash-4.4$
      For static library, the definition of sched_setaffinity aliases to the new definition.
        -bash-4.4$ readelf -s /usr/lib64/libc.a | grep sched_setaffinity
        File: /usr/lib64/libc.a(sched_setaffinity.o)
           8: 0000000000000000   455 FUNC    GLOBAL DEFAULT    1 __sched_setaffinity_new
          12: 0000000000000000   455 FUNC    WEAK   DEFAULT    1 sched_setaffinity
      
      For both elfutils and glibc, additional macros are used to control different handling
      of symbol versioning w.r.t static and shared libraries.
      For elfutils, the macro is SYMBOL_VERSIONING
      (https://sourceware.org/git/?p=elfutils.git;a=blob;f=lib/eu-config.h).
      For glibc, the macro is SHARED
      (https://sourceware.org/git/?p=glibc.git;a=blob;f=include/shlib-compat.h;hb=refs/heads/master)
      
      This patch used SHARED as the macro name. After this patch, the libbpf.a has
        -bash-4.4$ readelf -s libbpf.a | grep xsk_umem__create
           372: 0000000000017145  1190 FUNC    GLOBAL DEFAULT    1 xsk_umem__create_v0_0_4
           405: 0000000000017145  1190 FUNC    GLOBAL DEFAULT    1 xsk_umem__create
           499: 00000000000175eb   103 FUNC    GLOBAL DEFAULT    1 xsk_umem__create_v0_0_2
        -bash-4.4$
      No versioned symbols for xsk_umem__create.
      The libbpf.a can be used to build a shared library succesfully.
        -bash-4.4$ cat t.c
        extern void *xsk_umem__create;
        void * test() { return xsk_umem__create; }
        -bash-4.4$ gcc -c -fPIC t.c
        -bash-4.4$ gcc -shared t.o libbpf.a -o t.so
        -bash-4.4$
      
      Fixes: 10d30e30
      
       ("libbpf: add flags to umem config")
      Cc: Kevin Laatz <kevin.laatz@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      1bd63524
  30. 19 Sep, 2019 1 commit
  31. 30 Aug, 2019 1 commit
  32. 21 Aug, 2019 1 commit
  33. 17 Aug, 2019 1 commit
  34. 25 Jul, 2019 1 commit