Skip to contentSkip to conversation

libbpf: Add documentation for bpf_map batch operations

PATCH Applied grantseltzer 3 participants 3 messages Jan 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 libbpf: Add documentation for bpf_map batch operations

From: Grant Seltzer <[email protected]>

This adds documention for:

- bpf_map_delete_batch()
- bpf_map_lookup_batch()
- bpf_map_lookup_and_delete_batch()
- bpf_map_update_batch()

This also updates the public API for the keys parameter of bpf_map_delete_batch(), and both the
keys and values parameters of bpf_map_update_batch() to be constants.

---
 tools/lib/bpf/bpf.c |   8 +--
 tools/lib/bpf/bpf.h | 116 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 118 insertions(+), 6 deletions(-)
tools/lib/bpf/bpf.c +4 -4
index 9b64eed2b003..550b4cbb6c99 100644
@@ -691,11 +691,11 @@ static int bpf_map_batch_common(int cmd, int fd, void  *in_batch,
 	return libbpf_err_errno(ret);
 }
 
-int bpf_map_delete_batch(int fd, void *keys, __u32 *count,
+int bpf_map_delete_batch(int fd, const void *keys, __u32 *count,
 			 const struct bpf_map_batch_opts *opts)
 {
 	return bpf_map_batch_common(BPF_MAP_DELETE_BATCH, fd, NULL,
-				    NULL, keys, NULL, count, opts);
+				    NULL, (void *)keys, NULL, count, opts);
 }
 
 int bpf_map_lookup_batch(int fd, void *in_batch, void *out_batch, void *keys,
@@ -715,11 +715,11 @@ int bpf_map_lookup_and_delete_batch(int fd, void *in_batch, void *out_batch,
 				    count, opts);
 }
 
-int bpf_map_update_batch(int fd, void *keys, void *values, __u32 *count,
+int bpf_map_update_batch(int fd, const void *keys, const void *values, __u32 *count,
 			 const struct bpf_map_batch_opts *opts)
 {
 	return bpf_map_batch_common(BPF_MAP_UPDATE_BATCH, fd, NULL, NULL,
-				    keys, values, count, opts);
+				    (void *)keys, (void *)values, count, opts);
 }
 
 int bpf_obj_pin(int fd, const char *pathname)
tools/lib/bpf/bpf.h +114 -2

134 lines not on this page · raw message

Signature · 1 line
2.33.1
Acked-by on v3 1/1
#1 lore raw
Quoted 9 lines · grantseltzer

From: Grant Seltzer <[email protected]>

This adds documention for:

- bpf_map_delete_batch()
- bpf_map_lookup_batch()
- bpf_map_lookup_and_delete_batch()
- bpf_map_update_batch()

Quoted 6 lines

This also updates the public API for the keys parameter of bpf_map_delete_batch(), and both the
keys and values parameters of bpf_map_update_batch() to be constants.

#2 lore raw
Quoted 13 lines · Yonghong Song
Quoted 9 lines · grantseltzer

From: Grant Seltzer <[email protected]>

This adds documention for:

- bpf_map_delete_batch()
- bpf_map_lookup_batch()
- bpf_map_lookup_and_delete_batch()
- bpf_map_update_batch()

Quoted 8 lines
Quoted 6 lines

This also updates the public API for the keys parameter of bpf_map_delete_batch(), and both the
keys and values parameters of bpf_map_update_batch() to be constants.

Applied to bpf-next, thanks.