memif: handle unexpected EPOLLOUT for RX queue 81/29581/4
authorSteven Luong <sluong@cisco.com>
Wed, 21 Oct 2020 19:54:29 +0000 (12:54 -0700)
committerDamjan Marion <dmarion@me.com>
Mon, 26 Oct 2020 18:49:29 +0000 (18:49 +0000)
commit104f0df7f4b957b53c4faf843248be25c65ce941
tree49d1bd46de21b3bb073c0a6d5b8f560686dfece4
parent2e6f624f1f82ae0351dd05ad5d930d6876105519
memif: handle unexpected EPOLLOUT for RX queue

Getting an unexpected EPOLLOUT for RX queue and crashing due to missing
callback function on write_function to handle EPOLLOUT.

(gdb) f 5
f 5
    node=<optimized out>, vm=0x7f948bbe4540 <vlib_global_main>) at /vpp/src/vlib/unix/input.c:325
325       errors[n_errors] = f->write_function (f);
(gdb) p *e
p *e
$21 = {events = 4, data = {ptr = 0x23, fd = 35, u32 = 35, u64 = 35}}
(gdb) p file_main.file_pool[e->data.fd]
p file_main.file_pool[e->data.fd]
$22 = {file_descriptor = 37, flags = 1, polling_thread_index = 0, private_data = 65536,
  read_function = 0x7f944a87b140 <memif_int_fd_read_ready>, write_function = 0x0,
  error_function = 0x0, description = 0x7f944be22400 "memif0/1 rx 0 int", read_events = 0,
  write_events = 1, error_events = 0}
(gdb)

File descriptors are recycled. It is likely that the EPOLLOUT is meant
for the previous owner of the same file descriptor number which memif
recycled and memif RX did not expect to receive an EPOLLOUT. For
defensive play, we create a dummy callback function to ignore the
EPOLLOUT instead of crashing.

Type: fix

Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: I535cadbb9b71d3db2995b118c59a12c71f10af09
src/plugins/memif/memif.c