Skip to content

Commit ab90386

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 <[email protected]> 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. Signed-off-by: Nikita Kalyazin <[email protected]>
1 parent f0dd238 commit ab90386

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ and this project adheres to
3030
- [#4790](https://github.com/firecracker-microvm/firecracker/pull/4790): v1.9.0
3131
was missing most of the debugging information in the debuginfo file, due to a
3232
change in the Cargo defaults. This has been corrected.
33+
- [#xxxx](https://github.com/firecracker-microvm/firecracker/pull/xxxx): Add
34+
missing configuration of tap offload features when restoring from a snapshot.
35+
Setting the features was previously
36+
[moved](https://github.com/firecracker-microvm/firecracker/pull/4680/commits/49ed5ea4b48ccd98903da037368fa3108f58ac1f)
37+
from net device creation to device activation time, but it was not reflected
38+
in the restore path. This was leading to inability to connect to the restored
39+
VM if the offload features were used.
3340

3441
## \[1.9.0\]
3542

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

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

666666
/// Builds the offload features we will setup on the TAP device based on the features that the
667667
/// guest supports.
668-
fn build_tap_offload_features(guest_supported_features: u64) -> u32 {
668+
pub fn build_tap_offload_features(guest_supported_features: u64) -> u32 {
669669
let add_if_supported =
670670
|tap_features: &mut u32, supported_features: u64, tap_flag: u32, virtio_flag: u32| {
671671
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
@@ -10,7 +10,7 @@ use std::sync::{Arc, Mutex};
1010
use serde::{Deserialize, Serialize};
1111

1212
use super::device::Net;
13-
use super::NET_NUM_QUEUES;
13+
use super::{TapError, NET_NUM_QUEUES};
1414
use crate::devices::virtio::device::DeviceState;
1515
use crate::devices::virtio::persist::{PersistError as VirtioStateError, VirtioDeviceState};
1616
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)