Skip to content

Commit a620285

Browse files
authored
libbpf-tools/map_helpers: Fix duplicate map read operations (#4998)
Even when the batch read is successful, a non-batch read is performed. Fixed so that non-batch reads are not performed once batch reads are done. This is the result of testing tcpconnect by adding some logs to map_helpers. Before: ./tcpconnect -c dump_hash_batch, *count: 3 k: 16777343, v: 1 k: 50331775, v: 0 k: 385875968, v: 1 dump_hash_iter, *count: 3 k: 16777343, v: 1 k: 50331775, v: 0 k: 385875968, v: 1 LADDR RADDR RPORT CONNECT 127.0.0.1 127.0.0.3 23 1 127.0.0.1 127.0.0.1 23 1 127.0.0.1 127.0.0.2 23 1 After: ./tcpconnect -c dump_hash_batch *count: 2 k: 16777343, v: 1 k: 16777343, v: 0 LADDR RADDR RPORT CONNECT 127.0.0.1 127.0.0.1 23 1 127.0.0.1 127.0.0.2 23 1
1 parent b0b4239 commit a620285

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

libbpf-tools/map_helpers.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,12 @@ int dump_hash(int map_fd,
8585
if (batch_map_ops) {
8686
err = dump_hash_batch(map_fd, keys, key_size,
8787
values, value_size, count);
88-
if (err) {
89-
if (errno != EINVAL) {
90-
return -1;
91-
92-
/* assume that batch operations are not
93-
* supported and try non-batch mode */
94-
batch_map_ops = false;
95-
}
88+
if (err && errno == EINVAL) {
89+
/* assume that batch operations are not
90+
* supported and try non-batch mode */
91+
batch_map_ops = false;
92+
} else {
93+
return err;
9694
}
9795
}
9896

0 commit comments

Comments
 (0)