From bc17fee1bfdbd330f5a4377bf40f6de0681afa5c Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Fri, 25 Mar 2022 19:51:35 +0100 Subject: Filter: Bitfield eattrs reading / writing moved to filter code Before this change, fetch-update-write and bitmasking was hardcoded in attribute access code cased by the attribute type. Several filter instructions are used to do it instead. As this is certainly going to be a little bit slower than before, the switch block in attribute access code should be completely removed in near future, helping with both performance and code cleanliness. The user interface should have stayed intact. --- nest/route.h | 1 - 1 file changed, 1 deletion(-) (limited to 'nest/route.h') diff --git a/nest/route.h b/nest/route.h index 80c53ba6..a4af0edc 100644 --- a/nest/route.h +++ b/nest/route.h @@ -536,7 +536,6 @@ const char *ea_custom_name(uint ea); #define EAF_TYPE_IP_ADDRESS 0x04 /* IP address */ #define EAF_TYPE_ROUTER_ID 0x05 /* Router ID (IPv4 address) */ #define EAF_TYPE_AS_PATH 0x06 /* BGP AS path (encoding per RFC 1771:4.3) */ -#define EAF_TYPE_BITFIELD 0x09 /* 32-bit embedded bitfield */ #define EAF_TYPE_INT_SET 0x0a /* Set of u32's (e.g., a community list) */ #define EAF_TYPE_EC_SET 0x0e /* Set of pairs of u32's - ext. community list */ #define EAF_TYPE_LC_SET 0x12 /* Set of triplets of u32's - large community list */ -- cgit v1.2.3 From e261b325113a63410bc30287c135bf162480c3b2 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Thu, 14 Apr 2022 12:06:17 +0200 Subject: Dropping EAF_VAR_LENGTH as the attribute data is either embedded or adata --- nest/route.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nest/route.h') diff --git a/nest/route.h b/nest/route.h index a4af0edc..7557bf93 100644 --- a/nest/route.h +++ b/nest/route.h @@ -538,10 +538,10 @@ const char *ea_custom_name(uint ea); #define EAF_TYPE_AS_PATH 0x06 /* BGP AS path (encoding per RFC 1771:4.3) */ #define EAF_TYPE_INT_SET 0x0a /* Set of u32's (e.g., a community list) */ #define EAF_TYPE_EC_SET 0x0e /* Set of pairs of u32's - ext. community list */ -#define EAF_TYPE_LC_SET 0x12 /* Set of triplets of u32's - large community list */ -#define EAF_TYPE_IFACE 0x16 /* Interface pointer stored in adata */ +#define EAF_TYPE_LC_SET 0x08 /* Set of triplets of u32's - large community list */ +#define EAF_TYPE_IFACE 0x0c /* Interface pointer stored in adata */ #define EAF_EMBEDDED 0x01 /* Data stored in eattr.u.data (part of type spec) */ -#define EAF_VAR_LENGTH 0x02 /* Attribute length is variable (part of type spec) */ + /* Otherwise, attribute data is adata */ typedef struct adata { uint length; /* Length of data */ -- cgit v1.2.3 From 22f95d9889f07d868ffaec40ab43fd8dd9b0bb31 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Sat, 26 Mar 2022 12:37:41 +0100 Subject: Special attribute types for enums --- filter/config.Y | 2 +- filter/f-inst.c | 2 +- nest/route.h | 3 +++ nest/rt-attr.c | 7 +++++-- proto/bgp/attrs.c | 2 +- proto/bgp/config.Y | 2 +- proto/radv/config.Y | 2 +- 7 files changed, 13 insertions(+), 7 deletions(-) (limited to 'nest/route.h') diff --git a/filter/config.Y b/filter/config.Y index 67bd04b4..fb331c16 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -165,7 +165,7 @@ f_generate_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; diff --git a/filter/f-inst.c b/filter/f-inst.c index 8bfec479..11ca1e28 100644 --- a/filter/f-inst.c +++ b/filter/f-inst.c @@ -696,7 +696,7 @@ break; } - switch (e->type & EAF_TYPE_MASK) { + switch (e->type) { case EAF_TYPE_INT: RESULT_(da.f_type, i, e->u.data); break; diff --git a/nest/route.h b/nest/route.h index 7557bf93..d2f60f41 100644 --- a/nest/route.h +++ b/nest/route.h @@ -540,6 +540,9 @@ const char *ea_custom_name(uint ea); #define EAF_TYPE_EC_SET 0x0e /* Set of pairs of u32's - ext. community list */ #define EAF_TYPE_LC_SET 0x08 /* Set of triplets of u32's - large community list */ #define EAF_TYPE_IFACE 0x0c /* Interface pointer stored in adata */ +#define EAF_TYPE_BGP_ORIGIN 0x11 /* BGP Origin enum */ +#define EAF_TYPE_RA_PREFERENCE 0x13 /* RA Preference enum */ + #define EAF_EMBEDDED 0x01 /* Data stored in eattr.u.data (part of type spec) */ /* Otherwise, attribute data is adata */ diff --git a/nest/rt-attr.c b/nest/rt-attr.c index abda5d82..25548dca 100644 --- a/nest/rt-attr.c +++ b/nest/rt-attr.c @@ -948,7 +948,7 @@ ea_show(struct cli *c, const eattr *e) if (e->undef) bsprintf(pos, "undefined"); else - switch (e->type & EAF_TYPE_MASK) + switch (e->type) { case EAF_TYPE_INT: bsprintf(pos, "%u", e->u.data); @@ -1008,7 +1008,10 @@ ea_dump(ea_list *e) { eattr *a = &e->attrs[i]; debug(" %02x:%02x.%02x", EA_PROTO(a->id), EA_ID(a->id), a->flags); - debug("=%c", "?iO?I?P???S?????" [a->type & EAF_TYPE_MASK]); + debug("=%c", + "?iO?IRP???S??pE?" + "??L???N?????????" + "?o???r??????????" [a->type]); if (a->originated) debug("o"); if (a->type & EAF_EMBEDDED) diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index a7c49be5..b514f1b9 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -987,7 +987,7 @@ bgp_decode_unknown(struct bgp_parse_state *s, uint code, uint flags, byte *data, static const struct bgp_attr_desc bgp_attr_table[] = { [BA_ORIGIN] = { .name = "origin", - .type = EAF_TYPE_INT, + .type = EAF_TYPE_BGP_ORIGIN, .flags = BAF_TRANSITIVE, .export = bgp_export_origin, .encode = bgp_encode_u8, diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y index 241aa7c2..04920941 100644 --- a/proto/bgp/config.Y +++ b/proto/bgp/config.Y @@ -318,7 +318,7 @@ bgp_proto_channel: bgp_channel_start bgp_channel_opt_list bgp_channel_end; dynamic_attr: BGP_ORIGIN - { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_ENUM_BGP_ORIGIN, EA_CODE(PROTOCOL_BGP, BA_ORIGIN)); } ; + { $$ = f_new_dynamic_attr(EAF_TYPE_BGP_ORIGIN, T_ENUM_BGP_ORIGIN, EA_CODE(PROTOCOL_BGP, BA_ORIGIN)); } ; dynamic_attr: BGP_PATH { $$ = f_new_dynamic_attr(EAF_TYPE_AS_PATH, T_PATH, EA_CODE(PROTOCOL_BGP, BA_AS_PATH)); } ; dynamic_attr: BGP_NEXT_HOP diff --git a/proto/radv/config.Y b/proto/radv/config.Y index 8d4a3ab9..f16b897d 100644 --- a/proto/radv/config.Y +++ b/proto/radv/config.Y @@ -336,7 +336,7 @@ radv_sensitive: | SENSITIVE bool { $$ = $2; } ; -dynamic_attr: RA_PREFERENCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_ENUM_RA_PREFERENCE, EA_RA_PREFERENCE); } ; +dynamic_attr: RA_PREFERENCE { $$ = f_new_dynamic_attr(EAF_TYPE_RA_PREFERENCE, T_ENUM_RA_PREFERENCE, EA_RA_PREFERENCE); } ; dynamic_attr: RA_LIFETIME { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_RA_LIFETIME); } ; CF_CODE -- cgit v1.2.3