]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ethernet] Use standard 1500 byte MTU unless explicitly overridden
authorMichael Brown <mcb30@ipxe.org>
Tue, 17 Jul 2018 11:01:30 +0000 (12:01 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 17 Jul 2018 11:14:43 +0000 (12:14 +0100)
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>
src/drivers/net/ena.c
src/drivers/net/virtio-net.c
src/net/ethernet.c

index 8d29979bbc078954ea8feb87077aea3d06455b25..0f25c0beb4ea3b2b9ea273101c4b0bd0cad1300e 100644 (file)
@@ -565,6 +565,7 @@ static int ena_get_device_attributes ( struct net_device *netdev ) {
        feature = &rsp->get_feature.feature;
        memcpy ( netdev->hw_addr, feature->device.mac, ETH_ALEN );
        netdev->max_pkt_len = le32_to_cpu ( feature->device.mtu );
+       netdev->mtu = ( netdev->max_pkt_len - ETH_HLEN );
 
        DBGC ( ena, "ENA %p MAC %s MTU %zd\n",
               ena, eth_ntoa ( netdev->hw_addr ), netdev->max_pkt_len );
index fe79a92c4c1b0b916a418eea76a570e4852a6d01..78ec9ac4e0be0431addcfe63ebbf1d8609a07b5d 100644 (file)
@@ -493,6 +493,7 @@ static int virtnet_probe_legacy ( struct pci_device *pci ) {
                         &mtu, sizeof ( mtu ) );
                DBGC ( virtnet, "VIRTIO-NET %p mtu=%d\n", virtnet, mtu );
                netdev->max_pkt_len = ( mtu + ETH_HLEN );
+               netdev->mtu = mtu;
        }
 
        /* Register network device */
index 26fdedea8e1242ef89438633f592eeb313562f8a..707bdf90508927fcd21eb1a82306a3f58f0d08de 100644 (file)
@@ -269,6 +269,7 @@ struct net_device * alloc_etherdev ( size_t priv_size ) {
                netdev->ll_protocol = &ethernet_protocol;
                netdev->ll_broadcast = eth_broadcast;
                netdev->max_pkt_len = ETH_FRAME_LEN;
+               netdev->mtu = ETH_MAX_MTU;
        }
        return netdev;
 }