summaryrefslogtreecommitdiff
path: root/proto/bgp/config.Y
diff options
context:
space:
mode:
authorkaterina.kubecova <katerina.kubecova@nic.cz>2023-09-19 11:11:24 +0200
committerMaria Matejka <mq@ucw.cz>2023-09-20 14:15:18 +0200
commita0fb0eaa6780e60b7c5434dfe0e2ed402e5a4ea4 (patch)
tree11ae3a94c24f580239bcae1dd9b1925c2d35b6fa /proto/bgp/config.Y
parentcc122bf0c295207a909061a365eccd49462b1b16 (diff)
BGP: Setting and unsetting unknown attributes
All these must be declared as bytestring. Allows operators to delete unwanted attributes breaking the Internet: https://blog.benjojo.co.uk/post/bgp-path-attributes-grave-error-handling
Diffstat (limited to 'proto/bgp/config.Y')
-rw-r--r--proto/bgp/config.Y11
1 files changed, 10 insertions, 1 deletions
diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y
index a1f1f5ac..d9ff24d8 100644
--- a/proto/bgp/config.Y
+++ b/proto/bgp/config.Y
@@ -362,7 +362,16 @@ dynamic_attr: BGP_LARGE_COMMUNITY
dynamic_attr: BGP_OTC
{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(PROTOCOL_BGP, BA_ONLY_TO_CUSTOMER)); } ;
-
+custom_attr: ATTRIBUTE BGP NUM type symbol ';' {
+ if($3 > 255 || $3 < 1)
+ cf_error("Invalid attribute number. (Given %i, must be 1-255.)", $3);
+ if($4 != T_BYTESTRING)
+ cf_error("Attribute type must be bytestring, not %s.", f_type_name($4));
+ struct f_dynamic_attr* a = (struct f_dynamic_attr*) malloc(sizeof(struct f_dynamic_attr));
+ *a = f_new_dynamic_attr(f_type_attr($4), T_BYTESTRING, EA_CODE(PROTOCOL_BGP, $3));
+ a->flags = BAF_TRANSITIVE | BAF_OPTIONAL;
+ cf_define_symbol(new_config, $5, SYM_ATTRIBUTE, attribute, a);
+};
CF_ENUM(T_ENUM_BGP_ORIGIN, ORIGIN_, IGP, EGP, INCOMPLETE)