summaryrefslogtreecommitdiff
path: root/proto/bgp
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-05-30 15:43:13 +0200
committerMaria Matejka <mq@ucw.cz>2022-05-30 15:43:13 +0200
commit54344f15f8a6a6f5f0388097a1825a9c08c17482 (patch)
tree85af19e3330719d3486efdf8a12fc5f9549b72ac /proto/bgp
parent3752654852f4962465154257348000d6de1c2dae (diff)
parent0d0f6554a5c233bf2bf830ae319191c4b1808d49 (diff)
Merge commit '0d0f6554a5c233bf2bf830ae319191c4b1808d49' into haugesund
Diffstat (limited to 'proto/bgp')
-rw-r--r--proto/bgp/attrs.c40
-rw-r--r--proto/bgp/bgp.h16
-rw-r--r--proto/bgp/config.Y26
3 files changed, 44 insertions, 38 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index 4cc089e9..ed1bb12f 100644
--- a/proto/bgp/attrs.c
+++ b/proto/bgp/attrs.c
@@ -80,7 +80,7 @@ static const struct bgp_attr_desc bgp_attr_table[];
static inline int bgp_attr_known(uint code);
eattr *
-bgp_set_attr(ea_list **attrs, struct linpool *pool, uint code, uint flags, uintptr_t val)
+bgp_set_attr(ea_list **attrs, struct linpool *pool, uint code, uint flags, union bval val)
{
ASSERT(bgp_attr_known(code));
@@ -976,7 +976,7 @@ static inline void
bgp_decode_unknown(struct bgp_parse_state *s, uint code, uint flags, byte *data, uint len, ea_list **to)
{
/* Cannot use bgp_set_attr_data() as it works on known attributes only */
- ea_set_attr_data(to, s->pool, EA_CODE(PROTOCOL_BGP, code), flags, EAF_TYPE_OPAQUE, data, len);
+ ea_set_attr_data(to, s->pool, EA_CODE(PROTOCOL_BGP, code), flags, T_OPAQUE, data, len);
}
@@ -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_BGP_ORIGIN,
+ .type = T_ENUM_BGP_ORIGIN,
.flags = BAF_TRANSITIVE,
.export = bgp_export_origin,
.encode = bgp_encode_u8,
@@ -996,14 +996,14 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_AS_PATH] = {
.name = "as_path",
- .type = EAF_TYPE_AS_PATH,
+ .type = T_PATH,
.flags = BAF_TRANSITIVE,
.encode = bgp_encode_as_path,
.decode = bgp_decode_as_path,
},
[BA_NEXT_HOP] = {
.name = "next_hop",
- .type = EAF_TYPE_IP_ADDRESS,
+ .type = T_IP,
.flags = BAF_TRANSITIVE,
.encode = bgp_encode_next_hop,
.decode = bgp_decode_next_hop,
@@ -1011,14 +1011,14 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_MULTI_EXIT_DISC] = {
.name = "med",
- .type = EAF_TYPE_INT,
+ .type = T_INT,
.flags = BAF_OPTIONAL,
.encode = bgp_encode_u32,
.decode = bgp_decode_med,
},
[BA_LOCAL_PREF] = {
.name = "local_pref",
- .type = EAF_TYPE_INT,
+ .type = T_INT,
.flags = BAF_TRANSITIVE,
.export = bgp_export_local_pref,
.encode = bgp_encode_u32,
@@ -1026,14 +1026,14 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_ATOMIC_AGGR] = {
.name = "atomic_aggr",
- .type = EAF_TYPE_OPAQUE,
+ .type = T_OPAQUE,
.flags = BAF_TRANSITIVE,
.encode = bgp_encode_raw,
.decode = bgp_decode_atomic_aggr,
},
[BA_AGGREGATOR] = {
.name = "aggregator",
- .type = EAF_TYPE_OPAQUE,
+ .type = T_OPAQUE,
.flags = BAF_OPTIONAL | BAF_TRANSITIVE,
.encode = bgp_encode_aggregator,
.decode = bgp_decode_aggregator,
@@ -1041,7 +1041,7 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_COMMUNITY] = {
.name = "community",
- .type = EAF_TYPE_INT_SET,
+ .type = T_CLIST,
.flags = BAF_OPTIONAL | BAF_TRANSITIVE,
.export = bgp_export_community,
.encode = bgp_encode_u32s,
@@ -1049,7 +1049,7 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_ORIGINATOR_ID] = {
.name = "originator_id",
- .type = EAF_TYPE_ROUTER_ID,
+ .type = T_QUAD,
.flags = BAF_OPTIONAL,
.export = bgp_export_originator_id,
.encode = bgp_encode_u32,
@@ -1057,7 +1057,7 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_CLUSTER_LIST] = {
.name = "cluster_list",
- .type = EAF_TYPE_INT_SET,
+ .type = T_CLIST,
.flags = BAF_OPTIONAL,
.export = bgp_export_cluster_list,
.encode = bgp_encode_u32s,
@@ -1066,19 +1066,19 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_MP_REACH_NLRI] = {
.name = "mp_reach_nlri",
- .type = EAF_TYPE_OPAQUE,
+ .type = T_OPAQUE,
.flags = BAF_OPTIONAL,
.decode = bgp_decode_mp_reach_nlri,
},
[BA_MP_UNREACH_NLRI] = {
.name = "mp_unreach_nlri",
- .type = EAF_TYPE_OPAQUE,
+ .type = T_OPAQUE,
.flags = BAF_OPTIONAL,
.decode = bgp_decode_mp_unreach_nlri,
},
[BA_EXT_COMMUNITY] = {
.name = "ext_community",
- .type = EAF_TYPE_EC_SET,
+ .type = T_ECLIST,
.flags = BAF_OPTIONAL | BAF_TRANSITIVE,
.export = bgp_export_ext_community,
.encode = bgp_encode_u32s,
@@ -1086,14 +1086,14 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_AS4_PATH] = {
.name = "as4_path",
- .type = EAF_TYPE_AS_PATH,
+ .type = T_PATH,
.flags = BAF_OPTIONAL | BAF_TRANSITIVE,
.encode = bgp_encode_raw,
.decode = bgp_decode_as4_path,
},
[BA_AS4_AGGREGATOR] = {
.name = "as4_aggregator",
- .type = EAF_TYPE_OPAQUE,
+ .type = T_OPAQUE,
.flags = BAF_OPTIONAL | BAF_TRANSITIVE,
.encode = bgp_encode_raw,
.decode = bgp_decode_as4_aggregator,
@@ -1101,7 +1101,7 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_AIGP] = {
.name = "aigp",
- .type = EAF_TYPE_OPAQUE,
+ .type = T_OPAQUE,
.flags = BAF_OPTIONAL | BAF_DECODE_FLAGS,
.export = bgp_export_aigp,
.encode = bgp_encode_raw,
@@ -1110,7 +1110,7 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_LARGE_COMMUNITY] = {
.name = "large_community",
- .type = EAF_TYPE_LC_SET,
+ .type = T_LCLIST,
.flags = BAF_OPTIONAL | BAF_TRANSITIVE,
.export = bgp_export_large_community,
.encode = bgp_encode_u32s,
@@ -1118,7 +1118,7 @@ static const struct bgp_attr_desc bgp_attr_table[] = {
},
[BA_MPLS_LABEL_STACK] = {
.name = "mpls_label_stack",
- .type = EAF_TYPE_INT_SET,
+ .type = T_CLIST,
.export = bgp_export_mpls_label_stack,
.encode = bgp_encode_mpls_label_stack,
.decode = bgp_decode_mpls_label_stack,
diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h
index 022adb39..4a06eba2 100644
--- a/proto/bgp/bgp.h
+++ b/proto/bgp/bgp.h
@@ -545,22 +545,28 @@ bgp_find_attr(ea_list *attrs, uint code)
}
eattr *
-bgp_set_attr(ea_list **attrs, struct linpool *pool, uint code, uint flags, uintptr_t val);
+bgp_set_attr(ea_list **attrs, struct linpool *pool, uint code, uint flags, union bval val);
static inline void
bgp_set_attr_u32(ea_list **to, struct linpool *pool, uint code, uint flags, u32 val)
-{ bgp_set_attr(to, pool, code, flags, (uintptr_t) val); }
+{
+ union bval bv = { .data = val };
+ bgp_set_attr(to, pool, code, flags, bv);
+}
static inline void
-bgp_set_attr_ptr(ea_list **to, struct linpool *pool, uint code, uint flags, const struct adata *val)
-{ bgp_set_attr(to, pool, code, flags, (uintptr_t) val); }
+bgp_set_attr_ptr(ea_list **to, struct linpool *pool, uint code, uint flags, const struct adata *ad)
+{
+ union bval bv = { .ptr = ad };
+ bgp_set_attr(to, pool, code, flags, bv);
+}
static inline void
bgp_set_attr_data(ea_list **to, struct linpool *pool, uint code, uint flags, void *data, uint len)
{
struct adata *a = lp_alloc_adata(pool, len);
bmemcpy(a->data, data, len);
- bgp_set_attr(to, pool, code, flags, (uintptr_t) a);
+ bgp_set_attr_ptr(to, pool, code, flags, a);
}
#define bgp_unset_attr(to, pool, code) ea_unset_attr(to, pool, 0, code)
diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y
index 86124bfb..6a78f79b 100644
--- a/proto/bgp/config.Y
+++ b/proto/bgp/config.Y
@@ -318,31 +318,31 @@ bgp_proto_channel: bgp_channel_start bgp_channel_opt_list bgp_channel_end;
dynamic_attr: BGP_ORIGIN
- { $$ = f_new_dynamic_attr(EAF_TYPE_BGP_ORIGIN, T_ENUM_BGP_ORIGIN, EA_CODE(PROTOCOL_BGP, BA_ORIGIN)); } ;
+ { $$ = f_new_dynamic_attr(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)); } ;
+ { $$ = f_new_dynamic_attr(T_PATH, EA_CODE(PROTOCOL_BGP, BA_AS_PATH)); } ;
dynamic_attr: BGP_NEXT_HOP
- { $$ = f_new_dynamic_attr(EAF_TYPE_IP_ADDRESS, T_IP, EA_CODE(PROTOCOL_BGP, BA_NEXT_HOP)); } ;
+ { $$ = f_new_dynamic_attr(T_IP, EA_CODE(PROTOCOL_BGP, BA_NEXT_HOP)); } ;
dynamic_attr: BGP_MED
- { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(PROTOCOL_BGP, BA_MULTI_EXIT_DISC)); } ;
+ { $$ = f_new_dynamic_attr(T_INT, EA_CODE(PROTOCOL_BGP, BA_MULTI_EXIT_DISC)); } ;
dynamic_attr: BGP_LOCAL_PREF
- { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(PROTOCOL_BGP, BA_LOCAL_PREF)); } ;
+ { $$ = f_new_dynamic_attr(T_INT, EA_CODE(PROTOCOL_BGP, BA_LOCAL_PREF)); } ;
dynamic_attr: BGP_ATOMIC_AGGR
- { $$ = f_new_dynamic_attr(EAF_TYPE_OPAQUE, T_OPAQUE, EA_CODE(PROTOCOL_BGP, BA_ATOMIC_AGGR)); } ;
+ { $$ = f_new_dynamic_attr(T_OPAQUE, EA_CODE(PROTOCOL_BGP, BA_ATOMIC_AGGR)); } ;
dynamic_attr: BGP_AGGREGATOR
- { $$ = f_new_dynamic_attr(EAF_TYPE_OPAQUE, T_OPAQUE, EA_CODE(PROTOCOL_BGP, BA_AGGREGATOR)); } ;
+ { $$ = f_new_dynamic_attr(T_OPAQUE, EA_CODE(PROTOCOL_BGP, BA_AGGREGATOR)); } ;
dynamic_attr: BGP_COMMUNITY
- { $$ = f_new_dynamic_attr(EAF_TYPE_INT_SET, T_CLIST, EA_CODE(PROTOCOL_BGP, BA_COMMUNITY)); } ;
+ { $$ = f_new_dynamic_attr(T_CLIST, EA_CODE(PROTOCOL_BGP, BA_COMMUNITY)); } ;
dynamic_attr: BGP_ORIGINATOR_ID
- { $$ = f_new_dynamic_attr(EAF_TYPE_ROUTER_ID, T_QUAD, EA_CODE(PROTOCOL_BGP, BA_ORIGINATOR_ID)); } ;
+ { $$ = f_new_dynamic_attr(T_QUAD, EA_CODE(PROTOCOL_BGP, BA_ORIGINATOR_ID)); } ;
dynamic_attr: BGP_CLUSTER_LIST
- { $$ = f_new_dynamic_attr(EAF_TYPE_INT_SET, T_CLIST, EA_CODE(PROTOCOL_BGP, BA_CLUSTER_LIST)); } ;
+ { $$ = f_new_dynamic_attr(T_CLIST, EA_CODE(PROTOCOL_BGP, BA_CLUSTER_LIST)); } ;
dynamic_attr: BGP_EXT_COMMUNITY
- { $$ = f_new_dynamic_attr(EAF_TYPE_EC_SET, T_ECLIST, EA_CODE(PROTOCOL_BGP, BA_EXT_COMMUNITY)); } ;
+ { $$ = f_new_dynamic_attr(T_ECLIST, EA_CODE(PROTOCOL_BGP, BA_EXT_COMMUNITY)); } ;
dynamic_attr: BGP_AIGP
- { $$ = f_new_dynamic_attr(EAF_TYPE_OPAQUE, T_OPAQUE, EA_CODE(PROTOCOL_BGP, BA_AIGP)); } ;
+ { $$ = f_new_dynamic_attr(T_OPAQUE, EA_CODE(PROTOCOL_BGP, BA_AIGP)); } ;
dynamic_attr: BGP_LARGE_COMMUNITY
- { $$ = f_new_dynamic_attr(EAF_TYPE_LC_SET, T_LCLIST, EA_CODE(PROTOCOL_BGP, BA_LARGE_COMMUNITY)); } ;
+ { $$ = f_new_dynamic_attr(T_LCLIST, EA_CODE(PROTOCOL_BGP, BA_LARGE_COMMUNITY)); } ;