函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\xskmap.c Create Date:2022-07-27 14:43:01
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:xsk_map_update_elem

函数原型:static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value, u64 map_flags)

返回类型:int

参数:

类型参数名称
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  如果此条件成立可能性小(为编译器优化)(map_flags > update existing element )则返回:负EINVAL
184  如果此条件成立可能性小(为编译器优化)(i >= max_entries)则返回:负E2BIG
187  sock等于sockfd_lookup(fd, & err)
188  如果非sock则返回:err
191  如果sk_family不等于PF_XDP
192  sockfd_put(sock)
193  返回:负EOPNOTSUPP
196  xs等于sk
198  如果非xsk_is_setup_for_bpf_map(xs)则
199  sockfd_put(sock)
200  返回:负EOPNOTSUPP
203  map_entry等于xsk_map[i]
204  node等于xsk_map_node_alloc(m, map_entry)
205  如果是错误
206  sockfd_put(sock)
207  返回:错误
210  spin_lock_bh( & Synchronize map updates )
211  old_xs等于READ_ONCE( * map_entry)
212  如果old_xs恒等于xs
213  err等于0
214  转到:out
215  否则如果old_xsmap_flags恒等于create new element if it didn't exist
216  err等于负EEXIST
217  转到:out
218  否则如果非old_xsmap_flags恒等于update existing element
219  err等于负ENOENT
220  转到:out
222  xsk_map_sock_add(xs, node)
223  WRITE_ONCE( * map_entry, xs)
224  如果old_xsxsk_map_sock_delete(old_xs, map_entry)
226  spin_unlock_bh( & Synchronize map updates )
227  sockfd_put(sock)
228  返回:0
230  out :
231  spin_unlock_bh( & Synchronize map updates )
232  sockfd_put(sock)
233  xsk_map_node_free(node)
234  返回:err