29 lines · c
1// SPDX-License-Identifier: GPL-2.0-only2#include "vmlinux.h"3#include <bpf/bpf_helpers.h>4#include <bpf/bpf_endian.h>5 6#define TEST_COMM_LEN 167 8struct {9 __uint(type, BPF_MAP_TYPE_CGROUP_ARRAY);10 __uint(max_entries, 1);11 __type(key, u32);12 __type(value, u32);13} cgroup_map SEC(".maps");14 15char _license[] SEC("license") = "GPL";16 17SEC("tc")18int test_skb_helpers(struct __sk_buff *skb)19{20 struct task_struct *task;21 char comm[TEST_COMM_LEN];22 __u32 tpid;23 24 task = (struct task_struct *)bpf_get_current_task();25 bpf_probe_read_kernel(&tpid , sizeof(tpid), &task->tgid);26 bpf_probe_read_kernel_str(&comm, sizeof(comm), &task->comm);27 return 0;28}29