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+h21howxs23VkvTVk3BiepQz7Z1vXgRiE1w+F1eeHYqYZmLpA@mail.gmail.com>
Date:   Mon, 4 May 2020 21:38:26 +0300
From:   Vladimir Oltean <olteanv@...il.com>
To:     Vivien Didelot <vivien.didelot@...il.com>
Cc:     netdev <netdev@...r.kernel.org>, Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        Vinicius Costa Gomes <vinicius.gomes@...el.com>,
        Po Liu <po.liu@....com>,
        Xiaoliang Yang <xiaoliang.yang@....com>,
        Mingkai Hu <mingkai.hu@....com>,
        Christian Herber <christian.herber@....com>,
        Claudiu Manoil <claudiu.manoil@....com>,
        Vladimir Oltean <vladimir.oltean@....com>,
        Alexandru Marginean <alexandru.marginean@....com>,
        vlad@...lov.dev, Jiri Pirko <jiri@...lanox.com>,
        Ido Schimmel <idosch@...lanox.com>,
        Jakub Kicinski <kuba@...nel.org>
Subject: Re: [PATCH net-next 4/6] net: dsa: sja1105: support flow-based
 redirection via virtual links

Hi Vivien,

On Mon, 4 May 2020 at 21:23, Vivien Didelot <vivien.didelot@...il.com> wrote:
>
> On Mon, 4 May 2020 14:19:13 -0400, Vivien Didelot <vivien.didelot@...il.com> wrote:
> > Hi Vladimir,
> >
> > On Mon,  4 May 2020 00:10:33 +0300, Vladimir Oltean <olteanv@...il.com> wrote:
> > > +           case FLOW_ACTION_REDIRECT: {
> > > +                   struct dsa_port *to_dp;
> > > +
> > > +                   if (!dsa_slave_dev_check(act->dev)) {
> > > +                           NL_SET_ERR_MSG_MOD(extack,
> > > +                                              "Destination not a switch port");
> > > +                           return -EOPNOTSUPP;
> > > +                   }
> > > +
> > > +                   to_dp = dsa_slave_to_port(act->dev);
> >
> > Instead of exporting two DSA core internal functions, I would rather expose
> > a new helper for drivers, such as this one:
> >
> >     struct dsa_port *dsa_dev_to_port(struct net_device *dev)
> >     {
> >         if (!dsa_slave_dev_check(dev))
> >             return -EOPNOTSUPP;
>
> Oops, NULL, not an integer error code, but you get the idea of public helpers.
>
> >
> >         return dsa_slave_to_port(dev);
> >     }
> >
> > The naming might not be the best, this helper could even be mirroring-specific,
> > I didn't really check the requirements for this functionality yet.
> >
> >
> > Thank you,
> >
> >       Vivien

How about

int dsa_slave_get_port_index(struct net_device *dev)
{
    if (!dsa_slave_dev_check(dev))
        return -EINVAL;

    return dsa_slave_to_port(dev)->index;
}
EXPORT_SYMBOL_GPL(dsa_slave_get_port_index);

also, where to put it? slave.c I suppose?

Thanks,
-Vladimir

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ