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