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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231215193024.02819d85@hermes.local>
Date: Fri, 15 Dec 2023 19:30:24 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: Graeme Smecher <gsmecher@...eespeedlogic.com>
Cc: David Ahern <dsahern@...nel.org>, "David S. Miller"
 <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski
 <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
 claudiu.beznea@...on.dev, nicolas.ferre@...rochip.com, mdf@...nel.org
Subject: Re: [PATCH] RFC: net: ipconfig: temporarily bring interface down
 when changing MTU.

On Fri, 15 Dec 2023 17:04:31 -0800
Graeme Smecher <gsmecher@...eespeedlogic.com> wrote:

> Several network drivers (sh_eth, macb_main, nixge, sundance) only allow
> the MTU to be changed when the interface is down, because their buffer
> allocations are performed during ndo_open() and calculated using a
> specific MTU.
> 
> Kick-tested using QEMU (rtl8139, e1000).
> 
> Tested-by: Graeme Smecher <gsmecher@...eespeedlogic.com>
> ---
>  net/ipv4/ipconfig.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
> index c56b6fe6f0d7..69c2a41393a0 100644
> --- a/net/ipv4/ipconfig.c
> +++ b/net/ipv4/ipconfig.c
> @@ -396,9 +396,21 @@ static int __init ic_setup_if(void)
>  	 */
>  	if (ic_dev_mtu != 0) {
>  		rtnl_lock();
> -		if ((err = dev_set_mtu(ic_dev->dev, ic_dev_mtu)) < 0)
> -			pr_err("IP-Config: Unable to set interface mtu to %d (%d)\n",
> -			       ic_dev_mtu, err);
> +		/* Some Ethernet adapters only allow MTU to change when down. */
Check if interface was already down first.

> +		if((err = dev_change_flags(ic_dev->dev, ic_dev->dev->flags | IFF_UP, NULL)))

Please do not combine function call with err test. Surprised checkpatch doesn't complain about hat.

> +			pr_err("IP-Config: About to set MTU, but failed to "
> +				 "bring interface %s down! (%d)\n",

Don't break lines in error messages.
> +				 ic_dev->dev->name, err);
> +		else {
> +			if ((err = dev_set_mtu(ic_dev->dev, ic_dev_mtu)) < 0)
> +				pr_err("IP-Config: Unable to set interface mtu to %d (%d)\n",
> +				       ic_dev_mtu, err);
> +
> +			if((err = dev_change_flags(ic_dev->dev, ic_dev->dev->flags | IFF_UP, NULL)))
> +				pr_err("IP-Config: Trying to set MTU, but unable "
> +					 "to bring interface %s back up! (%d)\n",
> +					 ic_dev->dev->name, err);
> +		}
>  		rtnl_unlock();
>  	}
>  	return 0;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ