函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:trie_get_next_key

函数原型:static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key)

返回类型:int

参数:

类型参数名称
struct bpf_map *map
void *_key
void *_next_key
632  next_node等于NULL
633  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)
634  key等于_key, next_key等于_next_key
635  struct lpm_trie_node * * node_stack = NULL
636  err等于0, stack_ptr等于负1
652  search_root等于cu_dereference() - fetch RCU-protected pointer for dereferencing*@p: The pointer to read, prior to dereferencing* This is a simple wrapper around rcu_dereference_check().(root)
653  如果非search_root则返回:负ENOENT
657  如果非keyup to 32 for AF_INET, 128 for AF_INET6 大于max_prefixlen则转到:find_leftmost
660  node_stack等于分配数组内存
663  如果非node_stack则返回:负ENOMEM
667 node循环
668  node_stack[++stack_ptr]等于node
669  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.
670  如果prefixlen不等于matchlenprefixlen恒等于up to 32 for AF_INET, 128 for AF_INET6 退出
674  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
675  node等于cu_dereference() - fetch RCU-protected pointer for dereferencing*@p: The pointer to read, prior to dereferencing* This is a simple wrapper around rcu_dereference_check().(child[next_bit])
677  如果非nodeprefixlen不等于up to 32 for AF_INET, 128 for AF_INET6 flags按位与Intermediate node 则转到:find_leftmost
684  node等于node_stack[stack_ptr]
685 stack_ptr大于0循环
686  parent等于node_stack[stack_ptr - 1]
689  如果search_root则转到:find_leftmost
692  如果非flags按位与Intermediate node 的值则
693  next_node等于parent
694  转到:do_copy
697  node等于parent
698  stack_ptr自减
702  err等于负ENOENT
703  转到:free_stack
705  find_leftmost :
709 node循环
710  如果flags按位与Intermediate node
712  否则
713  next_node等于node
719  do_copy :
720  up to 32 for AF_INET, 128 for AF_INET6 等于prefixlen
721  内存复制((void * )next_key + offsetof(structbpf_lpm_trie_key, data), data, data_size)
723  free_stack :
724  kfree(node_stack)
725  返回:err