summaryrefslogtreecommitdiff
path: root/drivers/infiniband/ulp
diff options
context:
space:
mode:
authorMuhammad Sammar <muhammads@mellanox.com>2018-08-28 14:45:30 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-11-20 18:46:02 +0100
commita618cca0438ba548cc15eef748560a1fd4174903 (patch)
tree540811bf641174f27d87472ded25ca21cc7ad14c /drivers/infiniband/ulp
parent2543eeba256ae4a7bbfa0c8531e34371bfe306f6 (diff)
downloadlinux-a618cca0438ba548cc15eef748560a1fd4174903.tar.gz
linux-a618cca0438ba548cc15eef748560a1fd4174903.tar.bz2
linux-a618cca0438ba548cc15eef748560a1fd4174903.zip
IB/ipoib: Ensure that MTU isn't less than minimum permitted
[ Upstream commit 142a9c287613560edf5a03c8d142c8b6ebc1995b ] It is illegal to change MTU to a value lower than the minimum MTU stated in ethernet spec. In addition to that we need to add 4 bytes for encapsulation header (IPOIB_ENCAP_LEN). Before "ifconfig ib0 mtu 0" command, succeeds while it obviously shouldn't. Signed-off-by: Muhammad Sammar <muhammads@mellanox.com> Reviewed-by: Feras Daoud <ferasda@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/infiniband/ulp')
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 78dd36daac00..d8cb5bbe6eb5 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -243,7 +243,8 @@ static int ipoib_change_mtu(struct net_device *dev, int new_mtu)
return 0;
}
- if (new_mtu > IPOIB_UD_MTU(priv->max_ib_mtu))
+ if (new_mtu < (ETH_MIN_MTU + IPOIB_ENCAP_LEN) ||
+ new_mtu > IPOIB_UD_MTU(priv->max_ib_mtu))
return -EINVAL;
priv->admin_mtu = new_mtu;