summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/test_skb_ctx.c
blob: a724a70c6700cc98bfeacd4e5bbe219801660e34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: GPL-2.0

#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>

#include "bpf_compiler.h"

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

SEC("tc")
int process(struct __sk_buff *skb)
{
	__pragma_loop_unroll_full
	for (int i = 0; i < 5; i++) {
		if (skb->cb[i] != i + 1)
			return 1;
		skb->cb[i]++;
	}
	skb->priority++;
	skb->tstamp++;
	skb->mark++;

	if (skb->wire_len != 100)
		return 1;
	if (skb->gso_segs != 8)
		return 1;
	if (skb->gso_size != 10)
		return 1;
	if (skb->ingress_ifindex != 11)
		return 1;
	if (skb->ifindex != 1)
		return 1;
	if (skb->hwtstamp != 11)
		return 1;

	return 0;
}