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: <20221206185616.2ksuvlcmgelsfvw5@skbuf>
Date:   Tue, 6 Dec 2022 20:56:16 +0200
From:   Vladimir Oltean <olteanv@...il.com>
To:     Jerry Ray <jerry.ray@...rochip.com>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        "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,
        linux-kernel@...r.kernel.org, linux@...linux.org.uk
Subject: Re: [PATCH net-next v3 1/2] dsa: lan9303: Add port_max_mtu API

On Tue, Dec 06, 2022 at 12:34:59PM -0600, Jerry Ray wrote:
> +/* For non-cpu ports, the max frame size is 1518.
> + * The CPU port supports a max frame size of 1522.
> + * There is a JUMBO flag to make the max size 2048, but this driver
> + * presently does not support using it.
> + */
> +static int lan9303_port_max_mtu(struct dsa_switch *ds, int port)
> +{
> +	struct net_device *p = dsa_port_to_master(dsa_to_port(ds, port));

You can put debugging prints in the code, but please, in the code that
you submit, do remove gratuitous poking in the master net_device.

> +	struct lan9303 *chip = ds->priv;
> +
> +	dev_dbg(chip->dev, "%s(%d) entered. NET max_mtu is %d",
> +		__func__, port, p->max_mtu);
> +
> +	if (dsa_port_is_cpu(dsa_to_port(ds, port)))

The ds->ops->port_max_mtu() function is never called for the CPU port.
You must know this, you put a debugging print right above. If this would
have been called for anything other than user ports, dsa_port_to_master()
would have triggered a NULL pointer dereference (dp->cpu_dp is set to
NULL for CPU ports).

So please remove dead code.

> +		return 1522 - ETH_HLEN - ETH_FCS_LEN;
> +	else
> +		return 1518 - ETH_HLEN - ETH_FCS_LEN;

Please replace "1518 - ETH_HLEN - ETH_FCS_LEN" with "ETH_DATA_LEN".

Which brings me to a more serious question. If you say that the max_mtu
is equal to the default interface MTU (1500), and you provide no means
for the user to change the MTU to a different value, then why write the
patch? What behaves differently with and without it?

> +}
> +
>  static const struct dsa_switch_ops lan9303_switch_ops = {
>  	.get_tag_protocol = lan9303_get_tag_protocol,
>  	.setup = lan9303_setup,
> @@ -1299,6 +1318,7 @@ static const struct dsa_switch_ops lan9303_switch_ops = {
>  	.port_fdb_dump          = lan9303_port_fdb_dump,
>  	.port_mdb_add           = lan9303_port_mdb_add,
>  	.port_mdb_del           = lan9303_port_mdb_del,
> +	.port_max_mtu		= lan9303_port_max_mtu,
>  };

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ