Commit 733f0766 authored by Kevin Darbyshire-Bryant's avatar Kevin Darbyshire-Bryant Committed by David S. Miller

sched: act_ctinfo: use extack error reporting

Use extack error reporting mechanism in addition to returning -EINVAL

NL_SET_ERR_* code shamelessy copy/paste/adjusted from act_pedit &
sch_cake and used as reference as to what I should have done in the
first place.
Signed-off-by: default avatarKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3adcfa44
...@@ -165,15 +165,20 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, ...@@ -165,15 +165,20 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
u8 dscpmaskshift; u8 dscpmaskshift;
int ret = 0, err; int ret = 0, err;
if (!nla) if (!nla) {
NL_SET_ERR_MSG_MOD(extack, "ctinfo requires attributes to be passed");
return -EINVAL; return -EINVAL;
}
err = nla_parse_nested(tb, TCA_CTINFO_MAX, nla, ctinfo_policy, NULL); err = nla_parse_nested(tb, TCA_CTINFO_MAX, nla, ctinfo_policy, extack);
if (err < 0) if (err < 0)
return err; return err;
if (!tb[TCA_CTINFO_ACT]) if (!tb[TCA_CTINFO_ACT]) {
NL_SET_ERR_MSG_MOD(extack,
"Missing required TCA_CTINFO_ACT attribute");
return -EINVAL; return -EINVAL;
}
actparm = nla_data(tb[TCA_CTINFO_ACT]); actparm = nla_data(tb[TCA_CTINFO_ACT]);
/* do some basic validation here before dynamically allocating things */ /* do some basic validation here before dynamically allocating things */
...@@ -182,13 +187,21 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, ...@@ -182,13 +187,21 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
dscpmask = nla_get_u32(tb[TCA_CTINFO_PARMS_DSCP_MASK]); dscpmask = nla_get_u32(tb[TCA_CTINFO_PARMS_DSCP_MASK]);
/* need contiguous 6 bit mask */ /* need contiguous 6 bit mask */
dscpmaskshift = dscpmask ? __ffs(dscpmask) : 0; dscpmaskshift = dscpmask ? __ffs(dscpmask) : 0;
if ((~0 & (dscpmask >> dscpmaskshift)) != 0x3f) if ((~0 & (dscpmask >> dscpmaskshift)) != 0x3f) {
NL_SET_ERR_MSG_ATTR(extack,
tb[TCA_CTINFO_PARMS_DSCP_MASK],
"dscp mask must be 6 contiguous bits");
return -EINVAL; return -EINVAL;
}
dscpstatemask = tb[TCA_CTINFO_PARMS_DSCP_STATEMASK] ? dscpstatemask = tb[TCA_CTINFO_PARMS_DSCP_STATEMASK] ?
nla_get_u32(tb[TCA_CTINFO_PARMS_DSCP_STATEMASK]) : 0; nla_get_u32(tb[TCA_CTINFO_PARMS_DSCP_STATEMASK]) : 0;
/* mask & statemask must not overlap */ /* mask & statemask must not overlap */
if (dscpmask & dscpstatemask) if (dscpmask & dscpstatemask) {
NL_SET_ERR_MSG_ATTR(extack,
tb[TCA_CTINFO_PARMS_DSCP_STATEMASK],
"dscp statemask must not overlap dscp mask");
return -EINVAL; return -EINVAL;
}
} }
/* done the validation:now to the actual action allocation */ /* done the validation:now to the actual action allocation */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment