cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

tailcall_bpf2bpf2.c (728B)


      1// SPDX-License-Identifier: GPL-2.0
      2#include <linux/bpf.h>
      3#include <bpf/bpf_helpers.h>
      4#include "bpf_legacy.h"
      5
      6struct {
      7	__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
      8	__uint(max_entries, 1);
      9	__uint(key_size, sizeof(__u32));
     10	__uint(value_size, sizeof(__u32));
     11} jmp_table SEC(".maps");
     12
     13static __noinline
     14int subprog_tail(struct __sk_buff *skb)
     15{
     16	if (load_byte(skb, 0))
     17		bpf_tail_call_static(skb, &jmp_table, 1);
     18	else
     19		bpf_tail_call_static(skb, &jmp_table, 0);
     20	return 1;
     21}
     22
     23int count = 0;
     24
     25SEC("tc")
     26int classifier_0(struct __sk_buff *skb)
     27{
     28	count++;
     29	return subprog_tail(skb);
     30}
     31
     32SEC("tc")
     33int entry(struct __sk_buff *skb)
     34{
     35	bpf_tail_call_static(skb, &jmp_table, 0);
     36
     37	return 0;
     38}
     39
     40char __license[] SEC("license") = "GPL";