diff options
author | Pierre Pfister <ppfister@cisco.com> | 2018-02-07 15:48:21 +0100 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2018-02-07 18:46:28 +0000 |
commit | 8cedff2f462ef9deada9aae223868a216c7aa7f2 (patch) | |
tree | 7b71d2dd615fdacc5e1e002b7b9ef08b29c1f1e7 /src/vnet/devices | |
parent | 815d7d5637fbffd20bf81c74fd59dac8e4fe4d94 (diff) |
af_packet: Fix lock position
In multi-worker cases, af-packet tx was subject to a pretty
serious race condition as the device lock was obtained
after some queue values were read from queue.
Result could go from packet loss to queue inconsistency, leading
to tx being stuck for 'some time'.
The fix is really simple. Finding the problem was not...
Change-Id: Ib18967b7459a8609428a56de934c577cea87b165
Signed-off-by: Pierre Pfister <ppfister@cisco.com>
Diffstat (limited to 'src/vnet/devices')
-rw-r--r-- | src/vnet/devices/af_packet/device.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/vnet/devices/af_packet/device.c b/src/vnet/devices/af_packet/device.c index 2c2489b55ab..0991378f640 100644 --- a/src/vnet/devices/af_packet/device.c +++ b/src/vnet/devices/af_packet/device.c @@ -87,6 +87,7 @@ af_packet_interface_tx (vlib_main_t * vm, vnet_interface_output_runtime_t *rd = (void *) node->runtime_data; af_packet_if_t *apif = pool_elt_at_index (apm->interfaces, rd->dev_instance); + clib_spinlock_lock_if_init (&apif->lockp); int block = 0; u32 block_size = apif->tx_req->tp_block_size; u32 frame_size = apif->tx_req->tp_frame_size; @@ -96,8 +97,6 @@ af_packet_interface_tx (vlib_main_t * vm, struct tpacket2_hdr *tph; u32 frame_not_ready = 0; - clib_spinlock_lock_if_init (&apif->lockp); - while (n_left > 0) { u32 len; |