Skip to content

Commit

Permalink
Merge pull request #611 from thvdveld/mtu-fix
Browse files Browse the repository at this point in the history
fix mtu calculation for raw_socket
  • Loading branch information
Dirbaio committed May 18, 2022
2 parents 1b2458a + b283356 commit 117dc64
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/phy/raw_socket.rs
Expand Up @@ -43,7 +43,7 @@ impl RawSocket {
Ok(RawSocket {
medium,
lower: Rc::new(RefCell::new(lower)),
mtu: mtu,
mtu,
})
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/phy/sys/raw_socket.rs
@@ -1,6 +1,5 @@
use super::*;
use crate::phy::Medium;
use crate::wire::EthernetFrame;
use std::os::unix::io::{AsRawFd, RawFd};
use std::{io, mem};

Expand Down Expand Up @@ -48,11 +47,7 @@ impl RawSocketDesc {
}

pub fn interface_mtu(&mut self) -> io::Result<usize> {
// SIOCGIFMTU returns the IP MTU (typically 1500 bytes.)
// smoltcp counts the entire Ethernet packet in the MTU, so add the Ethernet header size to it.
let ip_mtu =
ifreq_ioctl(self.lower, &mut self.ifreq, imp::SIOCGIFMTU).map(|mtu| mtu as usize)?;
Ok(ip_mtu + EthernetFrame::<&[u8]>::header_len())
ifreq_ioctl(self.lower, &mut self.ifreq, imp::SIOCGIFMTU).map(|mtu| mtu as usize)
}

pub fn bind_interface(&mut self) -> io::Result<()> {
Expand Down

0 comments on commit 117dc64

Please sign in to comment.