Skip to content

Commit 3aa643b

Browse files
Iulian Barbuioanachirca
authored andcommitted
[net] fix rx queue freeze
Under heavy ingress traffic we might end up in a situation where the tap device is full, but the rx.deferred_frame flag is not set. Beeing in this state the firecracker RX queue becomes effectively blocked. The tap won't issue any new event because of the EPOLLET flag, while any rate limiter or RX queue event won't do any processing because the rx.deferred_frame flag is not set. We need to make sure we set the rx.deferred_frame flag on all the paths that leave unprocessed frames in the tap. Signed-off-by: Serban Iorga <[email protected]> Signed-off-by: Iulian Barbu <[email protected]>
1 parent 49d3b33 commit 3aa643b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/devices/src/virtio/net.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,11 @@ impl EpollHandler for NetEpollHandler {
534534
RX_TAP_EVENT => {
535535
METRICS.net.rx_tap_event_count.inc();
536536

537-
if self.rx.queue.is_empty(&self.mem) {
537+
// While there are no available RX queue buffers and there's a deferred_frame
538+
// don't process any more incoming. Otherwise start processing a frame. In the
539+
// process the deferred_frame flag will be set in order to avoid freezing the
540+
// RX queue.
541+
if self.rx.queue.is_empty(&self.mem) && self.rx.deferred_frame {
538542
return Err(DeviceError::NoAvailBuffers);
539543
}
540544

@@ -1461,7 +1465,8 @@ mod tests {
14611465
let mem = GuestMemory::new(&[(GuestAddress(0), 0x10000)]).unwrap();
14621466
let (mut h, _txq, rxq) = default_test_netepollhandler(&mem, test_mutators);
14631467

1464-
// The RX queue is empty.
1468+
// The RX queue is empty and rx.deferred_frame flag is set.
1469+
h.rx.deferred_frame = true;
14651470
match h.handle_event(RX_TAP_EVENT, epoll::Events::EPOLLIN) {
14661471
Err(DeviceError::NoAvailBuffers) => (),
14671472
_ => panic!("invalid"),

0 commit comments

Comments
 (0)