Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
mcb30 committed Jul 17, 2018
1 parent 05b9791 commit b9d68b9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/drivers/net/ena.c
Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions src/drivers/net/virtio-net.c
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/net/ethernet.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit b9d68b9

Please sign in to comment.