History

bpf: Added new helper bpf_get_ns_current_pid_tgid

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.

Carlos Neira committed 6 years ago

Commit b4490c51 parent 1e2328e7 files · +88 −2Browse files

Showing the changes to include/uapi/linux (1 of 7 files). Show all

Unified · Split

include/uapi/linux/bpf.h+19−1
@@ -2914,6 +2914,19 @@ union bpf_attr { · 2913 unmodified lines
2914 * of sizeof(struct perf_branch_entry).2914 * of sizeof(struct perf_branch_entry).
2915 *2915 *
2916 * **-ENOENT** if architecture does not support branch records.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#define __BPF_FUNC_MAPPER(FN) \2931#define __BPF_FUNC_MAPPER(FN) \
2919 FN(unspec), \2932 FN(unspec), \
@@ -3035,7 +3048,8 @@ union bpf_attr { · 115 unmodified lines
3035 FN(tcp_send_ack), \3048 FN(tcp_send_ack), \
3036 FN(send_signal_thread), \3049 FN(send_signal_thread), \
3037 FN(jiffies64), \3050 FN(jiffies64), \
3038 FN(read_branch_records),3051 FN(read_branch_records), \
3052 FN(get_ns_current_pid_tgid),
3039 3053
3040/* integer value in 'imm' field of BPF_CALL instruction selects which helper3054/* integer value in 'imm' field of BPF_CALL instruction selects which helper
3041 * function eBPF program intends to call3055 * function eBPF program intends to call
@@ -3829,4 +3843,8 @@ struct bpf_sockopt { · 787 unmodified lines
3829 __s32 retval;3843 __s32 retval;
3830};3844};
3831 3845
3846struct bpf_pidns_info {
3847 __u32 pid;
3848 __u32 tgid;
3849};
3832#endif /* _UAPI__LINUX_BPF_H__ */3850#endif /* _UAPI__LINUX_BPF_H__ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t