summaryrefslogtreecommitdiff
path: root/bpf_parser.y
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2015-11-15 23:16:37 +0200
committerTobias Klauser <tklauser@distanz.ch>2015-11-16 10:08:18 +0100
commitd65a9c47ac12ca0823a8e1b0ec2c6f52447011f7 (patch)
treefc1d9f680b188ab463112546f21dd53176d0f440 /bpf_parser.y
parent6b0e119ae85aad5f2582159fe68e91adb4b02dbd (diff)
bpfc: Do not panic if bpf file is not valid
If bpf file is not valid then cpp generated file is not deleted because panic() func is invoked. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> [tk: Move exit label to the correct place] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'bpf_parser.y')
-rw-r--r--bpf_parser.y13
1 files changed, 9 insertions, 4 deletions
diff --git a/bpf_parser.y b/bpf_parser.y
index 0959f3d..8c09639 100644
--- a/bpf_parser.y
+++ b/bpf_parser.y
@@ -739,6 +739,7 @@ int compile_filter(char *file, int verbose, int bypass, int format,
int i;
struct sock_fprog res;
char tmp_file[128];
+ int ret = 0;
memset(tmp_file, 0, sizeof(tmp_file));
@@ -792,9 +793,12 @@ int compile_filter(char *file, int verbose, int bypass, int format,
if (__bpf_validate(&res) == 0) {
if (verbose)
printf("Semantic error! BPF validation failed!\n");
- else
- panic("Semantic error! BPF validation failed! "
- "Try -V for debugging output!\n");
+ else {
+ printf("Semantic error! BPF validation failed! "
+ "Try -V for debugging output!\n");
+ ret = 1;
+ goto exit;
+ }
} else if (verbose) {
printf("is runnable!\n");
}
@@ -815,10 +819,11 @@ int compile_filter(char *file, int verbose, int bypass, int format,
if (yyin != stdin)
fclose(yyin);
+exit:
if (invoke_cpp)
unlink(tmp_file);
- return 0;
+ return ret;
}
void yyerror(const char *err)