Skip to content

Commit 3186f19

Browse files
Iulian Barbudianpopa
Iulian Barbu
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 a01adb1 commit 3186f19

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
@@ -552,7 +552,11 @@ impl EpollHandler for NetEpollHandler {
552552
RX_TAP_EVENT => {
553553
METRICS.net.rx_tap_event_count.inc();
554554

555-
if self.rx.queue.is_empty(&self.mem) {
555+
// While there are no available RX queue buffers and there's a deferred_frame
556+
// don't process any more incoming. Otherwise start processing a frame. In the
557+
// process the deferred_frame flag will be set in order to avoid freezing the
558+
// RX queue.
559+
if self.rx.queue.is_empty(&self.mem) && self.rx.deferred_frame {
556560
return Err(DeviceError::NoAvailBuffers);
557561
}
558562

@@ -1479,7 +1483,8 @@ mod tests {
14791483
let mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), 0x10000)]).unwrap();
14801484
let (mut h, _txq, rxq) = default_test_netepollhandler(&mem, test_mutators);
14811485

1482-
// The RX queue is empty.
1486+
// The RX queue is empty and rx.deferred_frame flag is set.
1487+
h.rx.deferred_frame = true;
14831488
match h.handle_event(RX_TAP_EVENT, epoll::Events::EPOLLIN) {
14841489
Err(DeviceError::NoAvailBuffers) => (),
14851490
_ => panic!("invalid"),

0 commit comments

Comments
 (0)