Loading...
1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2021 Facebook */
3#include "../bpf_testmod/bpf_testmod_kfunc.h"
4
5extern const int bpf_prog_active __ksym;
6int active_res = -1;
7int sk_state_res = -1;
8
9int __noinline f1(struct __sk_buff *skb)
10{
11 struct bpf_sock *sk = skb->sk;
12 int *active;
13
14 if (!sk)
15 return -1;
16
17 sk = bpf_sk_fullsock(sk);
18 if (!sk)
19 return -1;
20
21 active = (int *)bpf_per_cpu_ptr(&bpf_prog_active,
22 bpf_get_smp_processor_id());
23 if (active)
24 active_res = *active;
25
26 sk_state_res = bpf_kfunc_call_test3((struct sock *)sk)->__sk_common.skc_state;
27
28 return (__u32)bpf_kfunc_call_test1((struct sock *)sk, 1, 2, 3, 4);
29}
30
31SEC("tc")
32int kfunc_call_test1(struct __sk_buff *skb)
33{
34 return f1(skb);
35}
36
37char _license[] SEC("license") = "GPL";
1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2021 Facebook */
3#include <linux/bpf.h>
4#include <bpf/bpf_helpers.h>
5#include "bpf_tcp_helpers.h"
6
7extern const int bpf_prog_active __ksym;
8extern __u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b,
9 __u32 c, __u64 d) __ksym;
10extern struct sock *bpf_kfunc_call_test3(struct sock *sk) __ksym;
11int active_res = -1;
12int sk_state = -1;
13
14int __noinline f1(struct __sk_buff *skb)
15{
16 struct bpf_sock *sk = skb->sk;
17 int *active;
18
19 if (!sk)
20 return -1;
21
22 sk = bpf_sk_fullsock(sk);
23 if (!sk)
24 return -1;
25
26 active = (int *)bpf_per_cpu_ptr(&bpf_prog_active,
27 bpf_get_smp_processor_id());
28 if (active)
29 active_res = *active;
30
31 sk_state = bpf_kfunc_call_test3((struct sock *)sk)->__sk_common.skc_state;
32
33 return (__u32)bpf_kfunc_call_test1((struct sock *)sk, 1, 2, 3, 4);
34}
35
36SEC("classifier")
37int kfunc_call_test1(struct __sk_buff *skb)
38{
39 return f1(skb);
40}
41
42char _license[] SEC("license") = "GPL";