Hi,

I'm wondering whether the current practice of reusing sw_if_indexes in
some of tunnel implementations is safe.

What currently happens is that when a tunnel session is released, the
sw_if_index of the corresponding interface is put into vector of
reuse.

My first question is, why a vector? Wouldn't putting it back directly
into the pool lead to the same result?

Further, the vector works as LIFO, meaning the index can be reused immediately.
This, at least in theory, seems to create a race condition. The API or
CLI invocation stops all workers somewhere between graph nodes. That
means it could stop somewhere in the pipeline with a packet that
belongs to the sw interface that is about the be removed. The API call
will remove the interface, but will not clear the packet from the
processing pipeline. Once the workers continue, they will hit the
packet with the now invalid sw interface and might try to dereference
that into an invalid data structure (the pool entry is still valid,
but it will be shutdown at this point and possibly contain other
invalid data).
The interface reuse vector will guarantee that the interface pool
entry is still valid, but with a very fast API invocation or some kind
of batching it could happen that the interface entry is already reused
for a different session. This would lead to undefined results in the
best case or a crash in the worst case.

Is my above analysis correct or do I miss something?

Many thanks
Andreas

-- 
-- 
Dipl.-Inform. Andreas Schultz

----------------------- enabling your networks ----------------------
Travelping GmbH                     Phone:  +49-391-81 90 99 0
Roentgenstr. 13                     Fax:    +49-391-81 90 99 299
39108 Magdeburg                     Email:  i...@travelping.com
GERMANY                             Web:    http://www.travelping.com

Company Registration: Amtsgericht Stendal        Reg No.:   HRB 10578
Geschaeftsfuehrer: Holger Winkelmann          VAT ID No.: DE236673780
---------------------------------------------------------------------
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#13205): https://lists.fd.io/g/vpp-dev/message/13205
Mute This Topic: https://lists.fd.io/mt/31911780/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to