Pair components built from expressions are checked only when the filter runs. Document this failure mode and show how to guard a 32-bit large community field before using it as a 16-bit pair component. Target: patch --- doc/bird.sgml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/bird.sgml b/doc/bird.sgml index b97793f4..335a2d76 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -1848,6 +1848,10 @@ in the foot). Operators <cf/.asn/ and <cf/.data/ can be used to extract corresponding components of a pair: <cf>(<m/asn/, <m/data/)</cf>. + Pair construction from expressions is range-checked at filter runtime. + If either expression evaluates to a value greater than 65535, filter + evaluation fails with a runtime error. + <tag><label id="type-quad">quad</tag> This is a dotted quad of numbers used to represent router IDs (and others). Each component can have a value from 0 to 255. Literals of @@ -1990,6 +1994,18 @@ in the foot). to extract corresponding components of LCs: <cf>(<m/asn/, <m/data1/, <m/data2/)</cf>. + Large community fields are 32-bit, while pair components are 16-bit. + Therefore, check the range before using an LC field to construct a pair. + For example, given an LC value in <cf/op/: + <code> + if op.data2 <= 65535 then + bgp_community.add((64512, op.data2)); + else + reject; + </code> + The explicit <cf/reject/ is optional policy; a filter may instead ignore + an LC that cannot be represented as a pair. + <tag><label id="type-set">int|pair|quad|ip|prefix|ec|lc|rd|enum set</tag> Filters recognize several types of sets. Sets are similar to strings: you can pass them around but you cannot modify them. Literals of type <cf>int -- 2.47.3