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: <CA+h21ho_Q-3eUGNk_zH76nE-+hPu4AW68uu4Kd6XNSWL20izUg@mail.gmail.com>
Date:   Fri, 27 Mar 2020 12:00:01 +0200
From:   Vladimir Oltean <olteanv@...il.com>
To:     Andrew Lunn <andrew@...n.ch>
Cc:     Florian Fainelli <f.fainelli@...il.com>,
        Vivien Didelot <vivien.didelot@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <jakub.kicinski@...ronome.com>,
        murali.policharla@...adcom.com,
        Stephen Hemminger <stephen@...workplumber.org>,
        Jiri Pirko <jiri@...nulli.us>,
        Ido Schimmel <idosch@...sch.org>,
        Jakub Kicinski <kuba@...nel.org>,
        Nikolay Aleksandrov <nikolay@...ulusnetworks.com>,
        netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH v3 net-next 3/8] net: dsa: configure the MTU for switch ports

On Fri, 27 Mar 2020 at 02:06, Andrew Lunn <andrew@...n.ch> wrote:
>
> > -static void dsa_master_set_mtu(struct net_device *dev, struct dsa_port *cpu_dp)
> > -{
> > -     unsigned int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead;
> > -     int err;
> > -
> > -     rtnl_lock();
> > -     if (mtu <= dev->max_mtu) {
> > -             err = dev_set_mtu(dev, mtu);
> > -             if (err)
> > -                     netdev_dbg(dev, "Unable to set MTU to include for DSA overheads\n");
> > -     }
> > -     rtnl_unlock();
> > -}
> > -
> >  static void dsa_master_reset_mtu(struct net_device *dev)
> >  {
> >       int err;
> > @@ -344,7 +330,14 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
> >  {
> >       int ret;
> >
> > -     dsa_master_set_mtu(dev,  cpu_dp);
> > +     rtnl_lock();
> > +     ret = dev_set_mtu(dev, ETH_DATA_LEN + cpu_dp->tag_ops->overhead);
> > +     rtnl_unlock();
> > +     if (ret) {
> > +             netdev_err(dev, "error %d setting MTU to include DSA overhead\n",
> > +                        ret);
> > +             return ret;
> > +     }
>
> I suspect this will break devices. dsa_master_set_mtu() was not fatal
> if it failed. I did this deliberately because i suspect there are some
> MAC drivers which are unhappy to have the MTU changed, but will still
> send and receive frames which are bigger than the MTU.
>
> So please keep setting the MTU of ETH_DATA_LEN +
> cpu_dp->tag_ops->overhead or less as non-fatal. Jumbo frame sizes you
> should however check the return code.
>

Ok, I'll leave it non-fatal here.

> > @@ -1465,7 +1556,10 @@ int dsa_slave_create(struct dsa_port *port)
> >       slave_dev->priv_flags |= IFF_NO_QUEUE;
> >       slave_dev->netdev_ops = &dsa_slave_netdev_ops;
> >       slave_dev->min_mtu = 0;
> > -     slave_dev->max_mtu = ETH_MAX_MTU;
> > +     if (ds->ops->port_max_mtu)
> > +             slave_dev->max_mtu = ds->ops->port_max_mtu(ds, port->index);
> > +     else
> > +             slave_dev->max_mtu = ETH_MAX_MTU;
>
> Does this bring you anything. You have a lot more checks you perform
> when performing the actual change. Seems better to keep them all
> together.
>

This here is for cooperating with dev_validate_mtu() so I can get this
nice message:

ip link set dev sw0p1 mtu 2400
Error: mtu greater than device maximum.

>         Andrew

Thanks,
-Vladimir

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ