Re: [PATCH bpf-next] selftests: bpf: Use BTF map in sk_assign

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 6, 2023 at 8:07 AM Felix Maurer <fmaurer@xxxxxxxxxx> wrote:
>
> The sk_assign selftest uses tc to load the BPF object file for the test. If
> tc is linked against libbpf 1.0+, this test failed, because the BPF file
> used the legacy maps section. This approach is considered legacy by libbpf
> and tc (see examples/bpf/README in the iproute2 repo).
>
> Therefore, switch to the approach recommended by iproute2 and use a BTF
> defined map. This is also well supported by libbpf.
>
> Signed-off-by: Felix Maurer <fmaurer@xxxxxxxxxx>
> ---

This test was updated (see [0]) to support iproute2 version with and
without libbpf support. Please check the latest bpf-next/master.

  [0] 7ce878ca81bc ("selftests/bpf: Fix sk_assign on s390x")

>  .../selftests/bpf/progs/test_sk_assign.c      | 24 +++++--------------
>  1 file changed, 6 insertions(+), 18 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/test_sk_assign.c b/tools/testing/selftests/bpf/progs/test_sk_assign.c
> index 98c6493d9b91..b0536bdc002b 100644
> --- a/tools/testing/selftests/bpf/progs/test_sk_assign.c
> +++ b/tools/testing/selftests/bpf/progs/test_sk_assign.c
> @@ -16,25 +16,13 @@
>  #include <bpf/bpf_helpers.h>
>  #include <bpf/bpf_endian.h>
>
> -/* Pin map under /sys/fs/bpf/tc/globals/<map name> */
> -#define PIN_GLOBAL_NS 2
> -
> -/* Must match struct bpf_elf_map layout from iproute2 */
>  struct {
> -       __u32 type;
> -       __u32 size_key;
> -       __u32 size_value;
> -       __u32 max_elem;
> -       __u32 flags;
> -       __u32 id;
> -       __u32 pinning;
> -} server_map SEC("maps") = {
> -       .type = BPF_MAP_TYPE_SOCKMAP,
> -       .size_key = sizeof(int),
> -       .size_value  = sizeof(__u64),
> -       .max_elem = 1,
> -       .pinning = PIN_GLOBAL_NS,
> -};
> +       __uint(type, BPF_MAP_TYPE_SOCKMAP);
> +       __uint(key_size, sizeof(int));
> +       __uint(value_size, sizeof(__u64));
> +       __uint(max_entries, 1);
> +       __uint(pinning, LIBBPF_PIN_BY_NAME);
> +} server_map SEC(".maps");
>
>  char _license[] SEC("license") = "GPL";
>
> --
> 2.39.1
>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux