Using as set a list of routes to advertise

William bird at is.unlawful.id.au
Thu May 11 07:59:37 CEST 2023


On 10/05/2023 19:46, Maria Matejka via Bird-users wrote:
> Hello!

Thanks for replying.

> On 5/10/23 11:13, William wrote:
>> Hi All,
>> I've been digging around trying to find a nice way of doing it but 
>> can't seem to find a valid answer.
>> 
>> Is there a way to use a prefix set to create static routes?
> 
> No, this is not possible and implementing this would be surprisingly
> difficult as the prefix sets are implemented as a compressed trie
> optimized for fast lookup and not enumeration.
> 
> Also imagine this:
> 
>   define my_route_set = [ 2001:db8/32+ ]; # note the plus sign
>   protocol static { ipv6; route my_route_set via 2001:db8::dead:beef; }
> 
> This short code would generate approx. 7.9e28 routes.

Yeah, that could hurt.

> 
> If you could elaborate more precisely what you are trying to achieve
> as a whole result, we may try to help you find how to do it in the way
> BIRD is designed.

We have a number of remote sites where there are non-dynamically routed 
downstream subnets that we need to add as static routes (anything from 1 
to 20+ per site) but also advertise upstream back into the WAN.

Instead of specifying each prefix as an individual static route I was 
hoping to be able to use the existing prefix set to act as a list of 
routes to add.  If there was a way to iterate over the set in a loop 
fashion then that would suffice.  In our instance there aren't modifiers 
on the masks (no -'s, +'s or {minlen, maxlen}) hence the idea of being 
able to use the set as "just a list" - this could be a condition of 
using it for that function.

For example (twist on my original):

define my_route_set = [ 10.1.2.3/24, 172.20.4.2/24, 10.200.0.0/23 ];

protocol static route_set {
   ipv4 {
     table Some_Routes;
   }
   for ThisRoute in my_route_set {
     route ThisRoute via 192.168.55.2;    # downstream static gateway
   }
   route 5.6.7.8/32 via 192.168.55.1;
}

Resulting in:
bird> sh route table Some_Routes
Table Some_Routes:
10.1.2.3/24            unicast [route_set 2023-05-10] * (200)
	via 192.168.55.2 on ens256
10.20.4.2/24           unicast [route_set 2023-05-10] * (200)
	via 192.168.55.2 on ens256
10.200.0.0/23          unicast [route_set 2023-05-10] * (200)
	via 192.168.55.2 on ens256
5.6.7.8/32             unicast [route_set 2023-05-10] * (200)
	via 192.168.55.1 on ens256
192.168.55.0/24        unicast [Local_Ints 2023-05-10] * (240)
	dev ens256
bird>

Hope that explains better what I'm hoping to achieve.  I couldn't see a 
way of doing it with if..then..else or case statements.  The only other 
option would be to have a script scrape the set out of the config and 
prepare an include file *shudder*.

Regards,
William


More information about the Bird-users mailing list