net/netfilter/nft_set_pipapo.h

Source file repositories/reference/linux-study-clean/net/netfilter/nft_set_pipapo.h

File Facts

System
Linux kernel
Corpus path
net/netfilter/nft_set_pipapo.h
Extension
.h
Size
9702 bytes
Lines
302
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

struct nft_pipapo_field {
	unsigned int rules;
	unsigned int bsize;
	unsigned int rules_alloc;
	u8 groups;
	u8 bb;
	unsigned long *lt;
	union nft_pipapo_map_bucket *mt;
};

/**
 * struct nft_pipapo_scratch - percpu data used for lookup and matching
 * @bh_lock:    PREEMPT_RT local spinlock
 * @map_index:	Current working bitmap index, toggled between field matches
 * @__map:	store partial matching results during lookup
 */
struct nft_pipapo_scratch {
	local_lock_t bh_lock;
	u8 map_index;
	unsigned long __map[];
};

/**
 * struct nft_pipapo_match - Data used for lookup and matching
 * @field_count:	Amount of fields in set
 * @bsize_max:		Maximum lookup table bucket size of all fields, in longs
 * @scratch:		Preallocated per-CPU maps for partial matching results
 * @rcu:		Matching data is swapped on commits
 * @f:			Fields, with lookup and mapping tables
 */
struct nft_pipapo_match {
	u8 field_count;
	unsigned int bsize_max;
	struct nft_pipapo_scratch * __percpu *scratch;
	struct rcu_head rcu;
	struct nft_pipapo_field f[] __counted_by(field_count);
};

/**
 * struct nft_pipapo - Representation of a set
 * @match:	Currently in-use matching data
 * @clone:	Copy where pending insertions and deletions are kept
 * @width:	Total bytes to be matched for one packet, including padding
 * @last_gc:	Timestamp of last garbage collection run, jiffies
 * @gc_head:	list of nft_trans_gc to queue up for mem reclaim
 */
struct nft_pipapo {
	struct nft_pipapo_match __rcu *match;
	struct nft_pipapo_match *clone;
	int width;
	unsigned long last_gc;
	struct list_head gc_head;
};

struct nft_pipapo_elem;

/**
 * struct nft_pipapo_elem - API-facing representation of single set element
 * @priv:	element placeholder
 * @ext:	nftables API extensions
 */
struct nft_pipapo_elem {
	struct nft_elem_priv	priv;
	struct nft_set_ext	ext;
};

int pipapo_refill(unsigned long *map, unsigned int len, unsigned int rules,
		  unsigned long *dst,
		  const union nft_pipapo_map_bucket *mt, bool match_only);

/**
 * pipapo_and_field_buckets_4bit() - Intersect 4-bit buckets
 * @f:		Field including lookup table
 * @dst:	Area to store result
 * @data:	Input data selecting table buckets
 */
static inline void pipapo_and_field_buckets_4bit(const struct nft_pipapo_field *f,
						 unsigned long *dst,
						 const u8 *data)
{
	unsigned long *lt = NFT_PIPAPO_LT_ALIGN(f->lt);
	int group;

	for (group = 0; group < f->groups; group += BITS_PER_BYTE / 4, data++) {
		u8 v;

		v = *data >> 4;
		__bitmap_and(dst, dst, lt + v * f->bsize,
			     f->bsize * BITS_PER_LONG);
		lt += f->bsize * NFT_PIPAPO_BUCKETS(4);

Annotation

Implementation Notes