Skip to content

Commit

Permalink
xdp_ddos01_blacklist_cmdline: Fix wrong usage of bpf_map_get_next_key
Browse files Browse the repository at this point in the history
commit 83efebc missed another wrong usage of bpf_map_get_next_key.

Signed-off-by: Jesper Dangaard Brouer <[email protected]>
  • Loading branch information
netoptimizer committed Feb 20, 2019
1 parent 83efebc commit ae6f3eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/samples/bpf/xdp_ddos01_blacklist_cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ static void blacklist_list_all_ipv4(int fd)

static void blacklist_list_all_ports(int portfd, int countfds[])
{
__u32 key = 0, next_key;
__u32 key, *prev_key = NULL;
__u64 value;
bool started = false;

/* printf("{\n"); */
while (bpf_map_get_next_key(portfd, &key, &next_key) == 0) {
while (bpf_map_get_next_key(portfd, prev_key, &key) == 0) {
if ((bpf_map_lookup_elem(portfd, &key, &value)) != 0) {
fprintf(stderr,
"ERR: bpf_map_lookup_elem(%d) failed key:0x%X\n", portfd, key);
Expand All @@ -264,7 +264,7 @@ static void blacklist_list_all_ports(int portfd, int countfds[])
started = true;
blacklist_print_port(key, value, countfds);
}
key = next_key;
prev_key = &key;
}
}

Expand Down

0 comments on commit ae6f3eb

Please sign in to comment.