Skip to content

Commit 59d98c7

Browse files
aspskKernel Patches Daemon
authored andcommitted
bpf: update uapi/linux/bpf.h docs on the batch map ops
The map_lookup{,_and_delete}_batch operations return same values. Make this clear in documentation. Also, update the comments so that this is more clear that -ENOENT is a valid return value in case of success. (In fact, this is the most common return value, as this is reasonable to do map_lookup_batch(MAX_ENTRIES), which, in case of success, will always return -ENOENT.) Signed-off-by: Anton Protopopov <aspsk@isovalent.com>
1 parent 54db94b commit 59d98c7

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

include/uapi/linux/bpf.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -632,17 +632,19 @@ union bpf_iter_link_info {
632632
* returning the lock. This must be specified if the
633633
* elements contain a spinlock.
634634
*
635-
* On success, *count* elements from the map are copied into the
636-
* user buffer, with the keys copied into *keys* and the values
637-
* copied into the corresponding indices in *values*.
638-
*
639-
* If an error is returned and *errno* is not **EFAULT**, *count*
640-
* is set to the number of successfully processed elements.
635+
* On success, up to *count* elements from the map are copied into
636+
* the user buffer, with the keys copied into *keys* and the
637+
* values copied into the corresponding indices in *values*.
641638
*
642639
* Return
643640
* Returns zero on success. On error, -1 is returned and *errno*
644641
* is set appropriately.
645642
*
643+
* If an error is returned and *errno* is not **EFAULT**, then
644+
* *count* is set to the number of successfully processed
645+
* elements. In particular, the *errno* may be set to **ENOENT**
646+
* in case of success to indicate that the end of map is reached.
647+
*
646648
* May set *errno* to **ENOSPC** to indicate that *keys* or
647649
* *values* is too small to dump an entire bucket during
648650
* iteration of a hash-based map type.
@@ -655,15 +657,15 @@ union bpf_iter_link_info {
655657
* **BPF_MAP_LOOKUP_BATCH** with two exceptions:
656658
*
657659
* * Every element that is successfully returned is also deleted
658-
* from the map. This is at least *count* elements. Note that
659-
* *count* is both an input and an output parameter.
660+
* from the map. The *count* parameter is set to the number of
661+
* returned elements. This value can be less than the actual
662+
* number of deleted elements, see the next item.
660663
* * Upon returning with *errno* set to **EFAULT**, up to
661664
* *count* elements may be deleted without returning the keys
662665
* and values of the deleted elements.
663666
*
664667
* Return
665-
* Returns zero on success. On error, -1 is returned and *errno*
666-
* is set appropriately.
668+
* Same as the BPF_MAP_LOOKUP_BATCH return values.
667669
*
668670
* BPF_MAP_UPDATE_BATCH
669671
* Description

0 commit comments

Comments
 (0)