0001
0002 #include "vmlinux.h"
0003 #include <bpf/bpf_helpers.h>
0004 #include <bpf/bpf_endian.h>
0005
0006 #define TEST_COMM_LEN 16
0007
0008 struct {
0009 __uint(type, BPF_MAP_TYPE_CGROUP_ARRAY);
0010 __uint(max_entries, 1);
0011 __type(key, u32);
0012 __type(value, u32);
0013 } cgroup_map SEC(".maps");
0014
0015 char _license[] SEC("license") = "GPL";
0016
0017 SEC("tc")
0018 int test_skb_helpers(struct __sk_buff *skb)
0019 {
0020 struct task_struct *task;
0021 char comm[TEST_COMM_LEN];
0022 __u32 tpid;
0023
0024 task = (struct task_struct *)bpf_get_current_task();
0025 bpf_probe_read_kernel(&tpid , sizeof(tpid), &task->tgid);
0026 bpf_probe_read_kernel_str(&comm, sizeof(comm), &task->comm);
0027 return 0;
0028 }