Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\syscall.c Create Date:2022-07-28 12:52:52
Last Modify:2022-05-19 18:06:12 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:map_lookup_and_delete_elem

Proto:static int map_lookup_and_delete_elem(union bpf_attr *attr)

Type:int

Parameter:

TypeParameterName
union bpf_attr *attr
1185  __user * ukey = u64_to_user_ptr(key)
1186  __user * uvalue = u64_to_user_ptr(value)
1187  ufd = anonymous struct used by BPF_MAP_*_ELEM commands
1194  If helper macro to check that unused fields 'union bpf_attr' are zero (BPF_MAP_LOOKUP_AND_DELETE_ELEM) Then Return -EINVAL
1197  f = fdget(ufd)
1198  map = error is returned, fd is released.* On success caller should complete fd access with matching fdput()
1199  If IS_ERR(map) Then Return PTR_ERR(map)
1201  If Not (map_get_sys_perms(map, f) & Has write method(s) ) Then
1202  err = -EPERM
1203  Go to err_put
1206  key = __bpf_copy_key(ukey, key_size)
1207  If IS_ERR(key) Then
1208  err = PTR_ERR(key)
1209  Go to err_put
1212  value_size = value_size
1214  err = -ENOMEM
1215  value = Allocation memory
1216  If Not value Then Go to free_key
1219  If map_type == BPF_MAP_TYPE_QUEUE || map_type == BPF_MAP_TYPE_STACK Then
1221  err = map_pop_elem(map, value)
1222  Else
1223  err = -Operation is not supported
1226  If err Then Go to free_value
1229  If copy_to_user(uvalue, value, value_size) != 0 Then Go to free_value
1232  err = 0
1234  free_value :
1235  kfree(value)
1236  free_key :
1237  kfree(key)
1238  err_put :
1239  fdput(f)
1240  Return err