[PATCH bpf-next v1 1/7] tools: bpftool: fix infinite loop

From: Alban Crequy
Date: Wed Mar 20 2019 - 13:34:33 EST


From: Alban Crequy <alban@xxxxxxxxxx>

Symptoms: when forgetting to type the keyword 'type' in front of 'hash':
$ sudo bpftool map create /sys/fs/bpf/dir/foobar hash key 8 value 8 entries 128
(infinite loop, taking all the CPU)
^C

Signed-off-by: Alban Crequy <alban@xxxxxxxxxx>
---
tools/bpf/bpftool/map.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index e0c650d91784..994a7e0d16fb 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -1151,6 +1151,9 @@ static int do_create(int argc, char **argv)
return -1;
}
NEXT_ARG();
+ } else {
+ p_err("unknown arg %s", *argv);
+ return -1;
}
}

--
2.20.1