summaryrefslogtreecommitdiff
path: root/bpf.c
diff options
context:
space:
mode:
Diffstat (limited to 'bpf.c')
-rw-r--r--bpf.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/bpf.c b/bpf.c
index 2d769ec..66d1b6c 100644
--- a/bpf.c
+++ b/bpf.c
@@ -720,7 +720,11 @@ void bpf_parse_rules(char *rulefile, struct sock_fprog *bpf, uint32_t link_type)
return;
}
- fp = fopen(rulefile, "r");
+ if (!strcmp(rulefile, "-"))
+ fp = stdin;
+ else
+ fp = fopen(rulefile, "r");
+
if (!fp) {
bpf_try_compile(rulefile, bpf, link_type);
return;
@@ -753,7 +757,8 @@ void bpf_parse_rules(char *rulefile, struct sock_fprog *bpf, uint32_t link_type)
fmemset(buff, 0, sizeof(buff));
}
- fclose(fp);
+ if (fp != stdin)
+ fclose(fp);
if (unlikely(__bpf_validate(bpf) == 0))
panic("This is not a valid BPF program!\n");