瀏覽代碼

[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 年之前
父節點
當前提交
b9d68b9de0
共有 3 個檔案被更改,包括 3 行新增0 行删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存