Skip to content

Commit 279cf5c

Browse files
committed
fix(net): set tap offload features on restore
Tap offload features configuration was moved from the device creation time to the device activation time by the following commit: commit 1e5d3db Author: Nikita Zakirov <zakironi@amazon.com> Date: Fri Jan 19 15:48:21 2024 +0000 fix(net): Apply only supported TAP offloading features Since device activation code is only called on the boot path, the features were not automatically configured on the restore path. This change configures them on the restore path as well. The change does not include a unit test as we do not have a mockable interface for the tap device. The change does not include an integration test as we have not yet found a way to reproduce the issue using the existing test framework. Signed-off-by: Nikita Kalyazin <kalyazin@amazon.com>
1 parent d3b02e0 commit 279cf5c

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to
77
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## \[Unreleased\]
10+
11+
### Fixed
12+
13+
- [#4824](https://github.com/firecracker-microvm/firecracker/pull/4824): Add
14+
missing configuration of tap offload features when restoring from a snapshot.
15+
Setting the features was previously
16+
[moved](https://github.com/firecracker-microvm/firecracker/pull/4680/commits/49ed5ea4b48ccd98903da037368fa3108f58ac1f)
17+
from net device creation to device activation time, but it was not reflected
18+
in the restore path. This was leading to inability to connect to the restored
19+
VM if the offload features were used.
20+
921
## \[1.9.0\]
1022

1123
### Added

src/vmm/src/devices/virtio/net/device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl Net {
669669

670670
/// Builds the offload features we will setup on the TAP device based on the features that the
671671
/// guest supports.
672-
fn build_tap_offload_features(guest_supported_features: u64) -> u32 {
672+
pub fn build_tap_offload_features(guest_supported_features: u64) -> u32 {
673673
let add_if_supported =
674674
|tap_features: &mut u32, supported_features: u64, tap_flag: u32, virtio_flag: u32| {
675675
if supported_features & (1 << virtio_flag) != 0 {

src/vmm/src/devices/virtio/net/persist.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
1111
use utils::net::mac::MacAddr;
1212

1313
use super::device::Net;
14-
use super::NET_NUM_QUEUES;
14+
use super::{TapError, NET_NUM_QUEUES};
1515
use crate::devices::virtio::device::DeviceState;
1616
use crate::devices::virtio::persist::{PersistError as VirtioStateError, VirtioDeviceState};
1717
use crate::devices::virtio::queue::FIRECRACKER_MAX_QUEUE_SIZE;
@@ -65,6 +65,8 @@ pub enum NetPersistError {
6565
VirtioState(#[from] VirtioStateError),
6666
/// Indicator that no MMDS is associated with this device.
6767
NoMmdsDataStore,
68+
/// Setting tap interface offload flags failed: {0}
69+
TapSetOffload(TapError),
6870
}
6971

7072
impl Persist<'_> for Net {
@@ -129,6 +131,11 @@ impl Persist<'_> for Net {
129131
net.acked_features = state.virtio_state.acked_features;
130132

131133
if state.virtio_state.activated {
134+
let supported_flags: u32 = Net::build_tap_offload_features(net.acked_features);
135+
net.tap
136+
.set_offload(supported_flags)
137+
.map_err(NetPersistError::TapSetOffload)?;
138+
132139
net.device_state = DeviceState::Activated(constructor_args.mem);
133140
}
134141

0 commit comments

Comments
 (0)