lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 25 Mar 2024 16:27:35 +0100
From: thomas.perrot@...tlin.com
To: Nicolas Ferre <nicolas.ferre@...rochip.com>,
	Claudiu Beznea <claudiu.beznea@...on.dev>,
	"David S . Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Thomas Perrot <thomas.perrot@...tlin.com>
Subject: [PATCH net-next] net: macb: allow MTU change when the interface is up

From: Thomas Perrot <thomas.perrot@...tlin.com>

The macb_change_mtu callback doesn't allow MTU changes when the
interface is up because the MTU is used to set the buffer size on
GEM.

So, to be able to change the MTU from userspace it is necessary to
explicitly down then to up the interface, which is problematic in
some cases.

Then we suggest to reset the interface when the interface is already
up to allow to change the MTU, regardless of if the interface is up
or not.

Signed-off-by: Thomas Perrot <thomas.perrot@...tlin.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 898debfd4db3..5c20b162c5da 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3019,11 +3019,19 @@ static int macb_close(struct net_device *dev)
 
 static int macb_change_mtu(struct net_device *dev, int new_mtu)
 {
-	if (netif_running(dev))
-		return -EBUSY;
+	int reset = 0;
+
+	/* On GEM the buffer size is based on the MTU */
+	if (netif_running(dev)) {
+		macb_close(dev);
+		reset = 1;
+	}
 
 	dev->mtu = new_mtu;
 
+	if (reset)
+		macb_open(dev);
+
 	return 0;
 }
 
-- 
2.44.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ