Browse Source

[ethernet] Use standard 1500 byte MTU unless explicitly overridden

Devices that support jumbo frames will currently default to the
largest possible MTU.  This assumption is valid for virtual adapters
such as virtio-net, where the MTU must have been configured by a
system administrator, but is unsafe in the general case of a physical
adapter.

Default to the standard Ethernet MTU, unless explicitly overridden
either by the driver or via the ${netX/mtu} setting.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 6 years ago
parent
commit
b9d68b9de0
3 changed files with 3 additions and 0 deletions
  1. 1
    0
      src/drivers/net/ena.c
  2. 1
    0
      src/drivers/net/virtio-net.c
  3. 1
    0
      src/net/ethernet.c

+ 1
- 0
src/drivers/net/ena.c View File

565
 	feature = &rsp->get_feature.feature;
565
 	feature = &rsp->get_feature.feature;
566
 	memcpy ( netdev->hw_addr, feature->device.mac, ETH_ALEN );
566
 	memcpy ( netdev->hw_addr, feature->device.mac, ETH_ALEN );
567
 	netdev->max_pkt_len = le32_to_cpu ( feature->device.mtu );
567
 	netdev->max_pkt_len = le32_to_cpu ( feature->device.mtu );
568
+	netdev->mtu = ( netdev->max_pkt_len - ETH_HLEN );
568
 
569
 
569
 	DBGC ( ena, "ENA %p MAC %s MTU %zd\n",
570
 	DBGC ( ena, "ENA %p MAC %s MTU %zd\n",
570
 	       ena, eth_ntoa ( netdev->hw_addr ), netdev->max_pkt_len );
571
 	       ena, eth_ntoa ( netdev->hw_addr ), netdev->max_pkt_len );

+ 1
- 0
src/drivers/net/virtio-net.c View File

493
 			 &mtu, sizeof ( mtu ) );
493
 			 &mtu, sizeof ( mtu ) );
494
 		DBGC ( virtnet, "VIRTIO-NET %p mtu=%d\n", virtnet, mtu );
494
 		DBGC ( virtnet, "VIRTIO-NET %p mtu=%d\n", virtnet, mtu );
495
 		netdev->max_pkt_len = ( mtu + ETH_HLEN );
495
 		netdev->max_pkt_len = ( mtu + ETH_HLEN );
496
+		netdev->mtu = mtu;
496
 	}
497
 	}
497
 
498
 
498
 	/* Register network device */
499
 	/* Register network device */

+ 1
- 0
src/net/ethernet.c View File

269
 		netdev->ll_protocol = &ethernet_protocol;
269
 		netdev->ll_protocol = &ethernet_protocol;
270
 		netdev->ll_broadcast = eth_broadcast;
270
 		netdev->ll_broadcast = eth_broadcast;
271
 		netdev->max_pkt_len = ETH_FRAME_LEN;
271
 		netdev->max_pkt_len = ETH_FRAME_LEN;
272
+		netdev->mtu = ETH_MAX_MTU;
272
 	}
273
 	}
273
 	return netdev;
274
 	return netdev;
274
 }
275
 }

Loading…
Cancel
Save