generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 53
feat: add support for MTU in Netdog #686
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
Open
mikn
wants to merge
1
commit into
bottlerocket-os:develop
Choose a base branch
from
molnett:mk/netdog_add_mtu
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /// The mtu_tests macro contains MTU-related net config tests. It accepts a version number, | ||
| /// and creates a module for that version containing all applicable MTU tests. | ||
| macro_rules! mtu_tests { | ||
| ($version:expr) => { | ||
| mod mtu { | ||
| use $crate::net_config::deserialize_config; | ||
| use $crate::net_config::test_macros::gen_boilerplate; | ||
|
|
||
| gen_boilerplate!($version, "mtu"); | ||
|
|
||
| // Only test MTU for version 3 and later | ||
| #[test] | ||
| fn mtu_configuration() { | ||
| if VERSION < 3 { | ||
| // MTU is only supported in version 3 and later | ||
| return; | ||
| } | ||
|
|
||
| let config_str = render_config_template(net_config().join("net_config.toml")); | ||
| let net_config = deserialize_config(&config_str); | ||
| assert!(net_config.is_ok(), "Failed to deserialize config: {:?}", net_config.err()); | ||
|
|
||
| let net_config = net_config.unwrap(); | ||
|
|
||
| // Check that the config has interfaces | ||
| assert!(net_config.has_interfaces()); | ||
|
|
||
| // Convert to networkd config to ensure MTU values are passed through | ||
| let networkd_config = net_config.as_networkd_config(); | ||
| assert!(networkd_config.is_ok(), "Failed to create networkd config: {:?}", networkd_config.err()); | ||
|
|
||
| // The test passes if we can successfully deserialize and create networkd config | ||
| // with MTU values. The actual MTU values will be written to the .network files | ||
| // when the networkd config is written to disk. | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| pub(crate) use mtu_tests; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,7 @@ pub(crate) struct NetworkDVlan { | |||||||||
| // entry for this VLAN | ||||||||||
| pub(crate) device: InterfaceName, | ||||||||||
| pub(crate) id: VlanId, | ||||||||||
| pub(crate) mtu: Option<u32>, | ||||||||||
| } | ||||||||||
|
|
||||||||||
| impl NetDevFileCreator for NetworkDVlan { | ||||||||||
|
|
@@ -40,6 +41,7 @@ impl NetDevFileCreator for NetworkDVlan { | |||||||||
| routes: _, | ||||||||||
| device: _, // Device isn't used in .netdev files | ||||||||||
| id, | ||||||||||
| mtu: _, // MTU is configured in .network files, not .netdev | ||||||||||
| } = self; | ||||||||||
|
|
||||||||||
| let mut netdev = NetDevBuilder::new_vlan(name.clone()); | ||||||||||
|
|
@@ -63,13 +65,17 @@ impl NetworkFileCreator for NetworkDVlan { | |||||||||
| routes, | ||||||||||
| device: _, // device and id aren't used in .network files | ||||||||||
| id: _, | ||||||||||
| mtu, | ||||||||||
| } = self; | ||||||||||
|
|
||||||||||
| let mut network = NetworkBuilder::new_vlan(name.clone()); | ||||||||||
| network.with_dhcp(dhcp4.clone(), dhcp6.clone()); | ||||||||||
| maybe_add_some!(network, with_static_config, static4); | ||||||||||
| maybe_add_some!(network, with_static_config, static6); | ||||||||||
| maybe_add_some!(network, with_routes, routes); | ||||||||||
| if let Some(m) = mtu { | ||||||||||
| network.with_mtu(*m); | ||||||||||
| } | ||||||||||
|
Comment on lines
+76
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same suggestion for the other occurrences of this pattern:
Suggested change
|
||||||||||
|
|
||||||||||
| vec![network.build()] | ||||||||||
| } | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,7 @@ impl NetworkDConfig { | |
| static4: None, | ||
| static6: None, | ||
| routes: None, | ||
| mtu: None, | ||
| })) | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| version = {{version}} | ||
|
|
||
| # Interface with jumbo frames | ||
| [eno1] | ||
| dhcp4 = true | ||
| mtu = 9000 | ||
| primary = true | ||
|
|
||
| # Interface with standard MTU | ||
| [eno2] | ||
| dhcp6 = true | ||
| mtu = 1500 | ||
|
|
||
| # Bond with custom MTU | ||
| [bond0] | ||
| kind = "bond" | ||
| mode = "active-backup" | ||
| mtu = 1500 | ||
| interfaces = ["eth0", "eth1"] | ||
| dhcp4 = true | ||
|
|
||
| [bond0.monitoring] | ||
| miimon-frequency-ms = 100 | ||
| miimon-updelay-ms = 200 | ||
| miimon-downdelay-ms = 200 | ||
|
|
||
| # VLAN with custom MTU | ||
| [vlan100] | ||
| kind = "vlan" | ||
| device = "eno1" | ||
| id = 100 | ||
| mtu = 1500 | ||
| dhcp4 = true | ||
|
|
||
| # Interface without MTU specified (will use default) | ||
| [eno3] | ||
| dhcp4 = true | ||
| dhcp6 = true |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to increment the schema version for the MTU-related changes: