• Daniel T. Lee's avatar
    samples: bpf: Refactor hbm program with libbpf · c5815ac7
    Daniel T. Lee authored
    This commit refactors the existing cgroup programs with libbpf
    bpf loader. Since bpf_program__attach doesn't support cgroup program
    attachment, this explicitly attaches cgroup bpf program with
    bpf_program__attach_cgroup(bpf_prog, cg1).
    
    Also, to change attach_type of bpf program, this uses libbpf's
    bpf_program__set_expected_attach_type helper to switch EGRESS to
    INGRESS. To keep bpf program attached to the cgroup hierarchy even
    after the exit, this commit uses the BPF_LINK_PINNING to pin the link
    attachment even after it is closed.
    
    Besides, this program was broken due to the typo of BPF MAP definition.
    But this commit solves the problem by fixing this from 'queue_stats' map
    struct hvm_queue_stats -> hbm_queue_stats.
    
    Fixes: 36b5d471 ("selftests/bpf: samples/bpf: Split off legacy stuff from bpf_helpers.h")
    Signed-off-by: default avatarDaniel T. Lee <danieltimlee@gmail.com>
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20201124090310.24374-2-danieltimlee@gmail.com
    c5815ac7
hbm_kern.h 5.74 KB