Skip to content

Commit c471b90

Browse files
hormskuba-moo
authored andcommitted
net/sched: taprio: align entry index attr validation with mqprio
Both taprio and mqprio have code to validate respective entry index attributes. The validation is indented to ensure that the attribute is present, and that it's value is in range, and that each value is only used once. The purpose of this patch is to align the implementation of taprio with that of mqprio as there seems to be no good reason for them to differ. For one thing, this way, bugs will be present in both or neither. As a follow-up some consideration could be given to a common function used by both sch. No functional change intended. Except of tdc run: the results of the taprio tests # ok 81 ba39 - Add taprio Qdisc to multi-queue device (8 queues) # ok 82 9462 - Add taprio Qdisc with multiple sched-entry # ok 83 8d92 - Add taprio Qdisc with txtime-delay # ok 84 d092 - Delete taprio Qdisc with valid handle # ok 85 8471 - Show taprio class # ok 86 0a85 - Add taprio Qdisc to single-queue device # ok 87 6f62 - Add taprio Qdisc with too short interval # ok 88 831f - Add taprio Qdisc with too short cycle-time # ok 89 3e1e - Add taprio Qdisc with an invalid cycle-time # ok 90 39b4 - Reject grafting taprio as child qdisc of software taprio # ok 91 e8a1 - Reject grafting taprio as child qdisc of offloaded taprio # ok 92 a7bf - Graft cbs as child of software taprio # ok 93 6a83 - Graft cbs as child of offloaded taprio Cc: Vladimir Oltean <[email protected]> Cc: Maher Azzouzi <[email protected]> Link: https://lore.kernel.org/netdev/[email protected]/ Signed-off-by: Simon Horman <[email protected]> Reviewed-by: Cong Wang <[email protected]> Acked-by: Vinicius Costa Gomes <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5737383 commit c471b90

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

net/sched/sch_taprio.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ static const struct nla_policy entry_policy[TCA_TAPRIO_SCHED_ENTRY_MAX + 1] = {
998998

999999
static const struct nla_policy taprio_tc_policy[TCA_TAPRIO_TC_ENTRY_MAX + 1] = {
10001000
[TCA_TAPRIO_TC_ENTRY_INDEX] = NLA_POLICY_MAX(NLA_U32,
1001-
TC_QOPT_MAX_QUEUE),
1001+
TC_QOPT_MAX_QUEUE - 1),
10021002
[TCA_TAPRIO_TC_ENTRY_MAX_SDU] = { .type = NLA_U32 },
10031003
[TCA_TAPRIO_TC_ENTRY_FP] = NLA_POLICY_RANGE(NLA_U32,
10041004
TC_FP_EXPRESS,
@@ -1698,19 +1698,15 @@ static int taprio_parse_tc_entry(struct Qdisc *sch,
16981698
if (err < 0)
16991699
return err;
17001700

1701-
if (!tb[TCA_TAPRIO_TC_ENTRY_INDEX]) {
1701+
if (NL_REQ_ATTR_CHECK(extack, opt, tb, TCA_TAPRIO_TC_ENTRY_INDEX)) {
17021702
NL_SET_ERR_MSG_MOD(extack, "TC entry index missing");
17031703
return -EINVAL;
17041704
}
17051705

17061706
tc = nla_get_u32(tb[TCA_TAPRIO_TC_ENTRY_INDEX]);
1707-
if (tc >= TC_QOPT_MAX_QUEUE) {
1708-
NL_SET_ERR_MSG_MOD(extack, "TC entry index out of range");
1709-
return -ERANGE;
1710-
}
1711-
17121707
if (*seen_tcs & BIT(tc)) {
1713-
NL_SET_ERR_MSG_MOD(extack, "Duplicate TC entry");
1708+
NL_SET_ERR_MSG_ATTR(extack, tb[TCA_TAPRIO_TC_ENTRY_INDEX],
1709+
"Duplicate tc entry");
17141710
return -EINVAL;
17151711
}
17161712

0 commit comments

Comments
 (0)