Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\hashtab.c Create Date:2022-07-28 13:09:59
Last Modify:2022-05-23 09:15:29 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Called from syscall or from eBPF program

Proto:static int htab_map_update_elem(struct bpf_map *map, void *key, void *value, u64 map_flags)

Type:int

Parameter:

TypeParameterName
struct bpf_map *map
void *key
void *value
u64map_flags
822  htab = container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(map, structbpf_htab, map)
823  l_new = NULL
830  If Value for the false possibility is greater at compile time((map_flags & ~spin_lock-ed map_lookup/map_update ) > update existing element ) Then Return -EINVAL
834  WARN_ON_ONCE(!_read_lock_held() - might we be in RCU read-side critical section?* If CONFIG_DEBUG_LOCK_ALLOC is selected, returns nonzero iff in an RCU* read-side critical section)
836  key_size = key_size
838  hash = htab_map_hash(key, key_size, hashrnd)
840  b = __select_bucket(htab, hash)
841  head = head
843  If Value for the false possibility is greater at compile time(map_flags & spin_lock-ed map_lookup/map_update ) Then
844  If Value for the false possibility is greater at compile time(!map_value_has_spin_lock(map)) Then Return -EINVAL
847  l_old = an be called without bucket lock. it will repeat the loop in* the unlikely event when elements moved from one bucket into another* while link list is being walked
849  ret = check_flags(htab, l_old, map_flags)
850  If ret Then Return ret
852  If l_old Then
857  Return 0
866  raw_spin_lock_irqsave( & lock, flags)
868  l_old = his lookup function can only be called with bucket lock taken
870  ret = check_flags(htab, l_old, map_flags)
871  If ret Then Go to err
874  If Value for the false possibility is greater at compile time(l_old && (map_flags & spin_lock-ed map_lookup/map_update )) Then
881  copy_map_value_locked(map, key + 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.(key_size, 8), value, false)
884  ret = 0
885  Go to err
888  l_new = alloc_htab_elem(htab, key, value, key_size, hash, TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0., TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0., l_old)
890  If IS_ERR(l_new) Then
892  ret = PTR_ERR(l_new)
893  Go to err
899  hlist_nulls_add_head_rcu*@n: the element to add to the hash list
900  If l_old Then
901  hlist_nulls_del_rcu - deletes entry from hash list without re-initialization*@n: the element to delete from the hash list.* Note: hlist_nulls_unhashed() on entry does not return true after this,* the entry is in an undefined state
902  If Not htab_is_prealloc(htab) Then free_htab_elem(htab, l_old)
905  ret = 0
906  err :
907  raw_spin_unlock_irqrestore( & lock, flags)
908  Return ret
Caller
NameDescribe
bpf_fd_htab_map_update_elemly called from syscall