summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/xdp_metadata2.c
blob: cf69d05451c39b5873fb823491a1a8c4010f9b5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// SPDX-License-Identifier: GPL-2.0

#include <vmlinux.h>
#include "xdp_metadata.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx,
				    __u32 *hash) __ksym;

int called;

SEC("freplace/rx")
int freplace_rx(struct xdp_md *ctx)
{
	u32 hash = 0;
	/* Call _any_ metadata function to make sure we don't crash. */
	bpf_xdp_metadata_rx_hash(ctx, &hash);
	called++;
	return XDP_PASS;
}

char _license[] SEC("license") = "GPL";