pipapo_rules_same_key(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ pipapo_rules_same_key(9) ✨

okay so bestie, this one's straight out of the Kernel API Manual β€” pipapo_rules_same_key(9) β€” and it's literally just a lil counting function. it does not do anything fancy, it just tells you how many rules came from the same entry. that's it, that's the whole vibe. πŸ’…


🌸 NAME 🌸

pipapo_rules_same_key β€” get the number of rules that originated from the same entry 🫢


πŸŽ€ SYNOPSIS πŸŽ€

unsigned int pipapo_rules_same_key (struct nft_pipapo_field *f ,
unsigned int first );

like literally that's the whole signature, no cap ✨


πŸ¦‹ ARGUMENTS πŸ¦‹

  • f β€” the field that's holding the mapping table πŸ’–
  • first β€” the index of the first rule in the set of rules that all map to the same entry ⭐

πŸ‘‘ DESCRIPTION πŸ‘‘

okay so here's the tea β˜• β€” every rule in a field that came from the same original entry is gonna map to the same set of rules in the next field, or to the same element reference. that's the whole trick, iykyk.

so this function exploits that and returns the cardinality of the set of rules that originated from the same entry as the rule with index first β€” and yes, first itself is included in the count, she's not excluded from her own party πŸŽ‰ and like, "cardinality" is just math-speak for "how many are in the set", in case that word gave you a jump scare 😭

in pictures, bestie:

rules field #0                0    1    2    3    4 map to:
0    1   2-4  2-4  5-9 .    .    .......   . ...  |    |    |    |    |
|    |    |     |    |    |    |      '    '    '    '    '   in field
#1             0    1    2    3    4    5 ...

so if this is called for rule 2 on field #0, it will return 3 β€” because rules 2 and 3 in field 0 also map to the same set of rules (2, 3, 4) in the next field. three rules, one squad, periodt πŸ’€βœ¨

and for the last field in a set, we can just rely on the associated entries to map to the same element references. easy. slay. 🧚


πŸ”₯ RETURN πŸ”₯

the number of rules that originated from the same entry as first. that's it. that's the number. πŸ“


🌈 SEE ALSO 🌈

the kernel file ./net/netfilter/nft_set_pipapo.c Theory of Operation(9) (yes that's the good lore, go read it πŸ“–) β€” plus, and buckle up bestie, this list is long:

pipapo_refill(9), pipapo_get_slow(9), pipapo_get(9), nft_pipapo_lookup(9), nft_pipapo_get(9), pipapo_realloc_mt(9), lt_calculate_size(9), pipapo_resize(9), pipapo_bucket_set(9), pipapo_lt_4b_to_8b(9), pipapo_lt_8b_to_4b(9), pipapo_lt_bits_adjust(9), pipapo_insert(9), pipapo_step_diff(9), pipapo_step_after_end(9), pipapo_base_sum(9), pipapo_expand(9), pipapo_map(9), pipapo_free_scratch(9), pipapo_realloc_scratch(9), pipapo_maybe_clone(9), nft_pipapo_insert(9), pipapo_clone(9), pipapo_unmap(9), pipapo_drop(9), pipapo_gc_scan(9), pipapo_gc_queue(9), pipapo_free_fields(9), pipapo_reclaim_match(9), nft_pipapo_commit(9), nft_pipapo_activate(9), nft_pipapo_deactivate(9), nft_pipapo_flush(9), pipapo_get_boundaries(9), pipapo_match_field(9), nft_pipapo_remove(9), nft_pipapo_do_walk(9), nft_pipapo_walk(9), nft_pipapo_privsize(9), nft_pipapo_estimate(9), nft_pipapo_init(9), nft_set_pipapo_match_destroy(9), nft_pipapo_destroy(9), nft_pipapo_gc_init(9)

like?? forty-something cross-references, she's an icon, she's a legend, she IS the moment πŸ‘‘


ngl there's nothing dangerous in here, it's just a counter. no undefined behavior, no traps, go wild. πŸ’œ

okay that's the whole page bestie, ily, go count some rules πŸ’–πŸ¦‹βœ¨

β€” cute lil sign-off: this one lives in ./net/netfilter, it's dated October 2026, and yes it's still called pipapo_rules_same_key(9) πŸŽ€πŸŒΈ

πŸ“¦ where this page comes from