Use Variables / Defines in include statements
Hi, i currently try to do different includes, based on an variable/define within the config. for example: function test(int asn) { [ do something general ] include "/etc/bird/" . asn . "-special.conf"; } As this approach doesn't work, is there currently an possibility to do such includes somehow? regards, tim -- Tim Weippert http://weiti.org - weiti@weiti.org GPG Fingerprint - E704 7303 6FF0 8393 ADB1 398E 67F2 94AE 5995 7DD8
On 01/17/2017 11:03 AM, Tim Weippert wrote:
Hi,
i currently try to do different includes, based on an variable/define within the config.
for example:
function test(int asn) {
[ do something general ]
include "/etc/bird/" . asn . "-special.conf";
}
As this approach doesn't work, is there currently an possibility to do such includes somehow?
regards, tim
Hi! I assume you call this function from a filter. It would mean to resolve the filename for every route import/export. This is virtually impossible in the current architecture of filters; in the far future when another filter language is involved, it may be possible but still slow (all the config reading and parsing must be involved together with several syscalls). It should be possible to use the case switch to explicitely include these files, one by one. It is also needed to reload the config on every change. case asn { 65500: include "/etc/bird/65500-special.conf"; 65511: include "/etc/bird/65511-special.conf"; ... } MQ
Hi Jan, On Tue, Jan 17, 2017 at 01:00:57PM +0100, Jan Matejka wrote:
On 01/17/2017 11:03 AM, Tim Weippert wrote:
[ ... ]
I assume you call this function from a filter. It would mean to resolve the filename for every route import/export. This is virtually impossible in the current architecture of filters; in the far future when another filter language is involved, it may be possible but still slow (all the config reading and parsing must be involved together with several syscalls).
Ok, good to know, that ot is currently not possible and maybe in future. So, i hadn't overseen something ..
It should be possible to use the case switch to explicitely include these files, one by one. It is also needed to reload the config on every change.
case asn { 65500: include "/etc/bird/65500-special.conf"; 65511: include "/etc/bird/65511-special.conf"; ... }
Yes, that's my plan C. Currently i use If clauses and that seems to work fine. regards, tim -- Tim Weippert http://weiti.org - weiti@weiti.org GPG Fingerprint - E704 7303 6FF0 8393 ADB1 398E 67F2 94AE 5995 7DD8
On Tue, Jan 17, 2017 at 01:00:57PM +0100, Jan Matejka wrote:
On 01/17/2017 11:03 AM, Tim Weippert wrote:
Hi,
i currently try to do different includes, based on an variable/define within the config.
for example:
function test(int asn) {
[ do something general ]
include "/etc/bird/" . asn . "-special.conf";
}
As this approach doesn't work, is there currently an possibility to do such includes somehow?
regards, tim
Hi!
It should be possible to use the case switch to explicitely include these files, one by one. It is also needed to reload the config on every change.
case asn { 65500: include "/etc/bird/65500-special.conf"; 65511: include "/etc/bird/65511-special.conf"; ... }
Hi Note that include is a preprocessor operation unrelated to the filter language, so in /etc/bird/65500-special.conf you would have to use { .. } to have a proper block. Also note that the current grammar require include to be on a new line, so you would have to use: case asn { 65500: include "/etc/bird/65500-special.conf"; 65511: include "/etc/bird/65511-special.conf"; ... } And finally, you could simply use wildcards: case asn { include "/etc/bird/*-special.conf"; } And then in in each file the appropriate case branch, like this for /etc/bird/65500-special.conf: 65500: { ... } -- 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 (3)
-
Jan Matejka -
Ondrej Zajicek -
Tim Weippert