linux-yocto/tools/testing/selftests/bpf/progs/unsupported_ops.c
Martin KaFai Lau 4009c95fed selftests/bpf: Ensure the unsupported struct_ops prog cannot be loaded
There is an existing "bpf_tcp_ca/unsupp_cong_op" test to ensure
the unsupported tcp-cc "get_info" struct_ops prog cannot be loaded.

This patch adds a new test in the bpf_testmod such that the
unsupported ops test does not depend on other kernel subsystem
where its supporting ops may be changed in the future.

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://lore.kernel.org/r/20240722183049.2254692-4-martin.lau@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2024-07-29 13:09:10 -07:00

23 lines
530 B
C

// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
#include <vmlinux.h>
#include <bpf/bpf_tracing.h>
#include "bpf_misc.h"
#include "../bpf_testmod/bpf_testmod.h"
char _license[] SEC("license") = "GPL";
SEC("struct_ops/unsupported_ops")
__failure
__msg("attach to unsupported member unsupported_ops of struct bpf_testmod_ops")
int BPF_PROG(unsupported_ops)
{
return 0;
}
SEC(".struct_ops.link")
struct bpf_testmod_ops testmod = {
.unsupported_ops = (void *)unsupported_ops,
};