Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snapshot: Remove max_connections and max_pending_resets fields #4913

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to

### Changed

- [#4913](https://github.com/firecracker-microvm/firecracker/pull/4913): Removed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not opposing the change, but what are customers supposed to do in response to this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, they need to regenerate a snapshot. We might want to apply the same fix for the previous change.

unnecessary fields (`max_connections` and `max_pending_resets`) from the
snapshot format, bumping the snapshot version to 5.0.0.

### Deprecated

### Removed
Expand Down
45 changes: 9 additions & 36 deletions src/vmm/src/mmds/ns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ impl MmdsNetworkStack {
mac_addr: MacAddr,
ipv4_addr: Ipv4Addr,
tcp_port: u16,
max_connections: NonZeroUsize,
max_pending_resets: NonZeroUsize,
mmds: Arc<Mutex<Mmds>>,
) -> Self {
MmdsNetworkStack {
Expand All @@ -93,8 +91,8 @@ impl MmdsNetworkStack {
tcp_handler: TcpIPv4Handler::new(
ipv4_addr,
tcp_port,
max_connections,
max_pending_resets,
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
),
mmds,
}
Expand All @@ -105,14 +103,7 @@ impl MmdsNetworkStack {
let ipv4_addr = mmds_ipv4_addr.unwrap_or_else(|| Ipv4Addr::from(DEFAULT_IPV4_ADDR));

// The unwrap()s are safe because the given literals are greater than 0.
Self::new(
mac_addr,
ipv4_addr,
DEFAULT_TCP_PORT,
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
mmds,
)
Self::new(mac_addr, ipv4_addr, DEFAULT_TCP_PORT, mmds)
}

pub fn set_ipv4_addr(&mut self, ipv4_addr: Ipv4Addr) {
Expand Down Expand Up @@ -562,14 +553,8 @@ mod tests {
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
let mut ns = MmdsNetworkStack::new(
mac,
ip,
DEFAULT_TCP_PORT,
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
Arc::new(Mutex::new(Mmds::default())),
);
let mut ns =
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));

let mut eth =
EthernetFrame::write_incomplete(buf.as_mut(), mac, mac, ETHERTYPE_ARP).unwrap();
Expand All @@ -589,14 +574,8 @@ mod tests {
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
let ns = MmdsNetworkStack::new(
mac,
ip,
DEFAULT_TCP_PORT,
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
Arc::new(Mutex::new(Mmds::default())),
);
let ns =
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));

let mut eth =
EthernetFrame::write_incomplete(buf.as_mut(), mac, mac, ETHERTYPE_IPV4).unwrap();
Expand All @@ -615,14 +594,8 @@ mod tests {
let ip = Ipv4Addr::from(DEFAULT_IPV4_ADDR);
let other_ip = Ipv4Addr::new(5, 6, 7, 8);
let mac = MacAddr::from_bytes_unchecked(&[0; 6]);
let mut ns = MmdsNetworkStack::new(
mac,
ip,
DEFAULT_TCP_PORT,
NonZeroUsize::new(DEFAULT_MAX_CONNECTIONS).unwrap(),
NonZeroUsize::new(DEFAULT_MAX_PENDING_RESETS).unwrap(),
Arc::new(Mutex::new(Mmds::default())),
);
let mut ns =
MmdsNetworkStack::new_with_defaults(Some(ip), Arc::new(Mutex::new(Mmds::default())));

// try IPv4 with detour_arp
let mut eth =
Expand Down
15 changes: 0 additions & 15 deletions src/vmm/src/mmds/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! Defines the structures needed for saving/restoring MmdsNetworkStack.

use std::net::Ipv4Addr;
use std::num::NonZeroUsize;
use std::sync::{Arc, Mutex};

use serde::{Deserialize, Serialize};
Expand All @@ -20,8 +19,6 @@ pub struct MmdsNetworkStackState {
mac_addr: [u8; MAC_ADDR_LEN as usize],
ipv4_addr: u32,
tcp_port: u16,
max_connections: NonZeroUsize,
max_pending_resets: NonZeroUsize,
}

impl Persist<'_> for MmdsNetworkStack {
Expand All @@ -37,8 +34,6 @@ impl Persist<'_> for MmdsNetworkStack {
mac_addr,
ipv4_addr: self.ipv4_addr.into(),
tcp_port: self.tcp_handler.local_port(),
max_connections: self.tcp_handler.max_connections(),
max_pending_resets: self.tcp_handler.max_pending_resets(),
}
}

Expand All @@ -50,8 +45,6 @@ impl Persist<'_> for MmdsNetworkStack {
MacAddr::from_bytes_unchecked(&state.mac_addr),
Ipv4Addr::from(state.ipv4_addr),
state.tcp_port,
state.max_connections,
state.max_pending_resets,
mmds,
))
}
Expand Down Expand Up @@ -83,13 +76,5 @@ mod tests {
restored_ns.tcp_handler.local_port(),
ns.tcp_handler.local_port()
);
assert_eq!(
restored_ns.tcp_handler.max_connections(),
ns.tcp_handler.max_connections()
);
assert_eq!(
restored_ns.tcp_handler.max_pending_resets(),
ns.tcp_handler.max_pending_resets()
);
}
}
2 changes: 1 addition & 1 deletion src/vmm/src/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub enum CreateSnapshotError {
}

/// Snapshot version
pub const SNAPSHOT_VERSION: Version = Version::new(4, 0, 0);
pub const SNAPSHOT_VERSION: Version = Version::new(5, 0, 0);

/// Creates a Microvm snapshot.
pub fn create_snapshot(
Expand Down
Loading