mirror of
https://github.com/torvalds/linux.git
synced 2026-11-29 18:12:48 +00:00
Add a small test case which adds two programs - one calling the other through a tailcall - and check that BPF rejects them in case of different expected_attach_type values: # ./vmtest.sh -- ./test_progs -t xdp_devmap [...] #641/1 xdp_devmap_attach/DEVMAP with programs in entries:OK #641/2 xdp_devmap_attach/DEVMAP with frags programs in entries:OK #641/3 xdp_devmap_attach/Verifier check of DEVMAP programs:OK #641/4 xdp_devmap_attach/DEVMAP with programs in entries on veth:OK #641 xdp_devmap_attach:OK Summary: 2/4 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
30 lines
508 B
C
30 lines
508 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "vmlinux.h"
|
|
#include <bpf/bpf_helpers.h>
|
|
#include <bpf/bpf_tracing.h>
|
|
|
|
SEC("xdp")
|
|
int xdp_devmap(struct xdp_md *ctx)
|
|
{
|
|
return ctx->egress_ifindex;
|
|
}
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
|
|
__uint(max_entries, 1);
|
|
__uint(key_size, sizeof(__u32));
|
|
__array(values, int (void *));
|
|
} xdp_map SEC(".maps") = {
|
|
.values = {
|
|
[0] = (void *)&xdp_devmap,
|
|
},
|
|
};
|
|
|
|
SEC("xdp")
|
|
int xdp_entry(struct xdp_md *ctx)
|
|
{
|
|
bpf_tail_call(ctx, &xdp_map, 0);
|
|
return 0;
|
|
}
|