mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-10 15:54:39 +08:00
62511ceadf
Analogous to the gso_segs selftests introduced in commit d9ff286a0f
("bpf: allow BPF programs access skb_shared_info->gso_segs field").
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200303200503.226217-4-willemdebruijn.kernel@gmail.com
31 lines
516 B
C
31 lines
516 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
int _version SEC("version") = 1;
|
|
char _license[] SEC("license") = "GPL";
|
|
|
|
SEC("skb_ctx")
|
|
int process(struct __sk_buff *skb)
|
|
{
|
|
#pragma clang 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;
|
|
|
|
return 0;
|
|
}
|