Strange behaviour on filtering bgp_large_community ...
Hi List, maybe i'm doing something wrong, but if i use some quick and dirty filter on the CLI all is working as expecting: show route where bgp_large_community ~ [(65000, 0, 1001)] show route where (65000, 0, 1001) ~ bgp_large_community both get the expected results, show all routes with the specific community attached. If i use it in a filter function to filter the routes out: function filter_large(int TestID) { if ( bgp_large_community ~ [(65000, 0, TestID)] ) then { return false; } return true; } i get "all" routes, if clause doesn't get catched. function filter_large_V2(int TestID) { if ( (65000, 0, TestID) ~ bgp_large_community ) then { return false; } return true; } with the V2 function i get what i want, filter out all routes with the community attached and show all the rest. I'm a little confused here, because the first version of the if clause is used for bgp_ext_community on several functions on my setup and working as expected, only for bgp_large_community i need to switch to if clause from version V2, and only in a function? Can someone confirm or explain this? regards, tim -- Tim Weippert http://weiti.org - weiti@weiti.org GPG Fingerprint - E704 7303 6FF0 8393 ADB1 398E 67F2 94AE 5995 7DD8
I also noticed once that my filters only work correctly when I make (x, y, z) ~ bgp_large_community, the other way around it didn't work for me either. I didn't think anything about it though. Maybe this is a bug? On Mon, 15 May 2023 12:59:11 +0200 Tim Weippert via Bird-users <bird-users@network.cz> wrote:
Hi List,
maybe i'm doing something wrong, but if i use some quick and dirty filter on the CLI all is working as expecting:
show route where bgp_large_community ~ [(65000, 0, 1001)] show route where (65000, 0, 1001) ~ bgp_large_community
both get the expected results, show all routes with the specific community attached.
If i use it in a filter function to filter the routes out:
function filter_large(int TestID) { if ( bgp_large_community ~ [(65000, 0, TestID)] ) then { return false; } return true; }
i get "all" routes, if clause doesn't get catched.
function filter_large_V2(int TestID) { if ( (65000, 0, TestID) ~ bgp_large_community ) then { return false; } return true; }
with the V2 function i get what i want, filter out all routes with the community attached and show all the rest.
I'm a little confused here, because the first version of the if clause is used for bgp_ext_community on several functions on my setup and working as expected, only for bgp_large_community i need to switch to if clause from version V2, and only in a function?
Can someone confirm or explain this?
regards, tim
-- Tim Weippert http://weiti.org - weiti@weiti.org GPG Fingerprint - E704 7303 6FF0 8393 ADB1 398E 67F2 94AE 5995 7DD8
-- Marek Küthe m.k@mk16.de er/ihm he/him
On Mon, May 15, 2023 at 12:59:11PM +0200, Tim Weippert via Bird-users wrote:
Hi List,
maybe i'm doing something wrong, but if i use some quick and dirty filter on the CLI all is working as expecting:
show route where bgp_large_community ~ [(65000, 0, 1001)] show route where (65000, 0, 1001) ~ bgp_large_community
both get the expected results, show all routes with the specific community attached.
If i use it in a filter function to filter the routes out:
function filter_large(int TestID) { if ( bgp_large_community ~ [(65000, 0, TestID)] ) then { return false; } return true; }
i get "all" routes, if clause doesn't get catched.
function filter_large_V2(int TestID) { if ( (65000, 0, TestID) ~ bgp_large_community ) then { return false; } return true; }
with the V2 function i get what i want, filter out all routes with the community attached and show all the rest.
I'm a little confused here, because the first version of the if clause is used for bgp_ext_community on several functions on my setup and working as expected, only for bgp_large_community i need to switch to if clause from version V2, and only in a function?
Hi Set expressions like [...] in BIRD are static and created in parse-time. Therefore [(65000, 0, 1001)] is valid, while [(65000, 0, TestID)] is valid only if TestID is constant (like with 'define TestID = 100;'). In your case of filter_large() the TestID is a local variable, so [(65000, 0, TestID)] should fail during configuration parsing as non-constant expression. It seems it is not checked, so it is probably just evaluated TestID to zero or some random value and used that. -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
Hi Ondrej, On Fri, May 19, 2023 at 01:43:48AM +0200, Ondrej Zajicek wrote:
On Mon, May 15, 2023 at 12:59:11PM +0200, Tim Weippert via Bird-users wrote:
Hi List,
maybe i'm doing something wrong, but if i use some quick and dirty filter on the CLI all is working as expecting:
show route where bgp_large_community ~ [(65000, 0, 1001)] show route where (65000, 0, 1001) ~ bgp_large_community
[ ... ]
Hi
Set expressions like [...] in BIRD are static and created in parse-time. Therefore [(65000, 0, 1001)] is valid, while [(65000, 0, TestID)] is valid only if TestID is constant (like with 'define TestID = 100;').
In your case of filter_large() the TestID is a local variable, so [(65000, 0, TestID)] should fail during configuration parsing as non-constant expression. It seems it is not checked, so it is probably just evaluated TestID to zero or some random value and used that.
Understood, so it depends if it is a static text like in my CLI tests or an "variable which are changed in runtime". But the usage of '(65000, 0, TestID) ~ bgp_large_community' will work with both expressions. So for my use case it would be good to stick with one variant which works in both situations. thanks & regards, tim -- Tim Weippert http://weiti.org - weiti@weiti.org GPG Fingerprint - E704 7303 6FF0 8393 ADB1 398E 67F2 94AE 5995 7DD8
participants (3)
-
Marek Küthe -
Ondrej Zajicek -
Tim Weippert