tap: crash in multi-thread environment 43/19843/2
authorMohsin Kazmi <sykazmi@cisco.com>
Mon, 27 May 2019 13:53:25 +0000 (15:53 +0200)
committerDamjan Marion <dmarion@me.com>
Tue, 28 May 2019 08:14:48 +0000 (08:14 +0000)
commit3f340175aebaf84ed3994799e819e0801c7e3212
tree69c9ea1ac1405bcc0cea004891b449212c28cc99
parent8cd5bd8e34eb72ee5dccc2fb0733db9da03af5c8
tap: crash in multi-thread environment

In tap tx routine, virtio_interface_tx_inline, there used to be an
interface spinlock to ensure packets are processed in an orderly fashion
  clib_spinlock_lock_if_init (&vif->lockp);

When virtio code was introduced in 19.04, that line is changed to
  clib_spinlock_lock_if_init (&vring->lockp);
to accommodate multi-queues.

Unfortunately, althrough the spinlock exists in the vring, it was never
initialized for tap, only for virtio. As a result, many nasty things can
happen when running tap interface in multi-thread environment. Crash is
inevitable.

The fix is to initialize vring->lockp for tap and remove vif->lockp as it
is not used anymore.

Change-Id: I82b15d3e9b0fb6add9b9ac49bf602a538946634a
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
(cherry picked from commit c2c89782d34df0dc7197b18b042b4c2464a101ef)
src/vnet/devices/tap/tap.c
src/vnet/devices/virtio/virtio.c
src/vnet/devices/virtio/virtio.h