History

bpf: Add lookup_and_delete_elem support to hashtab

Extend the existing bpf_map_lookup_and_delete_elem() functionality to hashtab map types, in addition to stacks and queues. Create a new hashtab bpf_map_ops function that does lookup and deletion of the element under the same bucket lock and add the created map_ops to bpf.h.

Denis Salopek committed 5 years ago

Commit 3e87f191 parent f9bceaa5 files · +156 −4Browse files

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

Unified · Split

tools/include/uapi/linux/bpf.h+13−0
@@ -527,6 +527,15 @@ union bpf_iter_link_info { · 526 unmodified lines
527527 * Look up an element with the given *key* in the map referred to
528528 * by the file descriptor *fd*, and if found, delete the element.
529529 *
530+ * For **BPF_MAP_TYPE_QUEUE** and **BPF_MAP_TYPE_STACK** map
531+ * types, the *flags* argument needs to be set to 0, but for other
532+ * map types, it may be specified as:
533+ *
534+ * **BPF_F_LOCK**
535+ * Look up and delete the value of a spin-locked map
536+ * without returning the lock. This must be specified if
537+ * the elements contain a spinlock.
538+ *
530539 * The **BPF_MAP_TYPE_QUEUE** and **BPF_MAP_TYPE_STACK** map types
531540 * implement this command as a "pop" operation, deleting the top
532541 * element rather than one corresponding to *key*.
@@ -536,6 +545,10 @@ union bpf_iter_link_info { · 3 unmodified lines
536545 * This command is only valid for the following map types:
537546 * * **BPF_MAP_TYPE_QUEUE**
538547 * * **BPF_MAP_TYPE_STACK**
548+ * * **BPF_MAP_TYPE_HASH**
549+ * * **BPF_MAP_TYPE_PERCPU_HASH**
550+ * * **BPF_MAP_TYPE_LRU_HASH**
551+ * * **BPF_MAP_TYPE_LRU_PERCPU_HASH**
539552 *
540553 * Return
541554 * Returns zero on success. On error, -1 is returned and *errno*