Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\cgroup.c Create Date:2022-07-28 13:27:48
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Must be called with cgroup_mutex held to avoid races.

Proto:int __cgroup_bpf_query(struct cgroup *cgrp, const union bpf_attr *attr, union bpf_attr __user *uattr)

Type:int

Parameter:

TypeParameterName
struct cgroup *cgrp
const union bpf_attr *attr
union bpf_attr __user *uattr
501  __user * prog_ids = u64_to_user_ptr(prog_ids)
502  type = attach_type
503  progs = attached progs to this cgroup and attach flags * when flags == 0 or BPF_F_ALLOW_OVERRIDE the progs list will * have either zero or one element * when BPF_F_ALLOW_MULTI the list can have up to BPF_CGROUP_MAX_PROGS[type]
504  flags = flags[type]
506  ret = 0
508  effective = cu_dereference_protected() - fetch RCU pointer when updates prevented*@p: The pointer to read, prior to dereferencing*@c: The conditions under which the dereference will take place* Return the value of the specified RCU-protected pointer, but omit( array of effective progs in this cgroup [type], lockdep_is_held( & cgroup_mutex is the master lock))
511  If query_flags & lags for BPF_PROG_QUERY Then cnt = bpf_prog_array_length(effective)
513  Else cnt = number of elements in the list.* it's slow but the list cannot be long
516  If copy_to_user( & attach_flags, & flags, size of flags ) Then Return -EFAULT
518  If copy_to_user( & prog_cnt, & cnt, size of cnt ) Then Return -EFAULT
520  If prog_cnt == 0 || Not prog_ids || Not cnt Then Return 0
523  If prog_cnt < cnt Then
524  cnt = prog_cnt
525  ret = -ENOSPC
528  If query_flags & lags for BPF_PROG_QUERY Then
529  Return bpf_prog_array_copy_to_user(effective, prog_ids, cnt)
530  Else
534  i = 0
536  id = id
537  If copy_to_user(prog_ids + i, & id, size of id ) Then Return -EFAULT
539  If ++i == cnt Then Break
543  Return ret