Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2021 Facebook */
0003 #include <linux/bpf.h>
0004 #include <bpf/bpf_helpers.h>
0005 #include "bpf_tcp_helpers.h"
0006 
0007 extern const int bpf_prog_active __ksym;
0008 extern __u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b,
0009                   __u32 c, __u64 d) __ksym;
0010 extern struct sock *bpf_kfunc_call_test3(struct sock *sk) __ksym;
0011 int active_res = -1;
0012 int sk_state_res = -1;
0013 
0014 int __noinline f1(struct __sk_buff *skb)
0015 {
0016     struct bpf_sock *sk = skb->sk;
0017     int *active;
0018 
0019     if (!sk)
0020         return -1;
0021 
0022     sk = bpf_sk_fullsock(sk);
0023     if (!sk)
0024         return -1;
0025 
0026     active = (int *)bpf_per_cpu_ptr(&bpf_prog_active,
0027                     bpf_get_smp_processor_id());
0028     if (active)
0029         active_res = *active;
0030 
0031     sk_state_res = bpf_kfunc_call_test3((struct sock *)sk)->sk_state;
0032 
0033     return (__u32)bpf_kfunc_call_test1((struct sock *)sk, 1, 2, 3, 4);
0034 }
0035 
0036 SEC("tc")
0037 int kfunc_call_test1(struct __sk_buff *skb)
0038 {
0039     return f1(skb);
0040 }
0041 
0042 char _license[] SEC("license") = "GPL";