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.
Showing the changes to tools/include/uapi/linux (1 of 5 files). Show all
Unified · Split
| @@ -527,6 +527,15 @@ union bpf_iter_link_info { · 526 unmodified lines | ||
| 527 | 527 | * Look up an element with the given *key* in the map referred to |
| 528 | 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 | 539 | * The **BPF_MAP_TYPE_QUEUE** and **BPF_MAP_TYPE_STACK** map types |
| 531 | 540 | * implement this command as a "pop" operation, deleting the top |
| 532 | 541 | * element rather than one corresponding to *key*. |
| @@ -536,6 +545,10 @@ union bpf_iter_link_info { · 3 unmodified lines | ||
| 536 | 545 | * This command is only valid for the following map types: |
| 537 | 546 | * * **BPF_MAP_TYPE_QUEUE** |
| 538 | 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 | 553 | * Return |
| 541 | 554 | * Returns zero on success. On error, -1 is returned and *errno* |