函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:Called from syscall or from eBPF program

函数原型:static int trie_update_elem(struct bpf_map *map, void *_key, void *value, u64 flags)

返回类型:int

参数:

类型参数名称
struct bpf_map *map
void *_key
void *value
u64flags
303  trie等于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, structlpm_trie, map)
304  struct lpm_trie_node * node, * im_node = NULL, * new_node = NULL
305  __rcuslot
306  key等于_key
309  matchlen等于0
310  ret等于0
312  如果此条件成立可能性小(为编译器优化)(flags > update existing element )则返回:负EINVAL
315  如果up to 32 for AF_INET, 128 for AF_INET6 大于max_prefixlen则返回:负EINVAL
318  raw_spin_lock_irqsave( & lock, irq_flags)
322  如果n_entries恒等于max_entries
323  ret等于负ENOSPC
324  转到:out
327  new_node等于lpm_trie_node_alloc(trie, value)
328  如果非new_node
329  ret等于负ENOMEM
330  转到:out
333  n_entries自加
335  prefixlen等于up to 32 for AF_INET, 128 for AF_INET6
336  RCU_INIT_POINTER() - initialize an RCU protected pointer*@p: The pointer to be initialized.*@v: The value to initialized the pointer to.* Initialize an RCU-protected pointer in special cases where readers(child[0], NULL)
337  RCU_INIT_POINTER() - initialize an RCU protected pointer*@p: The pointer to be initialized.*@v: The value to initialized the pointer to.* Initialize an RCU-protected pointer in special cases where readers(child[1], NULL)
338  内存复制(data, Arbitrary size , data_size)
345  slot等于root
347 node等于cu_dereference_protected() - fetch RCU pointer when updates prevented*@p: The pointer to read, prior to dereferencing*@c: The conditions under which the dereference will take place* Return the value of the specified RCU-protected pointer, but omit( * slot, lockdep_is_held( & lock))循环
349  matchlen等于longest_prefix_match() - determine the longest prefix*@trie: The trie to get internal sizes from*@node: The node to operate on*@key: The key to compare to @node* Determine the longest prefix of @node that matches the bits in @key.
351  如果prefixlen不等于matchlenprefixlen恒等于up to 32 for AF_INET, 128 for AF_INET6 prefixlen恒等于max_prefixlen退出
356  next_bit等于This trie implements a longest prefix match algorithm that can be used to* match IP addresses to a stored set of ranges.* Data stored in @data of struct bpf_lpm_key and struct lpm_trie_node is
357  slot等于child[next_bit]
363  如果非node
364  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization( * slot, new_node)
365  转到:out
371  如果prefixlen恒等于matchlen
372  child[0]等于child[0]
373  child[1]等于child[1]
375  如果非flags按位与Intermediate node 的值则n_entries自减
378  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization( * slot, new_node)
379  kfree_rcu() - kfree an object after a grace period(node, rcu)
381  转到:out
387  如果matchlen恒等于up to 32 for AF_INET, 128 for AF_INET6
388  next_bit等于This trie implements a longest prefix match algorithm that can be used to* match IP addresses to a stored set of ranges.* Data stored in @data of struct bpf_lpm_key and struct lpm_trie_node is
389  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization(child[next_bit], node)
390  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization( * slot, new_node)
391  转到:out
394  im_node等于lpm_trie_node_alloc(trie, NULL)
395  如果非im_node
396  ret等于负ENOMEM
397  转到:out
400  prefixlen等于matchlen
401  flags或等于Intermediate node
402  内存复制(data, data, data_size)
405  如果This trie implements a longest prefix match algorithm that can be used to* match IP addresses to a stored set of ranges.* Data stored in @data of struct bpf_lpm_key and struct lpm_trie_node is
406  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization(child[0], node)
407  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization(child[1], new_node)
408  否则
409  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization(child[0], new_node)
410  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization(child[1], node)
414  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization( * slot, im_node)
416  out :
417  如果ret
418  如果new_noden_entries自减
421  kfree(new_node)
422  kfree(im_node)
425  raw_spin_unlock_irqrestore( & lock, irq_flags)
427  返回:ret