diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-11-25 18:12:37 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-11-25 18:13:55 +0100 |
commit | 6ccdbf4641d5cbdd97f11165c8515b166aa4d0d4 (patch) | |
tree | 791873d33a1862ac5ed1bea62bf3a4d94a5f2a4b | |
parent | 269b90d210a872ccaf49cfc3170a86c081c99ad5 (diff) | |
parent | 39f8f46d81203ebd6b976da56e83930f972dccab (diff) |
Merge commit '39f8f46d81203ebd6b976da56e83930f972dccab' into wireguard-next-tmp7-1
-rw-r--r-- | filter/config.Y | 60 | ||||
-rw-r--r-- | filter/data.c | 6 | ||||
-rw-r--r-- | filter/data.h | 2 | ||||
-rw-r--r-- | filter/decl.m4 | 5 |
4 files changed, 29 insertions, 44 deletions
diff --git a/filter/config.Y b/filter/config.Y index 19ade31f..5554fd27 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -357,42 +357,28 @@ f_new_lc_item(u32 f1, u32 t1, u32 f2, u32 t2, u32 f3, u32 t3) } static inline struct f_inst * -f_const_empty(struct f_dynamic_attr dyn) +f_const_empty(enum f_type t) { - struct f_val empty; - - switch (dyn.type) { - case EAF_TYPE_AS_PATH: - case EAF_TYPE_INT_SET: - case EAF_TYPE_EC_SET: - case EAF_TYPE_LC_SET: - empty = (struct f_val) { - .type = dyn.f_type, + switch (t) { + case T_PATH: + case T_CLIST: + case T_ECLIST: + case T_LCLIST: + case T_EMPTY_LIST: + return f_new_inst(FI_CONSTANT, (struct f_val) { + .type = t, .val.ad = &null_adata, - }; - break; - case EAF_TYPE_TUNNEL_ENCAP: - empty = f_const_empty_tlvlist; - break; - case 0: - empty = f_const_empty_list; - break; + }); + case T_TLVLIST: + return f_new_inst(FI_CONSTANT, (struct f_val) { + .type = T_TLVLIST, + .val.tl = NULL, // FIXME + }); default: - cf_error("Can't empty that attribute"); + return f_new_inst(FI_CONSTANT, (struct f_val) {}); } - - 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 @@ -1034,7 +1020,7 @@ method_term: ; method_cmd: - EMPTY { $$ = f_const_empty(FM.object->i_FI_EA_GET.da); } + EMPTY { $$ = f_const_empty(FM.object->i_FI_EA_GET.da.f_type); } | PREPEND '(' term ')' { $$ = f_new_inst(FI_PATH_PREPEND, FM.object, $3 ); } | ADD '(' term ')' { $$ = f_new_inst(FI_CLIST_ADD, FM.object, $3 ); } | DELETE '(' term ')' { $$ = f_new_inst(FI_CLIST_DEL, FM.object, $3 ); } @@ -1075,12 +1061,12 @@ term: $$ = $4; } - | 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; } + | EMPTY { $$ = f_const_empty(T_EMPTY_LIST); } + | '+' EMPTY '+' { $$ = f_const_empty(T_PATH); } + | '-' EMPTY '-' { $$ = f_const_empty(T_CLIST); } + | '-' '-' EMPTY '-' '-' { $$ = f_const_empty(T_ECLIST); } + | '-' '-' '-' EMPTY '-' '-' '-' { $$ = f_const_empty(T_LCLIST); } + | '-' '-' '-' '-' EMPTY '-' '-' '-' '-' { $$ = f_const_empty(T_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); } diff --git a/filter/data.c b/filter/data.c index f57ead8b..2e6d3784 100644 --- a/filter/data.c +++ b/filter/data.c @@ -88,11 +88,7 @@ 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_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, + .val.ti = &f_const_empty_trie }; static struct adata * diff --git a/filter/data.h b/filter/data.h index 26296751..1032eacf 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_prefix_set, f_const_empty_list, f_const_empty_tlvlist; +extern const struct f_val f_const_empty_prefix_set; 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 859b00ad..98b72be6 100644 --- a/filter/decl.m4 +++ b/filter/decl.m4 @@ -537,7 +537,10 @@ f_const_promotion(struct f_inst *arg, enum f_type want) }; return 1; } else if ((c->type == T_EMPTY_LIST) && (want == T_TLVLIST)) { - *c = f_const_empty_tlvlist; + *c = (struct f_val) { + .type = T_TLVLIST, + .val.tl = NULL, + }; return 1; } |