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: <Y1/EbRMDM4ah2qd6@DEN-LT-70577>
Date:   Mon, 31 Oct 2022 12:39:39 +0000
From:   <Daniel.Machon@...rochip.com>
To:     <petrm@...dia.com>
CC:     <netdev@...r.kernel.org>, <davem@...emloft.net>,
        <maxime.chevallier@...tlin.com>, <thomas.petazzoni@...tlin.com>,
        <edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.com>,
        <Lars.Povlsen@...rochip.com>, <Steen.Hegelund@...rochip.com>,
        <UNGLinuxDriver@...rochip.com>, <joe@...ches.com>,
        <linux@...linux.org.uk>, <Horatiu.Vultur@...rochip.com>,
        <Julia.Lawall@...ia.fr>, <vladimir.oltean@....com>,
        <linux-kernel@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH net-next v4 1/6] net: dcb: add new pcp selector to app
 object

> > diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
> > index dc4fb699b56c..68e033a459af 100644
> > --- a/net/dcb/dcbnl.c
> > +++ b/net/dcb/dcbnl.c
> > @@ -179,6 +179,57 @@ static const struct nla_policy dcbnl_featcfg_nest[DCB_FEATCFG_ATTR_MAX + 1] = {
> >  static LIST_HEAD(dcb_app_list);
> >  static DEFINE_SPINLOCK(dcb_lock);
> >
> > +static enum ieee_attrs_app dcbnl_app_attr_type_get(u8 selector)
> > +{
> > +     switch (selector) {
> > +     case IEEE_8021QAZ_APP_SEL_ETHERTYPE:
> > +     case IEEE_8021QAZ_APP_SEL_STREAM:
> > +     case IEEE_8021QAZ_APP_SEL_DGRAM:
> > +     case IEEE_8021QAZ_APP_SEL_ANY:
> > +     case IEEE_8021QAZ_APP_SEL_DSCP:
> > +             return DCB_ATTR_IEEE_APP;
> > +     case DCB_APP_SEL_PCP:
> > +             return DCB_ATTR_DCB_APP;
> > +     default:
> > +             return DCB_ATTR_IEEE_APP_UNSPEC;
> > +     }
> > +}
> > +
> > +static bool dcbnl_app_attr_type_validate(enum ieee_attrs_app type)
> > +{
> > +     switch (type) {
> > +     case DCB_ATTR_IEEE_APP:
> > +     case DCB_ATTR_DCB_APP:
> > +             return true;
> > +     default:
> > +             return false;
> > +     }
> > +}
> > +
> > +static bool dcbnl_app_selector_validate(enum ieee_attrs_app type, u32 selector)
> > +{
> > +     switch (selector) {
> > +     case IEEE_8021QAZ_APP_SEL_ETHERTYPE:
> > +     case IEEE_8021QAZ_APP_SEL_STREAM:
> > +     case IEEE_8021QAZ_APP_SEL_DGRAM:
> > +     case IEEE_8021QAZ_APP_SEL_ANY:
> > +     case IEEE_8021QAZ_APP_SEL_DSCP:
> > +             /* IEEE std selectors in IEEE std attribute */
> > +             if (type == DCB_ATTR_IEEE_APP)
> > +                     return true;
> > +             else
> > +                     return false;
> 
> AKA return type == DCB_ATTR_IEEE_APP;
> 
> > +     case DCB_APP_SEL_PCP:
> > +             /* Non-std selectors in non-std attribute */
> > +             if (type == DCB_ATTR_DCB_APP)
> > +                     return true;
> > +             else
> > +                     return false;
> 
> Likewise here.
> 
> > +     default:
> > +             return false;
> > +     }
> 
> Also, it really looks like the following would be equivalent?
> 
> static bool dcbnl_app_selector_validate(enum ieee_attrs_app type, u32 selector)
> {
>         return dcbnl_app_attr_type_get(selector) == type;
> }

Ah, yes. Less code. Much better indeed, thanks :-)

> 
> Also, shouldn't it be u8 selector?

Will be fixed in next version.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ