<div dir="ltr">That is almost the same methodology I used in other engines(RPL and XPL).<br>But, after having some issues on performance of control plane, I needed to change a bit...<br>Splitting the IFs of v4 and v6, and then inside that IF testing for the Prefix-list.<br>Doing that recursion on IFs, reduced a bit the impact on CPU of route-filtering job.<br><br><div>I'm curious if Bind has some method to optimize logic and sequence of those combined tests in some how.<br><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Em ter., 23 de jan. de 2024 às 10:44, Luiz Amaral <<a href="mailto:email@luiz.eng.br">email@luiz.eng.br</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Nico,<br>
<br>
I make separate defines per family (like you did) and then in my filters <br>
I just use:<br>
if (net.type = NET_IP4 && ! (net ~ ASxxx_IPV4)) then reject;<br>
if (net.type = NET_IP6 && ! (net ~ ASxxx_IPV6)) then reject;<br>
<br>
Best,<br>
Luiz<br>
<br>
On 23/01/2024 14:13, Nico Schottelius via Bird-users wrote:<br>
> Hello bird users,<br>
><br>
> I am wondering how you handle matching both IPv6 and IPv4 prefixes<br>
> efficiently.<br>
><br>
> We have tons of blocks in our config like these:<br>
><br>
> define net_genauso_v6 = [<br>
> 2a0a:5480::/29+<br>
> ];<br>
><br>
> define net_genauso_v4 = [<br>
> <a href="http://185.203.113.0/24" rel="noreferrer" target="_blank">185.203.113.0/24</a>,<br>
> <a href="http://185.116.114.0/24" rel="noreferrer" target="_blank">185.116.114.0/24</a><br>
> ];<br>
><br>
> And then later we have a function that combines them like this:<br>
><br>
> function is_genauso() -> bool<br>
> {<br>
> if ((net ~ net_genauso_v6) ||<br>
> (net ~ net_genauso_v4)) then {<br>
> return true;<br>
> }<br>
><br>
> return false;<br>
> }<br>
><br>
> And then much later, we have various filters utilising the function, the<br>
> most simple one being:<br>
><br>
> filter genauso {<br>
> if(is_genauso()) then accept;<br>
> reject;<br>
> }<br>
><br>
> Which is then used in both IPv4 & IPv6 channels:<br>
><br>
> protocol bgp incoming_r2ge {<br>
> ...<br>
><br>
> ipv6 {<br>
> import filter genauso;<br>
> export none;<br>
> };<br>
><br>
> ipv4 {<br>
> import filter genauso;<br>
> export none;<br>
> extended next hop on;<br>
> };<br>
> }<br>
><br>
><br>
> Instead of writing a wrapper function for each peer/constellation, it<br>
> would be great if we could do something like that:<br>
><br>
> define net_genauso = [<br>
> 2a0a:5480::/29+,<br>
> <a href="http://185.203.113.0/24" rel="noreferrer" target="_blank">185.203.113.0/24</a>,<br>
> <a href="http://185.116.114.0/24" rel="noreferrer" target="_blank">185.116.114.0/24</a><br>
> ];<br>
><br>
> ...<br>
> filter genauso {<br>
> if(net ~ net_genauso) then accept;<br>
> reject;<br>
> }<br>
> ...<br>
><br>
> However as of bird 2.14, this results in the following error:<br>
><br>
> bridge:~nico# bird -f -c ./bird.conf<br>
> bird: ./bird.conf:208:23 Mixed IPv4/IPv6 prefixes in prefix set.<br>
><br>
> So my question is, how do you usually match on the two families? Do you<br>
> also write a wrapper function like above? Or do you have a smarter way?<br>
><br>
> BR,<br>
><br>
> Nico<br>
><br>
> --<br>
> Sustainable and modern Infrastructures by <a href="http://ungleich.ch" rel="noreferrer" target="_blank">ungleich.ch</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Douglas Fernando Fischer<br>Engº de Controle e Automação<br><div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;color:black;text-align:left;line-height:130%;font-family:"courier new",monospace"></div></div></div>