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
527 * Look up an element with the given *key* in the map referred to527 * Look up an element with the given *key* in the map referred to
528 * by the file descriptor *fd*, and if found, delete the element.528 * by the file descriptor *fd*, and if found, delete the element.
529 *529 *
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 *
530 * The **BPF_MAP_TYPE_QUEUE** and **BPF_MAP_TYPE_STACK** map types539 * The **BPF_MAP_TYPE_QUEUE** and **BPF_MAP_TYPE_STACK** map types
531 * implement this command as a "pop" operation, deleting the top540 * implement this command as a "pop" operation, deleting the top
532 * element rather than one corresponding to *key*.541 * element rather than one corresponding to *key*.
@@ -536,6 +545,10 @@ union bpf_iter_link_info { · 3 unmodified lines
536 * This command is only valid for the following map types:545 * This command is only valid for the following map types:
537 * * **BPF_MAP_TYPE_QUEUE**546 * * **BPF_MAP_TYPE_QUEUE**
538 * * **BPF_MAP_TYPE_STACK**547 * * **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**
539 *552 *
540 * Return553 * Return
541 * Returns zero on success. On error, -1 is returned and *errno*554 * Returns zero on success. On error, -1 is returned and *errno*