diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-11-25 02:02:05 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-11-25 17:40:48 +0100 |
commit | a46594d84eff30217d0da5424dfc4bcddb49bc54 (patch) | |
tree | 4870dd3649f191c86a769318b400c72588d4fa6a | |
parent | c406ae7bacc48cc058c876c6ec9a16b54209e806 (diff) | |
parent | a5a6de581b79641b21b26277580cb4cc118da7ea (diff) |
Merge commit 'a5a6de58' into wireguard-next-tmp7-1
Conflicts:
filter/config.Y
filter/data.c
filter/data.h
-rw-r--r-- | filter/config.Y | 43 | ||||
-rw-r--r-- | filter/data.c | 19 | ||||
-rw-r--r-- | filter/data.h | 2 | ||||
-rw-r--r-- | filter/decl.m4 | 15 |
4 files changed, 42 insertions, 37 deletions
diff --git a/filter/config.Y b/filter/config.Y index b0f951ec..57108af7 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -323,33 +323,42 @@ f_new_lc_item(u32 f1, u32 t1, u32 f2, u32 t2, u32 f3, u32 t3) } static inline struct f_inst * -f_generate_empty(struct f_dynamic_attr dyn) +f_const_empty(struct f_dynamic_attr dyn) { struct f_val empty; - switch (dyn.type & EAF_TYPE_MASK) { + switch (dyn.type) { case EAF_TYPE_AS_PATH: - empty = f_const_empty_path; - break; case EAF_TYPE_INT_SET: - empty = f_const_empty_clist; - break; case EAF_TYPE_EC_SET: - empty = f_const_empty_eclist; - break; case EAF_TYPE_LC_SET: - empty = f_const_empty_lclist; + empty = (struct f_val) { + .type = dyn.f_type, + .val.ad = &null_adata, + }; break; case EAF_TYPE_TUNNEL_ENCAP: empty = f_const_empty_tlvlist; break; + case 0: + empty = f_const_empty_list; + break; default: cf_error("Can't empty that attribute"); } - return f_new_inst(FI_EA_SET, f_new_inst(FI_CONSTANT, empty), dyn); + return f_new_inst(FI_CONSTANT, empty); } +#define f_dummy_dynattr(_type, _f_type) ((struct f_dynamic_attr) { .type = _type, .f_type = _f_type, }) + +#define f_const_empty_path f_const_empty(f_dummy_dynattr(EAF_TYPE_AS_PATH, T_PATH)) +#define f_const_empty_clist f_const_empty(f_dummy_dynattr(EAF_TYPE_INT_SET, T_CLIST)) +#define f_const_empty_eclist f_const_empty(f_dummy_dynattr(EAF_TYPE_EC_SET, T_ECLIST)) +#define f_const_empty_lclist f_const_empty(f_dummy_dynattr(EAF_TYPE_LC_SET, T_LCLIST)) +#define f_const_empty_tlvlist f_const_empty(f_dummy_dynattr(EAF_TYPE_TUNNEL_ENCAP, T_TLVLIST)) +#define f_const_empty_list f_const_empty(f_dummy_dynattr(0, T_EMPTY_LIST)) + /* * Remove all new lines and doubled whitespaces * and convert all tabulators to spaces @@ -1001,12 +1010,12 @@ term: | dynamic_attr '.' RESET{ } */ - | EMPTY { $$ = f_new_inst(FI_CONSTANT, f_const_empty_list); } - | '+' EMPTY '+' { $$ = f_new_inst(FI_CONSTANT, f_const_empty_path); } - | '-' EMPTY '-' { $$ = f_new_inst(FI_CONSTANT, f_const_empty_clist); } - | '-' '-' EMPTY '-' '-' { $$ = f_new_inst(FI_CONSTANT, f_const_empty_eclist); } - | '-' '-' '-' EMPTY '-' '-' '-' { $$ = f_new_inst(FI_CONSTANT, f_const_empty_lclist); } - | '-' '-' '-' '-' EMPTY '-' '-' '-' '-' { $$ = f_new_inst(FI_CONSTANT, f_const_empty_tlvlist); } + | EMPTY { $$ = f_const_empty_list; } + | '+' EMPTY '+' { $$ = f_const_empty_path; } + | '-' EMPTY '-' { $$ = f_const_empty_clist; } + | '-' '-' EMPTY '-' '-' { $$ = f_const_empty_eclist; } + | '-' '-' '-' EMPTY '-' '-' '-' { $$ = f_const_empty_lclist; } + | '-' '-' '-' '-' EMPTY '-' '-' '-' '-' { $$ = f_const_empty_tlvlist; } | PREPEND '(' term ',' term ')' { $$ = f_new_inst(FI_PATH_PREPEND, $3, $5); } | ADD '(' term ',' term ')' { $$ = f_new_inst(FI_CLIST_ADD, $3, $5); } | DELETE '(' term ',' term ')' { $$ = f_new_inst(FI_CLIST_DEL, $3, $5); } @@ -1131,7 +1140,7 @@ cmd: $$ = f_new_inst(FI_SWITCH, $2, $4); } - | dynamic_attr '.' EMPTY ';' { $$ = f_generate_empty($1); } + | dynamic_attr '.' EMPTY ';' { $$ = f_new_inst(FI_EA_SET, f_const_empty($1), $1); } | dynamic_attr '.' PREPEND '(' term ')' ';' { $$ = f_generate_complex( FI_PATH_PREPEND, $1, $5 ); } | dynamic_attr '.' ADD '(' term ')' ';' { $$ = f_generate_complex( FI_CLIST_ADD, $1, $5 ); } | dynamic_attr '.' DELETE '(' term ')' ';' { $$ = f_generate_complex( FI_CLIST_DEL, $1, $5 ); } diff --git a/filter/data.c b/filter/data.c index 51fd7fa9..f57ead8b 100644 --- a/filter/data.c +++ b/filter/data.c @@ -86,24 +86,11 @@ f_type_element_type(enum f_type t) } const struct f_trie f_const_empty_trie = { .ipv4 = -1, }; - -const struct f_val f_const_empty_list = { - .type = T_EMPTY_LIST, -}, f_const_empty_path = { - .type = T_PATH, - .val.ad = &null_adata, -}, f_const_empty_clist = { - .type = T_CLIST, - .val.ad = &null_adata, -}, f_const_empty_eclist = { - .type = T_ECLIST, - .val.ad = &null_adata, -}, f_const_empty_lclist = { - .type = T_LCLIST, - .val.ad = &null_adata, -}, f_const_empty_prefix_set = { +const struct f_val f_const_empty_prefix_set = { .type = T_PREFIX_SET, .val.ti = &f_const_empty_trie, +}, f_const_empty_list = { + .type = T_EMPTY_LIST, }, f_const_empty_tlvlist = { .type = T_TLVLIST, }; diff --git a/filter/data.h b/filter/data.h index 513ec953..26296751 100644 --- a/filter/data.h +++ b/filter/data.h @@ -325,7 +325,7 @@ undef_value(struct f_val v) (v.val.ad == &null_adata); } -extern const struct f_val f_const_empty_list, f_const_empty_path, f_const_empty_clist, f_const_empty_eclist, f_const_empty_lclist, f_const_empty_prefix_set, f_const_empty_tlvlist; +extern const struct f_val f_const_empty_prefix_set, f_const_empty_list, f_const_empty_tlvlist; enum filter_return f_eval(const struct f_line *expr, struct linpool *tmp_pool, struct f_val *pres); diff --git a/filter/decl.m4 b/filter/decl.m4 index 4cc6276f..859b00ad 100644 --- a/filter/decl.m4 +++ b/filter/decl.m4 @@ -519,13 +519,22 @@ f_const_promotion(struct f_inst *arg, enum f_type want) *c = f_const_empty_prefix_set; return 1; } else if ((c->type == T_EMPTY_LIST) && (want == T_CLIST)) { - *c = f_const_empty_clist; + *c = (struct f_val) { + .type = T_CLIST, + .val.ad = &null_adata, + }; return 1; } else if ((c->type == T_EMPTY_LIST) && (want == T_ECLIST)) { - *c = f_const_empty_eclist; + *c = (struct f_val) { + .type = T_ECLIST, + .val.ad = &null_adata, + }; return 1; } else if ((c->type == T_EMPTY_LIST) && (want == T_LCLIST)) { - *c = f_const_empty_lclist; + *c = (struct f_val) { + .type = T_LCLIST, + .val.ad = &null_adata, + }; return 1; } else if ((c->type == T_EMPTY_LIST) && (want == T_TLVLIST)) { *c = f_const_empty_tlvlist; |