<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Hi Robin,</p>
<p>Apologies for the delayed response<br>
</p>
<div class="moz-cite-prefix">On 19/03/2024 20:38, Robin Jarry wrote:<br>
</div>
<blockquote type="cite" cite="mid:CZY0LHKYV4ZO.YRBZ6C6GW6AI@redhat.com">Hi Vladimir,
<br>
<br>
Medvedkin, Vladimir, Mar 19, 2024 at 18:16:
<br>
<blockquote type="cite">> 2) Is it OK/safe to modify a fib from
a control thread (read/write) > while it is used by data
path threads (read only)?
<br>
<br>
This part is a bit more complicated. In practice, I would say
yes, however, there is a possibility that if the lookup thread
is preempted in the middle of the lookup process, and at the
same time the control thread deletes the corresponding route,
then the lookup result may return outdated data. This problem is
solved in LPM with RCU enabled. I have plans to implement it in
the near future in the FIB.
<br>
</blockquote>
<br>
OK that's good to know, thanks.
<br>
<br>
<blockquote type="cite">> 3) There is no public API to
list/walk all configured routes in > a fib. Would that be
possible/easy to implement?
<br>
<br>
Yes, it already there. FIB under the hood uses rte_rib to hold
existing routes. So walking through can be implemented like:
<br>
</blockquote>
<br>
I had tried it and got confusing results out of this. This must
have been before I had realized that all addresses needed to be in
host order...
<br>
<br>
I tried again and it works as advertised with a small missing
detail: after configuring a default route, e.g.:
<br>
<br>
rte_fib_add(fib, RTE_IPV4(2, 2, 0, 0), 16, RTE_IPV4(1, 2, 3,
4));
<br>
rte_fib_add(fib, RTE_IPV4(3, 3, 3, 0), 24, RTE_IPV4(4, 3, 2,
1));
<br>
rte_fib_add(fib, RTE_IPV4(0, 0, 0, 0), 0, RTE_IPV4(9, 9, 9,
9));
<br>
<br>
It is not returned by rte_rib_get_nxt() successive calls. I only
see the other two routes:
<br>
<br>
2.2.0.0/16 via 1.2.3.4
<br>
3.3.3.0/24 via 4.3.2.1
<br>
<br>
Is this expected?
<br>
</blockquote>
<p>Yes, it is expected. It is also reflected in API: "Retrieve next
more specific prefix ...". So, in your case you should explicitly
lookup 0/0 route.</p>
<p><span class="EzKURWReUAB5oZgtQNkl" data-src-align="0:1" style="white-space: pre-wrap;">I</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="2:6" style="white-space: pre-wrap;">find</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="9:3" style="white-space: pre-wrap;">this</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="13:5" style="white-space: pre-wrap;">more</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="19:7" style="white-space: pre-wrap;">convenient</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="27:3" style="white-space: pre-wrap;">for</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="50:6" style="white-space: pre-wrap;">data</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="40:9" style="white-space: pre-wrap;">plane</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="31:8" style="white-space: pre-wrap;">structures</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="58:9" style="white-space: pre-wrap;">like</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="68:5" style="white-space: pre-wrap;">DIR24</span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="73:1" style="white-space: pre-wrap;">-</span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="74:1" style="white-space: pre-wrap;">8</span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="75:1" style="white-space: pre-wrap;">,</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="77:3" style="white-space: pre-wrap;">where</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="81:3" style="white-space: pre-wrap;">I</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="85:5" style="white-space: pre-wrap;">need</span><span style="white-space: pre-wrap;"> to </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="91:5" style="white-space: pre-wrap;">find</span><span style="white-space: pre-wrap;"> gaps </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="105:3" style="white-space: pre-wrap;">for</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="109:10" style="white-space: pre-wrap;">some</span><span style="white-space: pre-wrap;"> </span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="120:9" style="white-space: pre-wrap;">given</span><span style="white-space: pre-wrap;"> super</span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="130:13" style="white-space: pre-wrap;">prefix</span><span class="EzKURWReUAB5oZgtQNkl" data-src-align="143:1" style="white-space: pre-wrap;">.</span></p>
<blockquote type="cite" cite="mid:CZY0LHKYV4ZO.YRBZ6C6GW6AI@redhat.com">
<br>
<blockquote type="cite">> 4) In rte_fib, every IPv4 address
(route *and* next hop) needs to be > in host order. This
is not consistent with fib6 where addresses > are stored
in network order. It took me quite a while to figure > out
what was wrong with my code. <br>
This API behavior was created in such a way that it is the same
as LPM.
<br>
<br>
As for LPM, I think it was done this way for performance reasons
because in some scenarios you only working with the host order
ipv4 addresses.
<br>
</blockquote>
<br>
This should really be advertised in strong capital letters in the
API docs. Or (preferably) hidden to the user. I don't see any
valid scenario where you would work with host order IPv4
addresses.
<br>
</blockquote>
I just implemented lookup the same way as LPM. As for valid
scenario, years ago I used an LPM/FIB lookup on a huge text log
file(it was nginx logs if I remember correctly) with hundreds of
million lines with IP addresses to resolve corresponding AS numbers
for some statistics. The macro I used converted substrings with IPv4
into unsigned integers in host byte order. So, it is not always true
that IPv4 are in network byte order.<br>
<blockquote type="cite" cite="mid:CZY0LHKYV4ZO.YRBZ6C6GW6AI@redhat.com">
<br>
Do you think we could change that API or at least add a flag at
FIB/RIB creation to make it transparent to the user and consistent
between IPv4 and IPv6?
<br>
</blockquote>
<p>Yes, I will add FIB configuration option to allow BE IPv4 as an
input for lookup function.</p>
<blockquote type="cite" cite="mid:CZY0LHKYV4ZO.YRBZ6C6GW6AI@redhat.com">
<br>
Thanks!
<br>
<br>
</blockquote>
<pre class="moz-signature" cols="72">--
Regards,
Vladimir</pre>
</body>
</html>