diff options
Diffstat (limited to 'filter')
-rw-r--r-- | filter/f-inst.c | 27 | ||||
-rw-r--r-- | filter/filter.c | 11 | ||||
-rw-r--r-- | filter/filter_test.c | 4 | ||||
-rw-r--r-- | filter/tree_test.c | 13 | ||||
-rw-r--r-- | filter/trie_test.c | 8 |
5 files changed, 29 insertions, 34 deletions
diff --git a/filter/f-inst.c b/filter/f-inst.c index 426b598f..801eceec 100644 --- a/filter/f-inst.c +++ b/filter/f-inst.c @@ -70,7 +70,6 @@ * m4_dnl DYNAMIC_ATTR; dynamic attribute definition * m4_dnl RTC; route table config * m4_dnl ACCESS_RTE; this instruction needs route - * m4_dnl ACCESS_EATTRS; this instruction needs extended attributes * * m4_dnl FID_MEMBER( custom instruction member * m4_dnl C type, for storage in structs @@ -237,7 +236,6 @@ * m4_dnl fpool -> the current linpool * m4_dnl NEVER_CONSTANT-> don't generate pre-interpretation code at all * m4_dnl ACCESS_RTE -> check that route is available, also NEVER_CONSTANT - * m4_dnl ACCESS_EATTRS -> pre-cache the eattrs; use only with ACCESS_RTE * * m4_dnl If you are stymied, see FI_CALL or FI_CONSTANT or just search for * m4_dnl the mentioned macros in this file to see what is happening there in wild. @@ -687,7 +685,6 @@ { STATIC_ATTR; ACCESS_RTE; - ACCESS_EATTRS; switch (sa.sa_code) { @@ -695,7 +692,7 @@ case SA_PROTO: RESULT(sa.type, s, fs->rte->src->owner->name); break; default: { - struct eattr *nhea = ea_find(*fs->eattrs, &ea_gen_nexthop); + struct eattr *nhea = ea_find(fs->rte->attrs, &ea_gen_nexthop); struct nexthop_adata *nhad = nhea ? (struct nexthop_adata *) nhea->u.ptr : NULL; struct nexthop *nh = nhad ? &nhad->nh : NULL; @@ -731,7 +728,6 @@ INST(FI_RTA_SET, 1, 0) { ACCESS_RTE; - ACCESS_EATTRS; ARG_ANY(1); STATIC_ATTR; ARG_TYPE(1, sa.type); @@ -765,7 +761,7 @@ } case SA_GW: { - struct eattr *nh_ea = ea_find(*fs->eattrs, &ea_gen_nexthop); + struct eattr *nh_ea = ea_find(fs->rte->attrs, &ea_gen_nexthop); ip_addr ip = v1.val.ip; struct iface *ifa = (ipa_is_link_local(ip) && nh_ea) ? @@ -800,7 +796,7 @@ if (v1.val.i >= 0x100000) runtime( "Invalid MPLS label" ); - struct eattr *nh_ea = ea_find(*fs->eattrs, &ea_gen_nexthop); + struct eattr *nh_ea = ea_find(fs->rte->attrs, &ea_gen_nexthop); if (!nh_ea) runtime( "No nexthop to add a MPLS label to" ); @@ -823,7 +819,7 @@ if (i < 1 || i > 256) runtime( "Setting weight value out of bounds" ); - struct eattr *nh_ea = ea_find(*fs->eattrs, &ea_gen_nexthop); + struct eattr *nh_ea = ea_find(fs->rte->attrs, &ea_gen_nexthop); if (!nh_ea) runtime( "No nexthop to set weight on" ); @@ -837,7 +833,7 @@ NEXTHOP_WALK(nh, nhax) nh->weight = i - 1; - a = ea_set_attr(fs->eattrs, + a = ea_set_attr(&fs->rte->attrs, EA_LITERAL_DIRECT_ADATA(&ea_gen_nexthop, 0, &nhax->ad)); } break; @@ -847,7 +843,7 @@ } if (!a) - a = ea_set_attr(fs->eattrs, + a = ea_set_attr(&fs->rte->attrs, EA_LITERAL_DIRECT_ADATA(&ea_gen_nexthop, 0, tmp_copy_adata(&nha.ad))); a->originated = 1; @@ -858,11 +854,10 @@ INST(FI_EA_GET, 0, 1) { /* Access to extended attributes */ DYNAMIC_ATTR; ACCESS_RTE; - ACCESS_EATTRS; RESULT_TYPE(da->type); { const struct f_val *empty; - const eattr *e = ea_find(*fs->eattrs, da->id); + const eattr *e = ea_find(fs->rte->attrs, da->id); if (e) { @@ -888,7 +883,6 @@ INST(FI_EA_SET, 1, 0) { ACCESS_RTE; - ACCESS_EATTRS; ARG_ANY(1); DYNAMIC_ATTR; ARG_TYPE(1, da->type); @@ -905,12 +899,12 @@ break; case T_IP: - a = ea_set_attr(fs->eattrs, + a = ea_set_attr(&fs->rte->attrs, EA_LITERAL_STORE_ADATA(da, 0, &v1.val.ip, sizeof(ip_addr))); break; default: - a = ea_set_attr(fs->eattrs, + a = ea_set_attr(&fs->rte->attrs, EA_LITERAL_GENERIC(da->id, da->type, 0, .u = v1.val.bval)); break; } @@ -923,9 +917,8 @@ INST(FI_EA_UNSET, 0, 0) { DYNAMIC_ATTR; ACCESS_RTE; - ACCESS_EATTRS; - ea_unset_attr(fs->eattrs, 1, da); + ea_unset_attr(&fs->rte->attrs, 1, da); } INST(FI_DEFAULT, 2, 1) { diff --git a/filter/filter.c b/filter/filter.c index 9a94545c..0aff4d30 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -76,9 +76,6 @@ struct filter_state { /* The route we are processing. This may be NULL to indicate no route available. */ struct rte *rte; - /* Cached pointer to ea_list */ - struct ea_list **eattrs; - /* Buffer for log output */ struct buffer buf; @@ -94,11 +91,6 @@ void (*bt_assert_hook)(int result, const struct f_line_item *assert); #define f_stack_init(fs) ( _f_stack_init(fs, v, 128), _f_stack_init(fs, e, 128) ) -static inline void f_cache_eattrs(struct filter_state *fs) -{ - fs->eattrs = &(fs->rte->attrs); -} - static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS; /** @@ -164,8 +156,6 @@ interpret(struct filter_state *fs, const struct f_line *line, struct f_val *val) #define falloc(size) tmp_alloc(size) #define fpool tmp_linpool -#define ACCESS_EATTRS do { if (!fs->eattrs) f_cache_eattrs(fs); } while (0) - #include "filter/inst-interpret.c" #undef res #undef v1 @@ -174,7 +164,6 @@ interpret(struct filter_state *fs, const struct f_line *line, struct f_val *val) #undef runtime #undef falloc #undef fpool -#undef ACCESS_EATTRS } } diff --git a/filter/filter_test.c b/filter/filter_test.c index 5b24a765..671dba94 100644 --- a/filter/filter_test.c +++ b/filter/filter_test.c @@ -79,11 +79,11 @@ main(int argc, char *argv[]) if (!bt_config_file_parse(BT_CONFIG_FILE)) abort(); - bt_test_suite(t_reconfig, "Testing reconfiguration"); + bt_test_suite_extra(t_reconfig, 0, BT_TIMEOUT, "Testing reconfiguration"); struct f_bt_test_suite *t; WALK_LIST(t, config->tests) - bt_test_suite_base(run_function, t->fn_name, t, BT_FORKING, BT_TIMEOUT, "%s", t->dsc); + bt_test_suite_base(run_function, t->fn_name, t, 0, BT_TIMEOUT, "%s", t->dsc); bt_bird_cleanup(); return bt_exit_value(); diff --git a/filter/tree_test.c b/filter/tree_test.c index 05702f81..d180efbc 100644 --- a/filter/tree_test.c +++ b/filter/tree_test.c @@ -170,6 +170,8 @@ t_balancing(void) show_tree(balanced_tree_from_simple); bt_assert(same_tree(balanced_tree_from_simple, expected_balanced_tree)); + + tmp_flush(); } return 1; @@ -191,6 +193,9 @@ t_balancing_random(void) uint i; for(i = 0; i < 10; i++) { + struct lp_state lps; + lp_save(tmp_linpool, &lps); + struct f_tree *random_degenerated_tree = get_random_degenerated_left_tree(nodes_count); show_tree(random_degenerated_tree); @@ -200,7 +205,11 @@ t_balancing_random(void) show_tree(balanced_tree_from_random); bt_assert(same_tree(balanced_tree_from_random, expected_balanced_tree)); + + lp_restore(tmp_linpool, &lps); } + + tmp_flush(); } return 1; @@ -227,6 +236,8 @@ t_find(void) const struct f_tree *found_tree = find_tree(tree, &looking_up_value); bt_assert((val_compare(&looking_up_value, &(found_tree->from)) == 0) && (val_compare(&looking_up_value, &(found_tree->to)) == 0)); } + + tmp_flush(); } return 1; @@ -283,6 +294,8 @@ t_find_ranges(void) ((val_compare(&needle, &(found_tree->from)) == 1) && (val_compare(&needle, &(found_tree->to)) == -1)) ); } + + tmp_flush(); } return 1; diff --git a/filter/trie_test.c b/filter/trie_test.c index dc791280..ddce2daa 100644 --- a/filter/trie_test.c +++ b/filter/trie_test.c @@ -251,12 +251,12 @@ get_outer_net(net_addr *net, const struct f_prefix *src) static list * make_random_prefix_list(int num, int v6, int tight) { - list *prefixes = lp_allocz(tmp_linpool, sizeof(struct f_prefix_node)); + list *prefixes = tmp_allocz(sizeof(struct f_prefix_node)); init_list(prefixes); for (int i = 0; i < num; i++) { - struct f_prefix_node *px = lp_allocz(tmp_linpool, sizeof(struct f_prefix_node)); + struct f_prefix_node *px = tmp_allocz(sizeof(struct f_prefix_node)); get_random_prefix(&px->prefix, v6, tight); add_tail(prefixes, &px->n); @@ -294,7 +294,7 @@ read_prefix_list(FILE *f, int v6, int plus) char s[32]; int n; - list *pxlist = lp_allocz(tmp_linpool, sizeof(struct f_prefix_node)); + list *pxlist = tmp_allocz(sizeof(struct f_prefix_node)); init_list(pxlist); errno = 0; @@ -308,7 +308,7 @@ read_prefix_list(FILE *f, int v6, int plus) if (n != 5) bt_abort_msg("Invalid content of trie_data"); - struct f_prefix_node *px = lp_allocz(tmp_linpool, sizeof(struct f_prefix_node)); + struct f_prefix_node *px = tmp_allocz(sizeof(struct f_prefix_node)); net_fill_ip4(&px->prefix.net, ip4_build(a0, a1, a2, a3), pl); px->prefix.lo = pl; px->prefix.hi = plus ? IP4_MAX_PREFIX_LENGTH : pl; |