Good … now already afternoon, Nico!

On Sun, Sep 14, 2025 at 11:23:05AM +0200, Nico Schottelius wrote:

you have a very valid point I haven’t though about yet. You are right that currently filters and functions can just be used in the CLI w/o a “context”.

And maybe that is also the answer as to how bird should behave: if no “context” (or peer or whatever it will be named in the end) is supplied, I think bird should behave the same as before.

Yes, not only regular route filtering, there is multiple usage of the same filter engine where the context is different.

And we can even formalise this a bit and update the previous description:

string proto_to_or_destination_or_better_name

       The name of the protocol in which the filter or function is being
       called in. Allows to match on the destination.

       Might contain the empty string, if the evaluated outside a
       protocol context.

Empty string or undefined?

proto_to_or_destination_or_better_name is unset -> false

Well, this call is intended as “how do routes export to bar” check so here the name would be probably better set as the filter should imho run in the protocol context.

Otherwise you get different results than what gets exported, and the users get confused.

proto_to_or_destination_or_better_name is unset -> false

The question here is whether the filter engine should just silently treat the parameter as empty, or complain. I’m a little inclined for complaining because people may forget that they have target-specific behavior, try this while debugging, and get confused.

proto_to_or_destination_or_better_name is unset -> false

The same as above. Please note that if you ask for eval net, you get a runtime error because there is no route at all.

Now comes a however: however it might be helpful then to add a context alike syntax:

show route where foo() context proto bar

–> true

show route where foo() context proto foo

–> no routes

This looks viable, even though maybe a little bit clumsy.

proto_to_or_destination_or_better_name is = yay -> false

Indeed.

proto_to_or_destination_or_better_name is = yippie -> false

But then the template is used to create the protocol bar and one may expect there that we would evaluate the expression in the protocol context …

I’m not familiar with the sorted function, so no clue

It’s just a table parameter. I would say that the function may make use of some similar context but regarding the table involved instead.

Same as above, depends on where meow() is called.

In toplevel config, no block.

Basically these config uses are rudimentary uses of the filter engine to evaluate some config values. And the question is how to make this work the right way.

I think in the end, the actual value of proto_to_or_destination_or_better_name should be handled similar to how “net” is passed down:

Ha, you got to the same conclusion as myself above.

Thank you for opening this topic!

Thank you for being open and continuing to provide a great software!

We try our best. With open-source, one can actually quite openly discus what is going on and how things are going to be implemented. In the end, we need to collect the feature requirements early enough to not waste time implementing things wrongly.

Enjoy your sunny day!
Maria


Maria Matejka (she/her) | BIRD Team Leader | CZ.NIC, z.s.p.o.