Skip to content

Commit 30fae4a

Browse files
committed
fix(net): set tap offload features on restore
Set tap offload features on restore. Signed-off-by: Nikita Kalyazin <[email protected]>
1 parent d3b02e0 commit 30fae4a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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)