|
116 | 116 |
|
117 | 117 | #define QFQ_MTU_SHIFT 16 /* to support TSO/GSO */
|
118 | 118 | #define QFQ_MIN_LMAX 512 /* see qfq_slot_insert */
|
| 119 | +#define QFQ_MAX_LMAX (1UL << QFQ_MTU_SHIFT) |
119 | 120 |
|
120 | 121 | #define QFQ_MAX_AGG_CLASSES 8 /* max num classes per aggregate allowed */
|
121 | 122 |
|
@@ -217,9 +218,14 @@ static struct qfq_class *qfq_find_class(struct Qdisc *sch, u32 classid)
|
217 | 218 | return container_of(clc, struct qfq_class, common);
|
218 | 219 | }
|
219 | 220 |
|
| 221 | +static struct netlink_range_validation lmax_range = { |
| 222 | + .min = QFQ_MIN_LMAX, |
| 223 | + .max = QFQ_MAX_LMAX, |
| 224 | +}; |
| 225 | + |
220 | 226 | static const struct nla_policy qfq_policy[TCA_QFQ_MAX + 1] = {
|
221 |
| - [TCA_QFQ_WEIGHT] = { .type = NLA_U32 }, |
222 |
| - [TCA_QFQ_LMAX] = { .type = NLA_U32 }, |
| 227 | + [TCA_QFQ_WEIGHT] = NLA_POLICY_RANGE(NLA_U32, 1, QFQ_MAX_WEIGHT), |
| 228 | + [TCA_QFQ_LMAX] = NLA_POLICY_FULL_RANGE(NLA_U32, &lmax_range), |
223 | 229 | };
|
224 | 230 |
|
225 | 231 | /*
|
@@ -411,29 +417,20 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
|
411 | 417 | }
|
412 | 418 |
|
413 | 419 | err = nla_parse_nested_deprecated(tb, TCA_QFQ_MAX, tca[TCA_OPTIONS],
|
414 |
| - qfq_policy, NULL); |
| 420 | + qfq_policy, extack); |
415 | 421 | if (err < 0)
|
416 | 422 | return err;
|
417 | 423 |
|
418 |
| - if (tb[TCA_QFQ_WEIGHT]) { |
| 424 | + if (tb[TCA_QFQ_WEIGHT]) |
419 | 425 | weight = nla_get_u32(tb[TCA_QFQ_WEIGHT]);
|
420 |
| - if (!weight || weight > (1UL << QFQ_MAX_WSHIFT)) { |
421 |
| - pr_notice("qfq: invalid weight %u\n", weight); |
422 |
| - return -EINVAL; |
423 |
| - } |
424 |
| - } else |
| 426 | + else |
425 | 427 | weight = 1;
|
426 | 428 |
|
427 | 429 | if (tb[TCA_QFQ_LMAX])
|
428 | 430 | lmax = nla_get_u32(tb[TCA_QFQ_LMAX]);
|
429 | 431 | else
|
430 | 432 | lmax = psched_mtu(qdisc_dev(sch));
|
431 | 433 |
|
432 |
| - if (lmax < QFQ_MIN_LMAX || lmax > (1UL << QFQ_MTU_SHIFT)) { |
433 |
| - pr_notice("qfq: invalid max length %u\n", lmax); |
434 |
| - return -EINVAL; |
435 |
| - } |
436 |
| - |
437 | 434 | inv_w = ONE_FP / weight;
|
438 | 435 | weight = ONE_FP / inv_w;
|
439 | 436 |
|
|
0 commit comments