[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1497785298-13468-11-git-send-email-netanel@amazon.com>
Date: Sun, 18 Jun 2017 14:28:15 +0300
From: <netanel@...zon.com>
To: <davem@...emloft.net>, <netdev@...r.kernel.org>
CC: Netanel Belgazal <netanel@...zon.com>, <dwmw@...zon.com>,
<zorik@...zon.com>, <matua@...zon.com>, <saeedb@...zon.com>,
<msw@...zon.com>, <aliguori@...zon.com>, <nafea@...zon.com>,
<evgenys@...zon.com>
Subject: [PATCH net-next 10/13] net: ena: add mtu limitation in ena_change_mtu()
From: Netanel Belgazal <netanel@...zon.com>
Signed-off-by: Netanel Belgazal <netanel@...zon.com>
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 7dee448157bb..7f31f4ce7b8e 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -108,6 +108,13 @@ static int ena_change_mtu(struct net_device *dev, int new_mtu)
struct ena_adapter *adapter = netdev_priv(dev);
int ret;
+ if ((new_mtu > adapter->max_mtu) || (new_mtu < ENA_MIN_MTU)) {
+ netif_err(adapter, drv, dev,
+ "Invalid MTU setting. new_mtu: %d max mtu: %d min mtu: %d\n",
+ new_mtu, adapter->max_mtu, ENA_MIN_MTU);
+ return -EINVAL;
+ }
+
ret = ena_com_set_dev_mtu(adapter->ena_dev, new_mtu);
if (!ret) {
netif_dbg(adapter, drv, dev, "set MTU to %d\n", new_mtu);
@@ -3008,8 +3015,6 @@ static void ena_set_conf_feat_params(struct ena_adapter *adapter,
ena_set_dev_offloads(feat, netdev);
adapter->max_mtu = feat->dev_attr.max_mtu;
- netdev->max_mtu = adapter->max_mtu;
- netdev->min_mtu = ENA_MIN_MTU;
}
static int ena_rss_init_default(struct ena_adapter *adapter)
--
2.7.4
Powered by blists - more mailing lists