函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\syscall.c Create Date:2022-07-27 14:05:16
Last Modify:2022-05-19 18:06:12 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:map_update_elem

函数原型:static int map_update_elem(union bpf_attr *attr)

返回类型:int

参数:

类型参数名称
union bpf_attr *attr
949  __userukey等于u64_to_user_ptr(key)
950  __useruvalue等于u64_to_user_ptr(value)
951  ufd等于 anonymous struct used by BPF_MAP_*_ELEM commands
958  如果helper macro to check that unused fields 'union bpf_attr' are zero (BPF_MAP_UPDATE_ELEM)则返回:负EINVAL
961  f等于fdget(ufd)
962  map等于 error is returned, fd is released.* On success caller should complete fd access with matching fdput()
963  如果是错误则返回:错误
965  如果非map_get_sys_perms(map, f)按位与Has write method(s) 的值则
966  err等于负EPERM
967  转到:err_put
970  如果flags按位与spin_lock-ed map_lookup/map_update 且非map_value_has_spin_lock(map)则
972  err等于负EINVAL
973  转到:err_put
976  key等于__bpf_copy_key(ukey, key_size)
977  如果是错误
978  err等于错误
979  转到:err_put
982  如果map_type恒等于BPF_MAP_TYPE_PERCPU_HASHmap_type恒等于BPF_MAP_TYPE_LRU_PERCPU_HASHmap_type恒等于BPF_MAP_TYPE_PERCPU_ARRAYmap_type恒等于BPF_MAP_TYPE_PERCPU_CGROUP_STORAGEvalue_size等于und_up - round up to next specified power of 2*@x: the value to round*@y: multiple to round up to (must be a power of 2)* Rounds @x up to next multiple of @y (which must be a power of 2).* To perform arbitrary rounding up, use roundup() below.(value_size, 8)乘num_possible_cpus()
987  否则value_size等于value_size
990  err等于负ENOMEM
991  value等于开辟内存
992  如果非value则转到:free_key
995  err等于负EFAULT
996  如果copy_from_user(value, uvalue, value_size)不等于0则转到:free_value
1000  如果bpf_map_is_dev_bound(map)则
1001  err等于bpf_map_offload_update_elem(map, key, value, flags)
1002  转到:out
1003  否则如果map_type恒等于BPF_MAP_TYPE_CPUMAPmap_type恒等于BPF_MAP_TYPE_SOCKHASHmap_type恒等于BPF_MAP_TYPE_SOCKMAP
1006  err等于map_update_elem(map, key, value, flags)
1007  转到:out
1008  否则如果IS_FD_PROG_ARRAY(map)则
1009  err等于ly called from syscall
1011  转到:out
1017  禁止抢占()
1018  __this_cpu_inc(bpf_prog_active)
1019  如果map_type恒等于BPF_MAP_TYPE_PERCPU_HASHmap_type恒等于BPF_MAP_TYPE_LRU_PERCPU_HASH
1021  err等于bpf_percpu_hash_update(map, key, value, flags)
1022  否则如果map_type恒等于BPF_MAP_TYPE_PERCPU_ARRAY
1023  err等于bpf_percpu_array_update(map, key, value, flags)
1024  否则如果map_type恒等于BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE
1025  err等于bpf_percpu_cgroup_storage_update(map, key, value, flags)
1027  否则如果IS_FD_ARRAY(map)则
1028  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
1029  err等于ly called from syscall
1031  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
1032  否则如果map_type恒等于BPF_MAP_TYPE_HASH_OF_MAPS
1033  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
1034  err等于ly called from syscall
1036  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
1037  否则如果map_type恒等于BPF_MAP_TYPE_REUSEPORT_SOCKARRAY
1039  err等于Called from syscall only.* The "nsk" in the fd refcnt.* The "osk" and "reuse" are protected by reuseport_lock.
1041  否则如果map_type恒等于BPF_MAP_TYPE_QUEUEmap_type恒等于BPF_MAP_TYPE_STACK
1043  err等于map_push_elem(map, value, flags)
1044  否则
1045  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
1046  err等于map_update_elem(map, key, value, flags)
1047  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
1049  __this_cpu_dec(bpf_prog_active)
1050  禁用抢占和中断()
1051  maybe_wait_bpf_programs(map)
1052  out :
1053  free_value :
1054  kfree(value)
1055  free_key :
1056  kfree(key)
1057  err_put :
1058  fdput(f)
1059  返回:err