Re: [PATCH net-next v4 2/6] net: dcb: add new apptrust attribute
From: Petr Machata <petrm@nvidia.com>
Date: 2022-10-31 16:25:18
Also in:
linux-arm-kernel, lkml
[off-list ref] writes:
quoted
quoted
+ if (ieee[DCB_ATTR_DCB_APP_TRUST_TABLE]) { + u8 selectors[IEEE_8021QAZ_APP_SEL_MAX + 1] = {0}; + struct nlattr *attr; + int nselectors = 0; + u8 selector; + int rem, i; + + if (!ops->dcbnl_setapptrust) { + err = -EOPNOTSUPP; + goto err; + } + + nla_for_each_nested(attr, ieee[DCB_ATTR_DCB_APP_TRUST_TABLE], + rem) { + if (nla_type(attr) != DCB_ATTR_DCB_APP_TRUST || + nla_len(attr) != 1 || + nselectors >= sizeof(selectors)) { + err = -EINVAL; + goto err; + } + + selector = nla_get_u8(attr); + 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: + case DCB_APP_SEL_PCP:This assumes that the range of DCB attributes will never overlap with the range of IEEE attributes. Wasn't the original reason for introducing the DCB nest to not have to make this assumption? I.e. now that we split DCB and IEEE attributes in the APP_TABLE attribute, shouldn't it be done here as well?Hmm, doesn't hurt to do strict checking here as well. We can even get rid of the DCB_ATTR_DCB_APP_TRUST attr and just pass DCB_ATTR_DCB_APP and DCB_ATTR_IEEE_APP? Then use the same functions to do the checking.
That would make sense to me.