@@ -783,7 +783,15 @@ impl InterfaceInner {
783
783
784
784
#[ allow( unused) ] // unused depending on which sockets are enabled
785
785
pub ( crate ) fn ip_mtu ( & self ) -> usize {
786
- self . caps . ip_mtu ( )
786
+ match self . caps . medium {
787
+ #[ cfg( feature = "medium-ethernet" ) ]
788
+ Medium :: Ethernet => self . caps . max_transmission_unit - 14 ,
789
+ #[ cfg( feature = "medium-ip" ) ]
790
+ Medium :: Ip => self . caps . max_transmission_unit ,
791
+ #[ cfg( feature = "medium-ieee802154" ) ]
792
+ Medium :: Ieee802154 => self . caps . max_transmission_unit , // TODO(thvdveld): what is the MTU for Medium::IEEE802
793
+ _ => unimplemented ! ( ) ,
794
+ }
787
795
}
788
796
789
797
#[ allow( unused) ] // unused depending on which sockets are enabled, and in tests
@@ -1210,7 +1218,7 @@ impl InterfaceInner {
1210
1218
#[ cfg( feature = "proto-ipv4" ) ]
1211
1219
IpRepr :: Ipv4 ( repr) => {
1212
1220
// If we have an IPv4 packet, then we need to check if we need to fragment it.
1213
- if total_ip_len > self . caps . ip_mtu ( ) {
1221
+ if total_ip_len > self . ip_mtu ( ) {
1214
1222
#[ cfg( feature = "proto-ipv4-fragmentation" ) ]
1215
1223
{
1216
1224
net_debug ! ( "start fragmentation" ) ;
@@ -1219,7 +1227,7 @@ impl InterfaceInner {
1219
1227
let tx_len = self . caps . max_transmission_unit ;
1220
1228
1221
1229
let ip_header_len = repr. buffer_len ( ) ;
1222
- let first_frag_ip_len = self . caps . ip_mtu ( ) ;
1230
+ let first_frag_ip_len = self . ip_mtu ( ) ;
1223
1231
1224
1232
if frag. buffer . len ( ) < total_ip_len {
1225
1233
net_debug ! (
@@ -1305,7 +1313,7 @@ impl InterfaceInner {
1305
1313
#[ cfg( feature = "proto-ipv6" ) ]
1306
1314
IpRepr :: Ipv6 ( _) => {
1307
1315
// Check if we need to fragment it.
1308
- if total_ip_len > self . caps . ip_mtu ( ) {
1316
+ if total_ip_len > self . ip_mtu ( ) {
1309
1317
net_debug ! ( "IPv6 fragmentation support is unimplemented. Dropping." ) ;
1310
1318
Ok ( ( ) )
1311
1319
} else {
0 commit comments