summaryrefslogtreecommitdiffstats
path: root/src/drivers/net
diff options
context:
space:
mode:
authorMichael Brown2018-07-17 13:01:30 +0200
committerMichael Brown2018-07-17 13:14:43 +0200
commitb9d68b9de02cc474c8a713f1232ce69fefafe18e (patch)
treebb78cdd2596ec08a7d926315519e2c30b3e2b892 /src/drivers/net
parent[rndis] Clean up error handling path in register_rndis() (diff)
downloadipxe-b9d68b9de02cc474c8a713f1232ce69fefafe18e.tar.gz
ipxe-b9d68b9de02cc474c8a713f1232ce69fefafe18e.tar.xz
ipxe-b9d68b9de02cc474c8a713f1232ce69fefafe18e.zip
[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>
Diffstat (limited to 'src/drivers/net')
-rw-r--r--src/drivers/net/ena.c1
-rw-r--r--src/drivers/net/virtio-net.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c
index 8d29979b..0f25c0be 100644
--- a/src/drivers/net/ena.c
+++ b/src/drivers/net/ena.c
@@ -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 );
diff --git a/src/drivers/net/virtio-net.c b/src/drivers/net/virtio-net.c
index fe79a92c..78ec9ac4 100644
--- a/src/drivers/net/virtio-net.c
+++ b/src/drivers/net/virtio-net.c
@@ -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 */