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:29
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:trie_alloc

Proto:static struct bpf_map *trie_alloc(union bpf_attr *attr)

Type:struct bpf_map

Parameter:

TypeParameterName
union bpf_attr *attr
543  cost = size of trie
546  If Not Check operation authority Then Return ERR_PTR( - EPERM)
550  If max number of entries in a map == 0 || Not ( BPF_MAP_CREATE related * flags defined above. & lags for BPF_MAP_CREATE command ) || BPF_MAP_CREATE related * flags defined above. & ~LPM_CREATE_FLAG_MASK || Not bpf_map_flags_access_ok( BPF_MAP_CREATE related * flags defined above.) || size of key in bytes < LPM_KEY_SIZE_MIN || size of key in bytes > LPM_KEY_SIZE_MAX || size of value in bytes < LPM_VAL_SIZE_MIN || size of value in bytes > LPM_VAL_SIZE_MAX Then Return ERR_PTR( - EINVAL)
560  trie = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
561  If Not trie Then Return ERR_PTR( - ENOMEM)
565  bpf_map_init_from_attr( & map, attr)
566  data_size = size of key in bytes - offsetof(structbpf_lpm_trie_key, data)
568  max_prefixlen = data_size * 8
570  cost_per_node = sizeof(structlpm_trie_node) + size of value in bytes + data_size
572  cost += max number of entries in a map * cost_per_node
574  ret = bpf_map_charge_init( & memory, cost)
575  If ret Then Go to out_err
578  raw_spin_lock_init( & lock)
580  Return map
581  out_err :
582  kfree(trie)
583  Return ERR_PTR(ret)