Skip to content

Commit 53a122b

Browse files
committed
snapshot: Remove max_connections and max_pending_resets fields
`TcpIPv4Handler` for MMDS network stack preallocates several buffers whose sizes are saved into a snapshot as `max_connections` and `max_pending_resets` in `MmdsNetworkStackState`. But they are always the same constant hardcoded values (`DEFAULT_MAX_CONNECTIONS` and `DEFAULT_MAX_PENDING_RESETS`) as of today, which means there is no need to save them into a snapshot. Even if we change the hardcoded sizes across Firecracker versions, that should not be a problem. This is because the snapshot feature does not support migration of network connections and those buffers are initialized with empty on snapshot restoration. When migrating from a microVM with larger buffers to a microVM with smaller ones, some guest workloads might not work due to the lack of the buffer spaces. The issue is not a problem of the snapshot feature and should also occur on a purely booted microVM (not restored from a snapshot). Thus, removes those fields from snapshots. Since this is a breaking change of the snapshot format, bumps the major version of the snapshot format. Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent 32c6ed4 commit 53a122b

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

src/vmm/src/mmds/ns.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ impl MmdsNetworkStack {
8181
mac_addr: MacAddr,
8282
ipv4_addr: Ipv4Addr,
8383
tcp_port: u16,
84-
max_connections: NonZeroUsize,
85-
max_pending_resets: NonZeroUsize,
8684
mmds: Arc<Mutex<Mmds>>,
8785
) -> Self {
8886
MmdsNetworkStack {
@@ -93,8 +91,8 @@ impl MmdsNetworkStack {
9391
tcp_handler: TcpIPv4Handler::new(
9492
ipv4_addr,
9593
tcp_port,
96-
max_connections,
97-
max_pending_resets,
94+
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
95+
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
9896
),
9997
mmds,
10098
}
@@ -105,14 +103,7 @@ impl MmdsNetworkStack {
105103
let ipv4_addr = mmds_ipv4_addr.unwrap_or_else(|| Ipv4Addr::from(DEFAULT_IPV4_ADDR));
106104

107105
// The unwrap()s are safe because the given literals are greater than 0.
108-
Self::new(
109-
mac_addr,
110-
ipv4_addr,
111-
DEFAULT_TCP_PORT,
112-
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
113-
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
114-
mmds,
115-
)
106+
Self::new(mac_addr, ipv4_addr, DEFAULT_TCP_PORT, mmds)
116107
}
117108

118109
pub fn set_ipv4_addr(&mut self, ipv4_addr: Ipv4Addr) {

src/vmm/src/mmds/persist.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//! Defines the structures needed for saving/restoring MmdsNetworkStack.
55
66
use std::net::Ipv4Addr;
7-
use std::num::NonZeroUsize;
87
use std::sync::{Arc, Mutex};
98

109
use serde::{Deserialize, Serialize};
@@ -20,8 +19,6 @@ pub struct MmdsNetworkStackState {
2019
mac_addr: [u8; MAC_ADDR_LEN as usize],
2120
ipv4_addr: u32,
2221
tcp_port: u16,
23-
max_connections: NonZeroUsize,
24-
max_pending_resets: NonZeroUsize,
2522
}
2623

2724
impl Persist<'_> for MmdsNetworkStack {
@@ -37,8 +34,6 @@ impl Persist<'_> for MmdsNetworkStack {
3734
mac_addr,
3835
ipv4_addr: self.ipv4_addr.into(),
3936
tcp_port: self.tcp_handler.local_port(),
40-
max_connections: self.tcp_handler.max_connections(),
41-
max_pending_resets: self.tcp_handler.max_pending_resets(),
4237
}
4338
}
4439

@@ -50,8 +45,6 @@ impl Persist<'_> for MmdsNetworkStack {
5045
MacAddr::from_bytes_unchecked(&state.mac_addr),
5146
Ipv4Addr::from(state.ipv4_addr),
5247
state.tcp_port,
53-
state.max_connections,
54-
state.max_pending_resets,
5548
mmds,
5649
))
5750
}
@@ -83,13 +76,5 @@ mod tests {
8376
restored_ns.tcp_handler.local_port(),
8477
ns.tcp_handler.local_port()
8578
);
86-
assert_eq!(
87-
restored_ns.tcp_handler.max_connections(),
88-
ns.tcp_handler.max_connections()
89-
);
90-
assert_eq!(
91-
restored_ns.tcp_handler.max_pending_resets(),
92-
ns.tcp_handler.max_pending_resets()
93-
);
9479
}
9580
}

src/vmm/src/persist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub enum CreateSnapshotError {
157157
}
158158

159159
/// Snapshot version
160-
pub const SNAPSHOT_VERSION: Version = Version::new(4, 0, 0);
160+
pub const SNAPSHOT_VERSION: Version = Version::new(5, 0, 0);
161161

162162
/// Creates a Microvm snapshot.
163163
pub fn create_snapshot(

0 commit comments

Comments
 (0)