/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com * Copyright (c) 2016 Facebook * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */#include<linux/bpf.h>#include<linux/jhash.h>#include<linux/filter.h>#include<linux/rculist_nulls.h>#include"percpu_freelist.h"#include"bpf_lru_list.h"#include"map_in_map.h"#define HTAB_CREATE_FLAG_MASK \ (BPF_F_NO_PREALLOC | BPF_F_NO_COMMON_LRU | BPF_F_NUMA_NODE | \ BPF_F_RDONLY | BPF_F_WRONLY)structbucket{structhlist_nulls_headhead;raw_spinlock_tlock;};structbpf_htab{structbpf_mapmap;structbucket*buckets;void*elems;union{structpcpu_freelistfreelist;structbpf_lrulru;};structhtab_elem*__percpu*extra_elems;atomic_tcount;/* number of elements in this hashtable */u32n_buckets;/* number of hash buckets */u32elem_size;/* size of each element in bytes */};/* each htab element is struct htab_elem + key + value */structhtab_elem{union{structhlist_nulls_nodehash_node;struct{void*padding;union{structbpf_htab*htab;structpcpu_freelist_nodefnode;};};};union{structrcu_headrcu;structbpf_lru_nodelru_node;};u32hash;charkey[0]__aligned(8);};staticboolhtab_lru_map_delete_node(void*arg,structbpf_lru_node*node);staticboolhtab_is_lru(conststructbpf_htab*htab){returnhtab->map.map_type==BPF_MAP_TYPE_LRU_HASH||htab->map.map_typ