diff options
author | katerina.kubecova <katerina.kubecova@nic.cz> | 2023-09-19 11:11:24 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2023-09-20 14:15:18 +0200 |
commit | a0fb0eaa6780e60b7c5434dfe0e2ed402e5a4ea4 (patch) | |
tree | 11ae3a94c24f580239bcae1dd9b1925c2d35b6fa /filter | |
parent | cc122bf0c295207a909061a365eccd49462b1b16 (diff) | |
download | bird-a0fb0eaa6780e60b7c5434dfe0e2ed402e5a4ea4.tar.gz |
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 'filter')
-rw-r--r-- | filter/data.h | 1 | ||||
-rw-r--r-- | filter/f-inst.c | 2 | ||||
-rw-r--r-- | filter/f-inst.h | 15 |
3 files changed, 17 insertions, 1 deletions
diff --git a/filter/data.h b/filter/data.h index 90e779c8..3430455a 100644 --- a/filter/data.h +++ b/filter/data.h @@ -99,6 +99,7 @@ struct f_dynamic_attr { u8 bit; /* For bitfield accessors */ enum f_type f_type; /* Filter type */ uint ea_code; /* EA code */ + uint flags; }; enum f_sa_code { diff --git a/filter/f-inst.c b/filter/f-inst.c index 510c431f..a7bec81e 100644 --- a/filter/f-inst.c +++ b/filter/f-inst.c @@ -857,7 +857,7 @@ l->flags = EALF_SORTED; l->count = 1; l->attrs[0].id = da.ea_code; - l->attrs[0].flags = 0; + l->attrs[0].flags = da.flags; l->attrs[0].type = da.type; l->attrs[0].originated = 1; l->attrs[0].fresh = 1; diff --git a/filter/f-inst.h b/filter/f-inst.h index 2bde6378..955cfbdc 100644 --- a/filter/f-inst.h +++ b/filter/f-inst.h @@ -118,6 +118,21 @@ static inline struct f_dynamic_attr f_new_dynamic_attr_bit(u8 bit, enum f_type f static inline struct f_static_attr f_new_static_attr(int f_type, int code, int readonly) { return (struct f_static_attr) { .f_type = f_type, .sa_code = code, .readonly = readonly }; } +static inline int f_type_attr(int f_type) { + switch (f_type) { + case T_INT: return EAF_TYPE_INT; + case T_IP: return EAF_TYPE_IP_ADDRESS; + case T_QUAD: return EAF_TYPE_ROUTER_ID; + case T_PATH: return EAF_TYPE_AS_PATH; + case T_CLIST: return EAF_TYPE_INT_SET; + case T_ECLIST: return EAF_TYPE_EC_SET; + case T_LCLIST: return EAF_TYPE_LC_SET; + case T_BYTESTRING: return EAF_TYPE_OPAQUE; + default: + cf_error("Custom route attribute of unsupported type"); + } +} + /* Hook for call bt_assert() function in configuration */ extern void (*bt_assert_hook)(int result, const struct f_line_item *assert); |