Skip to content

Commit

Permalink
add option to set the MTU at compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed Jul 21, 2023
1 parent 0ffa837 commit 5876a29
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/drivers/net/virtio_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use core::cell::RefCell;
use core::cmp::Ordering;
use core::mem;
use core::result::Result;
use core::str::FromStr;

use pci_types::InterruptLine;
use zerocopy::AsBytes;
Expand Down Expand Up @@ -517,7 +518,13 @@ impl NetworkInterface for VirtioNetDriver {
/// Currently, if VIRTIO_NET_F_MAC is not set
// MTU is set static to 1500 bytes.
fn get_mtu(&self) -> u16 {
if self.dev_cfg.features.is_feature(Features::VIRTIO_NET_F_MTU) {
if let Some(my_mtu) = hermit_var!("HERMIT_MTU") {
warn!(
"Using value of the environment variable HERMIT_MTU ({}) as MTU",
my_mtu
);
u16::from_str(&my_mtu).unwrap()
} else if self.dev_cfg.features.is_feature(Features::VIRTIO_NET_F_MTU) {
self.dev_cfg.raw.get_mtu()
} else {
1500
Expand Down

0 comments on commit 5876a29

Please sign in to comment.