On Thu, Dec 16, 2021 at 02:41:28PM +0100, Alexander Zubkov wrote:
Hi everyone!
I made a couple of patches to do some interesting stuff with communities. The first patch allows to pick a component from a standard or a large community:
(10, 20, 30) @ 2 --> 20
And the second patch allows to search for minimum or maximum element in a community list. This combined allows to do some cool stuff with communities like this:
bgp_local_pref = filter(bgp_large_community, [(<as>, <localpref_val>, *)]).min @ 3
This will find us the minimum from our "localpref" communities and get that number as integer, ready to assign it where we need. Now we use a series of if's to check all the possible variants and that is not very convenient. I think this features will greatly boost the possibilities of working with communities in bird.
Hi Nice patches, thanks! I agree that these features are pretty useful. Will merge the second one with no comments. With the first one, i do not really like the syntax. (Large) communities are not arrays to access them with indexing operator, and also using '@' as indexing operator is pretty unortodox. These are regular structures, so it is natural to use structure field accessors. Question is how these fields should be named, perhaps: global_id, data_1, data_2? That would make: (10, 20, 30) . global_id --> 10 (10, 20, 30) . data_1 --> 20 -- 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."