From 57842858948385a5dc5fe48fd9d3739bfe0a88ff Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 22 Apr 2021 14:18:57 +0100 Subject: [PATCH] net_util: queue_pair: Handle tap write returning EAGAIN/EWOULDBLOCK If the tap file descriptor is not writable then try again later. Update the RX side to match the test on std::io::ErrorKind::WouldBlock Fixes: #2517 Signed-off-by: Rob Bradford --- net_util/src/queue_pair.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/net_util/src/queue_pair.rs b/net_util/src/queue_pair.rs index eb93637ef..7b73d402d 100644 --- a/net_util/src/queue_pair.rs +++ b/net_util/src/queue_pair.rs @@ -92,8 +92,14 @@ impl TxVirtio { }; if result < 0 { let e = std::io::Error::last_os_error(); - error!("net: tx: failed writing to tap: {}", e); queue.go_to_previous_position(); + + /* EAGAIN */ + if e.kind() == std::io::ErrorKind::WouldBlock { + warn!("net: tx: (recoverable) failed writing to tap: {}", e); + break; + } + error!("net: tx: failed writing to tap: {}", e); return Err(NetQueuePairError::WriteTap(e)); } @@ -179,10 +185,9 @@ impl RxVirtio { exhausted_descs = false; queue.go_to_previous_position(); - if let Some(raw_err) = e.raw_os_error() { - if raw_err == libc::EAGAIN { - break; - } + /* EAGAIN */ + if e.kind() == std::io::ErrorKind::WouldBlock { + break; } error!("net: rx: failed reading from tap: {}", e);