From 1bb8cf17318a09ee55a99043703512ec37560b29 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Sat, 15 Jun 2013 20:57:47 +0200 Subject: bpf: use Linux' define of BPF_MAXINSNS Do not necessarily define our own, only in case the Linux one is not available. Signed-off-by: Daniel Borkmann --- bpf_insns.h | 4 ++++ bpf_parser.y | 16 +++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bpf_insns.h b/bpf_insns.h index 193f0b7..47db2e3 100644 --- a/bpf_insns.h +++ b/bpf_insns.h @@ -1,6 +1,10 @@ #ifndef BPF_INSNS_H #define BPF_INSNS_H +#ifndef BPF_MAXINSNS +# define BPF_MAXINSNS 4096 +#endif + #define BPF_CLASS(code) ((code) & 0x07) #define BPF_LD 0x00 #define BPF_LDX 0x01 diff --git a/bpf_parser.y b/bpf_parser.y index 19268ae..a101057 100644 --- a/bpf_parser.y +++ b/bpf_parser.y @@ -17,6 +17,7 @@ #include #include #include +#include #include "bpf.h" #include "str.h" @@ -25,20 +26,17 @@ #include "built_in.h" #include "die.h" -#define MAX_INSTRUCTIONS 4096 - int compile_filter(char *file, int verbose, int bypass, int format, bool invoke_cpp); static int curr_instr = 0; -static struct sock_filter out[MAX_INSTRUCTIONS]; - -static char *labels[MAX_INSTRUCTIONS]; +static struct sock_filter out[BPF_MAXINSNS]; -static char *labels_jt[MAX_INSTRUCTIONS]; -static char *labels_jf[MAX_INSTRUCTIONS]; -static char *labels_k[MAX_INSTRUCTIONS]; +static char *labels[BPF_MAXINSNS]; +static char *labels_jt[BPF_MAXINSNS]; +static char *labels_jf[BPF_MAXINSNS]; +static char *labels_k[BPF_MAXINSNS]; #define YYERROR_VERBOSE 0 #define YYDEBUG 0 @@ -54,7 +52,7 @@ extern char *yytext; static inline void check_max_instr(void) { - if (curr_instr >= MAX_INSTRUCTIONS) + if (curr_instr >= BPF_MAXINSNS) panic("Exceeded maximal number of instructions!\n"); } -- cgit v1.2.3-54-g00ecf