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,6 +565,7 @@ static int ena_get_device_attributes ( struct net_device *netdev ) {
565 565
 	feature = &rsp->get_feature.feature;
566 566
 	memcpy ( netdev->hw_addr, feature->device.mac, ETH_ALEN );
567 567
 	netdev->max_pkt_len = le32_to_cpu ( feature->device.mtu );
568
+	netdev->mtu = ( netdev->max_pkt_len - ETH_HLEN );
568 569
 
569 570
 	DBGC ( ena, "ENA %p MAC %s MTU %zd\n",
570 571
 	       ena, eth_ntoa ( netdev->hw_addr ), netdev->max_pkt_len );

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

@@ -493,6 +493,7 @@ static int virtnet_probe_legacy ( struct pci_device *pci ) {
493 493
 			 &mtu, sizeof ( mtu ) );
494 494
 		DBGC ( virtnet, "VIRTIO-NET %p mtu=%d\n", virtnet, mtu );
495 495
 		netdev->max_pkt_len = ( mtu + ETH_HLEN );
496
+		netdev->mtu = mtu;
496 497
 	}
497 498
 
498 499
 	/* Register network device */

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

@@ -269,6 +269,7 @@ struct net_device * alloc_etherdev ( size_t priv_size ) {
269 269
 		netdev->ll_protocol = &ethernet_protocol;
270 270
 		netdev->ll_broadcast = eth_broadcast;
271 271
 		netdev->max_pkt_len = ETH_FRAME_LEN;
272
+		netdev->mtu = ETH_MAX_MTU;
272 273
 	}
273 274
 	return netdev;
274 275
 }

Loading…
Cancel
Save