diff options
author | Maria Matejka <mq@ucw.cz> | 2022-09-21 16:53:17 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2022-09-21 17:48:31 +0200 |
commit | f51837ace6bfa357f45c6bb5f573fd61a3f1f039 (patch) | |
tree | b9255e3c4291007a34020c703ea98cdc2b11bab2 | |
parent | 05c63ae734f4dcfeb479e4bd69550f6ce4fef1d7 (diff) |
Caching eattrs in filters is not needed anymore.
After flattening the route attribute structure, the ea_list ** is derivable
from rte * by arithmetics. Caching the derived value doesn't help performance
and therefore is removed as unnecessary.
-rw-r--r-- | filter/f-inst.c | 27 | ||||
-rw-r--r-- | filter/filter.c | 11 |
2 files changed, 10 insertions, 28 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 } } |