net_util: queue_pair: Handle TX writev EINVAL gracefully

When writev to the TAP returns EINVAL the guest submitted a
malformed packet. Drop it and continue instead of killing the
worker thread.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-05-05 14:42:49 +02:00
committed by Rob Bradford
parent 3402bc0762
commit 17fefa1e45

View File

@@ -118,18 +118,22 @@ impl TxVirtio {
retry_write = true;
break;
}
error!("net: tx: failed writing to tap: {e}");
return Err(NetQueuePairError::WriteTap(e));
}
if (result as usize) < vnet_hdr_len() {
if e.raw_os_error() == Some(libc::EINVAL) {
error!("net: tx: dropping malformed packet: {e}");
0
} else {
error!("net: tx: failed writing to tap: {e}");
return Err(NetQueuePairError::WriteTap(e));
}
} else if (result as usize) < vnet_hdr_len() {
return Err(NetQueuePairError::InvalidVirtioNetHeader);
} else {
self.counter_bytes += Wrapping(result as u64 - vnet_hdr_len() as u64);
self.counter_frames += Wrapping(1);
result as u64
}
self.counter_bytes += Wrapping(result as u64 - vnet_hdr_len() as u64);
self.counter_frames += Wrapping(1);
result as u64
};
// For the sake of simplicity (similar to the RX rate limiting), we always