Bird 2.0.0 and (filter) code deduplication
Hello *, TL;DR: Skip to last paragraph. during the migration to Bird 2.0.0, the combined linecount of my bird config files has increased by quite a bit. The bulk of the increase is an unfortunate consequence of the bird/bird6 merge which I'll describe in the following. With Bird 1.6.3 I could reuse protocol-agnostic filter code using the following scheme: $ cat bird.conf function foo() { # some v4-specific filter checks } include "common"; $ cat bird6.conf # same thing in green $ cat common function bar() { # protocol-agnostic boilerplate with calls to foo() all over it } This approach for code deduplication has become substantially more difficult with Bird 2.0.0. I do, however, have an suggestion on how to fix this: Could you please add a way to check the current channel's AFI/SAFI from within filter code? That way, I could keep my bar() function unmodified and merge the two foo() implementations using a 'if afi = "ipv4" then { } else { }' construction. Regards, Luis Ressel
On Sun, Dec 17, 2017 at 01:37:39AM +0100, Luis Ressel wrote:
Hello *,
Could you please add a way to check the current channel's AFI/SAFI from within filter code? That way, I could keep my bar() function unmodified and merge the two foo() implementations using a 'if afi = "ipv4" then { } else { }' construction.
Hi You can use 'net.type = NET_IP4', 'net.type = NET_IP6'. See: http://bird.network.cz/?get_doc&f=bird-5.html#type-prefix -- 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."
You can use ‘net.type = NET_IP4', 'net.type = NET_IP6'.
Nice … And you can also „just“ mix IPv6 and legacy IPv4 matches in prefix-lists, etc.: if net ~ [ 2001:db8::/32+, # doc fc00::/15+, # ULAs fe80::/16+ # link locals 192.168.0.0/16+, # RFC1918 172.16.0.0/24+, # RFC1918 10.0.0.0/8+, # RFC1918 ] then { Works just fine with 2.0.0 … -c
On Sun, 17 Dec 2017 13:43:03 +0100 Clemens Schrimpe <clemens.schrimpe@gmail.com> wrote:
You can use ‘net.type = NET_IP4', 'net.type = NET_IP6'.
Nice …
And you can also „just“ mix IPv6 and legacy IPv4 matches in prefix-lists, etc.:
Thanks to both of you! The mixed sets are a nice trick which will take care of parts of my AFI-dependant configs, and for the rest (ROA, for example), I'll use Ondrej's suggestion. Cheers, Luis Ressel
participants (3)
-
Clemens Schrimpe -
Luis Ressel -
Ondrej Zajicek