Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:trie_get_next_key

Proto:static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key)

Type:int

Parameter:

TypeParameterName
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 = fetch RCU-protected pointer for dereferencing(root)
653  If Not search_root Then Return -ENOENT
657  If Not key || up to 32 for AF_INET, 128 for AF_INET6 > max_prefixlen Then Go to find_leftmost
660  node_stack = kmalloc_array - allocate memory for an array.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
663  If Not node_stack Then Return -ENOMEM
667  When node cycle
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  If prefixlen != matchlen || prefixlen == up to 32 for AF_INET, 128 for AF_INET6 Then Break
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 = fetch RCU-protected pointer for dereferencing(child[next_bit])
677  If Not node || prefixlen != up to 32 for AF_INET, 128 for AF_INET6 || flags & Intermediate node Then Go to find_leftmost
684  node = node_stack[stack_ptr]
685  When stack_ptr > 0 cycle
686  parent = node_stack[stack_ptr - 1]
689  If search_root Then Go to find_leftmost
692  If Not (flags & Intermediate node ) Then
693  next_node = parent
694  Go to do_copy
697  node = parent
698  stack_ptr--
702  err = -ENOENT
703  Go to free_stack
705  find_leftmost :
709  When node cycle
710  If flags & Intermediate node Then
712  Else
713  next_node = node
719  do_copy :
720  up to 32 for AF_INET, 128 for AF_INET6 = prefixlen
721  No 3D Now!((void * )next_key + offsetof(structbpf_lpm_trie_key, data), data, data_size)
723  free_stack :
724  kfree(node_stack)
725  Return err