History

bpf: Clarify batch lookup/lookup_and_delete semantics

The batch lookup and lookup_and_delete APIs have two parameters, in_batch and out_batch, to facilitate iterative lookup/lookup_and_deletion operations for supported maps. Except NULL for in_batch at the start of these two batch operations, both parameters need to point to memory equal or larger than the respective map key size, except for various hashmaps (hash, percpu_hash, lru_hash, lru_percpu_hash) where the in_batch/out_batch memory size should be at least 4 bytes. Document these semantics to clarify the API.

Martin Kelly committed 2 years ago

Commit 58fd62e1 parent 89ee8383 files · +22 −7Browse files

Showing the changes to tools/include/uapi/linux (1 of 3 files). Show all

Unified · Split

tools/include/uapi/linux/bpf.h+5−1
@@ -617,7 +617,11 @@ union bpf_iter_link_info { · 616 unmodified lines
617617 * to NULL to begin the batched operation. After each subsequent
618618 * **BPF_MAP_LOOKUP_BATCH**, the caller should pass the resultant
619619 * *out_batch* as the *in_batch* for the next operation to
620− * continue iteration from the current point.
620+ * continue iteration from the current point. Both *in_batch* and
621+ * *out_batch* must point to memory large enough to hold a key,
622+ * except for maps of type **BPF_MAP_TYPE_{HASH, PERCPU_HASH,
623+ * LRU_HASH, LRU_PERCPU_HASH}**, for which batch parameters
624+ * must be at least 4 bytes wide regardless of key size.
621625 *
622626 * The *keys* and *values* are output parameters which must point
623627 * to memory large enough to hold *count* items based on the key