Defines for mixed IPv6/IPv4

Nico Schottelius nico.schottelius at ungleich.ch
Tue Jan 23 14:13:02 CET 2024


Hello bird users,

I am wondering how you handle matching both IPv6 and IPv4 prefixes
efficiently.

We have tons of blocks in our config like these:

define net_genauso_v6 = [
       2a0a:5480::/29+
];

define net_genauso_v4 = [
       185.203.113.0/24,
       185.116.114.0/24
];

And then later we have a function that combines them like this:

function is_genauso() -> bool
{
  if ((net ~ net_genauso_v6) ||
      (net ~ net_genauso_v4)) then {
      return true;
  }

  return false;
}

And then much later, we have various filters utilising the function, the
most simple one being:

filter genauso {
  if(is_genauso()) then accept;
  reject;
}

Which is then used in both IPv4 & IPv6 channels:

protocol bgp incoming_r2ge {
    ...

    ipv6 {
      import filter genauso;
      export none;
    };

    ipv4 {
      import filter genauso;
      export none;
      extended next hop on;
    };
}


Instead of writing a wrapper function for each peer/constellation, it
would be great if we could do something like that:

define net_genauso = [
       2a0a:5480::/29+,
       185.203.113.0/24,
       185.116.114.0/24
       ];

...
filter genauso {
  if(net ~ net_genauso) then accept;
  reject;
}
...

However as of bird 2.14, this results in the following error:

bridge:~nico# bird -f -c ./bird.conf
bird: ./bird.conf:208:23 Mixed IPv4/IPv6 prefixes in prefix set.

So my question is, how do you usually match on the two families? Do you
also write a wrapper function like above? Or do you have a smarter way?

BR,

Nico

--
Sustainable and modern Infrastructures by ungleich.ch


More information about the Bird-users mailing list