Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samples: bpf: Refactor XDP programs with libbpf #225

Closed
wants to merge 4 commits into from

Commits on Oct 10, 2020

  1. adding ci files

    kernel-patches-bot committed Oct 10, 2020
    Configuration menu
    Copy the full SHA
    369ae87 View commit details
    Browse the repository at this point in the history
  2. samples: bpf: Refactor xdp_monitor with libbpf

    To avoid confusion caused by the increasing fragmentation of the BPF
    Loader program, this commit would like to change to the libbpf loader
    instead of using the bpf_load.
    
    Thanks to libbpf's bpf_link interface, managing the tracepoint BPF
    program is much easier. bpf_program__attach_tracepoint manages the
    enable of tracepoint event and attach of BPF programs to it with a
    single interface bpf_link, so there is no need to manage event_fd and
    prog_fd separately.
    
    This commit refactors xdp_monitor with using this libbpf API, and the
    bpf_load is removed and migrated to libbpf.
    
    Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
    DanielTimLee authored and kernel-patches-bot committed Oct 10, 2020
    Configuration menu
    Copy the full SHA
    48b06d5 View commit details
    Browse the repository at this point in the history
  3. samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect…

    …_cpu
    
    From commit d7a18ea ("libbpf: Add generic bpf_program__attach()"),
    for some BPF programs, it is now possible to attach BPF programs
    with __attach() instead of explicitly calling __attach_<type>().
    
    This commit refactors the __attach_tracepoint() with libbpf's generic
    __attach() method. In addition, this refactors the logic of setting
    the map FD to simplify the code. Also, the missing removal of
    bpf_load.o in Makefile has been fixed.
    
    Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
    DanielTimLee authored and kernel-patches-bot committed Oct 10, 2020
    Configuration menu
    Copy the full SHA
    875ab5a View commit details
    Browse the repository at this point in the history
  4. samples: bpf: refactor XDP kern program maps with BTF-defined map

    Most of the samples were converted to use the new BTF-defined MAP as
    they moved to libbpf, but some of the samples were missing.
    
    Instead of using the previous BPF MAP definition, this commit refactors
    xdp_monitor and xdp_sample_pkts_kern MAP definition with the new
    BTF-defined MAP format.
    
    Also, this commit removes the max_entries attribute at PERF_EVENT_ARRAY
    map type. The libbpf's bpf_object__create_map() will automatically
    set max_entries to the maximum configured number of CPUs on the host.
    
    Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
    DanielTimLee authored and kernel-patches-bot committed Oct 10, 2020
    Configuration menu
    Copy the full SHA
    61a7896 View commit details
    Browse the repository at this point in the history