Blob Blame History Raw
From: Pedro Tammela <pctammela@mojatatu.com>
Date: Sat, 22 Apr 2023 12:56:11 -0300
Subject: net/sched: sch_qfq: refactor parsing of netlink parameters
Patch-mainline: v6.4-rc1
Git-commit: 25369891fcef373540f8b4e0b3bccf77a04490d5
References: bsc#1213585

Two parameters can be transformed into netlink policies and
validated while parsing the netlink message.

SLE12-SP4-LTSS: we do not have the advanced netlink policy infrastructure
yet so omit the part replacing existing checks by policies and only
introduce QFQ_MAX_LMAX (needed by further backports) and use it.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Michal Kubecek <mkubecek@suse.cz>

---
 net/sched/sch_qfq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -116,6 +116,7 @@
 
 #define QFQ_MTU_SHIFT		16	/* to support TSO/GSO */
 #define QFQ_MIN_LMAX		512	/* see qfq_slot_insert */
+#define QFQ_MAX_LMAX		(1UL << QFQ_MTU_SHIFT)
 
 #define QFQ_MAX_AGG_CLASSES	8 /* max num classes per aggregate allowed */
 
@@ -426,7 +427,7 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
 
 	if (tb[TCA_QFQ_WEIGHT]) {
 		weight = nla_get_u32(tb[TCA_QFQ_WEIGHT]);
-		if (!weight || weight > (1UL << QFQ_MAX_WSHIFT)) {
+		if (!weight || weight > QFQ_MAX_LMAX) {
 			pr_notice("qfq: invalid weight %u\n", weight);
 			return -EINVAL;
 		}
@@ -438,7 +439,7 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
 	else
 		lmax = psched_mtu(qdisc_dev(sch));
 
-	if (lmax < QFQ_MIN_LMAX || lmax > (1UL << QFQ_MTU_SHIFT)) {
+	if (lmax < QFQ_MIN_LMAX || lmax > QFQ_MAX_LMAX) {
 		pr_notice("qfq: invalid max length %u\n", lmax);
 		return -EINVAL;
 	}