net_util: queue_pair: Handle TX short tap write gracefully

When writev returns fewer bytes than vnet_hdr_len the packet is
truncated. Log the error and drop it instead of returning a fatal
InvalidVirtioNetHeader error that would crash the worker thread.

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

View File

@@ -127,7 +127,8 @@ impl TxVirtio {
return Err(NetQueuePairError::WriteTap(e));
}
} else if (result as usize) < vnet_hdr_len() {
return Err(NetQueuePairError::InvalidVirtioNetHeader);
error!("net: tx: short tap write ({result} < {})", vnet_hdr_len());
0
} else {
self.counter_bytes += Wrapping(result as u64 - vnet_hdr_len() as u64);
self.counter_frames += Wrapping(1);