Skip to content

Commit ae6f3eb

Browse files
committed
xdp_ddos01_blacklist_cmdline: Fix wrong usage of bpf_map_get_next_key
commit 83efebc missed another wrong usage of bpf_map_get_next_key. Signed-off-by: Jesper Dangaard Brouer <[email protected]>
1 parent 83efebc commit ae6f3eb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/samples/bpf/xdp_ddos01_blacklist_cmdline.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,12 @@ static void blacklist_list_all_ipv4(int fd)
248248

249249
static void blacklist_list_all_ports(int portfd, int countfds[])
250250
{
251-
__u32 key = 0, next_key;
251+
__u32 key, *prev_key = NULL;
252252
__u64 value;
253253
bool started = false;
254254

255255
/* printf("{\n"); */
256-
while (bpf_map_get_next_key(portfd, &key, &next_key) == 0) {
256+
while (bpf_map_get_next_key(portfd, prev_key, &key) == 0) {
257257
if ((bpf_map_lookup_elem(portfd, &key, &value)) != 0) {
258258
fprintf(stderr,
259259
"ERR: bpf_map_lookup_elem(%d) failed key:0x%X\n", portfd, key);
@@ -264,7 +264,7 @@ static void blacklist_list_all_ports(int portfd, int countfds[])
264264
started = true;
265265
blacklist_print_port(key, value, countfds);
266266
}
267-
key = next_key;
267+
prev_key = &key;
268268
}
269269
}
270270

0 commit comments

Comments
 (0)