Hello, I want to do function, which adds many communities in one function call now I use it like this: function add_community(pair peer_community) { bgp_community.add(peer_community); return true; } add_community((11111, 4444)) && add_community((11111, 5555)) && add_community((2222, 6666)) and I want to do something like this: function add_community(pair set peer_community) { bgp_community.add(peer_community); # doesnt work, incompatible types return true; } and call it like this: add_community([ (11111, 4444), (11111, 5555), (2222, 6666) ]) is it possible? Thank you Jirasek
On Fri, Apr 13, 2012 at 11:09:58AM +0200, Jaroslav Jir??sek wrote:
Hello,
Hello.
and I want to do something like this:
function add_community(pair set peer_community) { bgp_community.add(peer_community); # doesnt work, incompatible types return true; }
and call it like this:
add_community([ (11111, 4444), (11111, 5555), (2222, 6666) ])
is it possible?
Not directly like this. But if you have few known communites, you can do next hardcode: function add_community(pair set comm) { if ( (123,555) ~ comm ) then bgp_community.add((123,555)); if ( (123,666) ~ comm ) then bgp_community.add((123,666)); if ( (123,777) ~ comm ) then bgp_community.add((123,777)); if ( (123,888) ~ comm ) then bgp_community.add((123,888)); } This is ugly, but if you have little count of communities this is not annoying solution.
On Fri, 13 Apr 2012, Oleg wrote:
function add_community(pair set peer_community) { bgp_community.add(peer_community); # doesnt work, incompatible types return true; }
...
Not directly like this. But if you have few known communites, you can do next hardcode:
function add_community(pair set comm) { if ( (123,555) ~ comm ) then bgp_community.add((123,555)); if ( (123,666) ~ comm ) then bgp_community.add((123,666)); if ( (123,777) ~ comm ) then bgp_community.add((123,777)); if ( (123,888) ~ comm ) then bgp_community.add((123,888)); }
This is ugly, but if you have little count of communities this is not annoying solution.
Well, we cannot have clist literals, only pair set literals. That makes this limitation of clist operations rather unfortunate. Can BIRD be extended to allow operating on clists using pair sets? I.e. clist.add(pair set), clist.delete(pair set)... commit 0888a737b045b48106edbd28ba3cd62fcc8c191e, "Extends set operations in filters." did add the relevant clist to clist operations, but pair sets were still left unimplemented... -- "One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
On Fri, Apr 13, 2012 at 05:00:40PM -0300, Henrique de Moraes Holschuh wrote:
Well, we cannot have clist literals, only pair set literals. That makes this limitation of clist operations rather unfortunate.
Can BIRD be extended to allow operating on clists using pair sets?
I.e. clist.add(pair set), clist.delete(pair set)...
You could use clist.delete(pair set) or clist.filter(pair set). Only nonimplemented think is clist.add(pair set), which is operation that would expand compact representation of pair sets to explicit representation of clist, which is generally expensive and that may not be obvious to some users. For example, even restricted user from bird client could exhaust all memory by using show route command with some filter containing clist.add([(*,*)]). If we explicitly limit number of communities in clist, it could be done, but it is probably better idea to implement clist literals, which may be also useful for explicitly setting bgp_community with initial clist. -- 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."
On Tue, 17 Apr 2012, Ondrej Zajicek wrote:
On Fri, Apr 13, 2012 at 05:00:40PM -0300, Henrique de Moraes Holschuh wrote:
Well, we cannot have clist literals, only pair set literals. That makes this limitation of clist operations rather unfortunate.
Can BIRD be extended to allow operating on clists using pair sets?
I.e. clist.add(pair set), clist.delete(pair set)...
You could use clist.delete(pair set) or clist.filter(pair set). Only nonimplemented think is clist.add(pair set), which is operation that would expand compact representation of pair sets to explicit representation of clist, which is generally expensive and that may not be obvious to some users. For example, even restricted user from bird client could exhaust all memory by using show route command with some filter containing clist.add([(*,*)]).
If we explicitly limit number of communities in clist, it could be done, but it is probably better idea to implement clist literals, which may be also useful for explicitly setting bgp_community with initial clist.
Well, clist literals would solve my use case, and also the use case presented in this thread. So that might indeed be a better option. -- "One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
participants (4)
-
Henrique de Moraes Holschuh -
Jaroslav Jirásek -
Oleg -
Ondrej Zajicek