operator to prepend bgp path multiple times
Hi, I suggest to add a new operator: prepend_times(P, A, N) - that will allow to prepend AS A to path P several times (N). Now we need to use some function like this: function add_prepends(int asn, int num) { if num = 1 then { bgp_path.prepend(asn); } else if num = 2 then { bgp_path.prepend(asn); bgp_path.prepend(asn); } else if num = 3 then { ... } Usually the number of prepends is observable, so this function can fit most of cases, but with available operator it will be a bit more convenient, a little syntactic sugar. But it is not something that is hard to live without, of course. In my patch, I chose to "join" implementations of prepend() and prepend_times(). It is questionable, because it requires some additional supporting stuff if I understood right. So may be it is better to implement it as separate operators.
Hello, Wow, I see in the next branch we now have recursive functions supported. So this function became easier to implement in a config. At least I do not want to have it out of the box now. On Sat, Jan 1, 2022 at 8:24 PM Alexander Zubkov <green@qrator.net> wrote:
Hi,
I suggest to add a new operator: prepend_times(P, A, N) - that will allow to prepend AS A to path P several times (N). Now we need to use some function like this:
function add_prepends(int asn, int num) { if num = 1 then { bgp_path.prepend(asn); } else if num = 2 then { bgp_path.prepend(asn); bgp_path.prepend(asn); } else if num = 3 then { ... }
Usually the number of prepends is observable, so this function can fit most of cases, but with available operator it will be a bit more convenient, a little syntactic sugar. But it is not something that is hard to live without, of course.
In my patch, I chose to "join" implementations of prepend() and prepend_times(). It is questionable, because it requires some additional supporting stuff if I understood right. So may be it is better to implement it as separate operators.
On Mon, Mar 14, 2022 at 05:30:48PM +0100, Alexander Zubkov wrote:
Hello,
Wow, I see in the next branch we now have recursive functions supported. So this function became easier to implement in a config. At least I do not want to have it out of the box now.
Hi Yes, i recently immersed into filtering code to implement function call argument type checking, and with that i also implemented direct recursion, in-code variable definitions with initializers, and for loops to iterate over *lists and bgp paths. -- 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."
participants (2)
-
Alexander Zubkov -
Ondrej Zajicek