Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:xsk_map_update_elem

Proto:static int xsk_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
175  m = 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, structxsk_map, map)
177  i = key , fd = value
182  If Value for the false possibility is greater at compile time(map_flags > update existing element ) Then Return -EINVAL
184  If Value for the false possibility is greater at compile time(i >= max_entries) Then Return -E2BIG
187  sock = sockfd_lookup(fd, & err)
188  If Not sock Then Return err
191  If sk_family != PF_XDP Then
192  sockfd_put(sock)
193  Return -EOPNOTSUPP
196  xs = sk
198  If Not xsk_is_setup_for_bpf_map(xs) Then
199  sockfd_put(sock)
200  Return -EOPNOTSUPP
203  map_entry = xsk_map[i]
204  node = xsk_map_node_alloc(m, map_entry)
205  If IS_ERR(node) Then
206  sockfd_put(sock)
207  Return PTR_ERR(node)
210  spin_lock_bh( & Synchronize map updates )
211  old_xs = READ_ONCE( * map_entry)
212  If old_xs == xs Then
213  err = 0
214  Go to out
215  Else if old_xs && map_flags == create new element if it didn't exist Then
216  err = -EEXIST
217  Go to out
218  Else if Not old_xs && map_flags == update existing element Then
219  err = -ENOENT
220  Go to out
222  xsk_map_sock_add(xs, node)
223  WRITE_ONCE( * map_entry, xs)
224  If old_xs Then xsk_map_sock_delete(old_xs, map_entry)
226  spin_unlock_bh( & Synchronize map updates )
227  sockfd_put(sock)
228  Return 0
230  out :
231  spin_unlock_bh( & Synchronize map updates )
232  sockfd_put(sock)
233  xsk_map_node_free(node)
234  Return err