File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
src/vmm/src/devices/virtio/net Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -669,7 +669,7 @@ impl Net {
669
669
670
670
/// Builds the offload features we will setup on the TAP device based on the features that the
671
671
/// 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 {
673
673
let add_if_supported =
674
674
|tap_features : & mut u32 , supported_features : u64 , tap_flag : u32 , virtio_flag : u32 | {
675
675
if supported_features & ( 1 << virtio_flag) != 0 {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
11
11
use utils:: net:: mac:: MacAddr ;
12
12
13
13
use super :: device:: Net ;
14
- use super :: NET_NUM_QUEUES ;
14
+ use super :: { TapError , NET_NUM_QUEUES } ;
15
15
use crate :: devices:: virtio:: device:: DeviceState ;
16
16
use crate :: devices:: virtio:: persist:: { PersistError as VirtioStateError , VirtioDeviceState } ;
17
17
use crate :: devices:: virtio:: queue:: FIRECRACKER_MAX_QUEUE_SIZE ;
@@ -65,6 +65,8 @@ pub enum NetPersistError {
65
65
VirtioState ( #[ from] VirtioStateError ) ,
66
66
/// Indicator that no MMDS is associated with this device.
67
67
NoMmdsDataStore ,
68
+ /// Setting tap interface offload flags failed: {0}
69
+ TapSetOffload ( TapError ) ,
68
70
}
69
71
70
72
impl Persist < ' _ > for Net {
@@ -129,6 +131,11 @@ impl Persist<'_> for Net {
129
131
net. acked_features = state. virtio_state . acked_features ;
130
132
131
133
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
+
132
139
net. device_state = DeviceState :: Activated ( constructor_args. mem ) ;
133
140
}
134
141
You can’t perform that action at this time.
0 commit comments