New bpf helper bpf_get_ns_current_pid_tgid, This helper will return pid and tgid from current task which namespace matches dev_t and inode number provided, this will allows us to instrument a process inside a container.
Showing the changes to include/uapi/linux (1 of 7 files). Show all
Unified · Split
| @@ -2914,6 +2914,19 @@ union bpf_attr { · 2913 unmodified lines | ||
| 2914 | 2914 | * of sizeof(struct perf_branch_entry). |
| 2915 | 2915 | * |
| 2916 | 2916 | * **-ENOENT** if architecture does not support branch records. |
| 2917 | + * | |
| 2918 | + * int bpf_get_ns_current_pid_tgid(u64 dev, u64 ino, struct bpf_pidns_info *nsdata, u32 size) | |
| 2919 | + * Description | |
| 2920 | + * Returns 0 on success, values for *pid* and *tgid* as seen from the current | |
| 2921 | + * *namespace* will be returned in *nsdata*. | |
| 2922 | + * | |
| 2923 | + * On failure, the returned value is one of the following: | |
| 2924 | + * | |
| 2925 | + * **-EINVAL** if dev and inum supplied don't match dev_t and inode number | |
| 2926 | + * with nsfs of current task, or if dev conversion to dev_t lost high bits. | |
| 2927 | + * | |
| 2928 | + * **-ENOENT** if pidns does not exists for the current task. | |
| 2929 | + * | |
| 2917 | 2930 | */ |
| 2918 | 2931 | #define __BPF_FUNC_MAPPER(FN) \ |
| 2919 | 2932 | FN(unspec), \ |
| @@ -3035,7 +3048,8 @@ union bpf_attr { · 115 unmodified lines | ||
| 3035 | 3048 | FN(tcp_send_ack), \ |
| 3036 | 3049 | FN(send_signal_thread), \ |
| 3037 | 3050 | FN(jiffies64), \ |
| 3038 | − FN(read_branch_records), | |
| 3051 | + FN(read_branch_records), \ | |
| 3052 | + FN(get_ns_current_pid_tgid), | |
| 3039 | 3053 | |
| 3040 | 3054 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 3041 | 3055 | * function eBPF program intends to call |
| @@ -3829,4 +3843,8 @@ struct bpf_sockopt { · 787 unmodified lines | ||
| 3829 | 3843 | __s32 retval; |
| 3830 | 3844 | }; |
| 3831 | 3845 | |
| 3846 | +struct bpf_pidns_info { | |
| 3847 | + __u32 pid; | |
| 3848 | + __u32 tgid; | |
| 3849 | +}; | |
| 3832 | 3850 | #endif /* _UAPI__LINUX_BPF_H__ */ |