Skip to content

Commit e583eb5

Browse files
dcarattigregkh
authored andcommitted
net/sched: fq_pie: re-factor fix for fq_pie endless loop
commit 3a62fed upstream. the patch that fixed an endless loop in_fq_pie_init() was not considering that 65535 is a valid class id. The correct bugfix for this infinite loop is to change 'idx' to become an u32, like Colin proposed in the past [1]. Fix this as follows: - restore 65536 as maximum possible values of 'flows_cnt' - use u32 'idx' when iterating on 'q->flows' - fix the TDC selftest This reverts commit bb2f930. [1] https://lore.kernel.org/netdev/[email protected]/ CC: Colin Ian King <[email protected]> CC: [email protected] Fixes: bb2f930 ("net/sched: fix infinite loop in sch_fq_pie") Fixes: ec97ecf ("net: sched: add Flow Queue PIE packet scheduler") Signed-off-by: Davide Caratti <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 47da4f6 commit e583eb5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

net/sched/sch_fq_pie.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt,
297297
goto flow_error;
298298
}
299299
q->flows_cnt = nla_get_u32(tb[TCA_FQ_PIE_FLOWS]);
300-
if (!q->flows_cnt || q->flows_cnt >= 65536) {
300+
if (!q->flows_cnt || q->flows_cnt > 65536) {
301301
NL_SET_ERR_MSG_MOD(extack,
302-
"Number of flows must range in [1..65535]");
302+
"Number of flows must range in [1..65536]");
303303
goto flow_error;
304304
}
305305
}
@@ -367,7 +367,7 @@ static void fq_pie_timer(struct timer_list *t)
367367
struct fq_pie_sched_data *q = from_timer(q, t, adapt_timer);
368368
struct Qdisc *sch = q->sch;
369369
spinlock_t *root_lock; /* to lock qdisc for probability calculations */
370-
u16 idx;
370+
u32 idx;
371371

372372
root_lock = qdisc_lock(qdisc_root_sleeping(sch));
373373
spin_lock(root_lock);
@@ -388,7 +388,7 @@ static int fq_pie_init(struct Qdisc *sch, struct nlattr *opt,
388388
{
389389
struct fq_pie_sched_data *q = qdisc_priv(sch);
390390
int err;
391-
u16 idx;
391+
u32 idx;
392392

393393
pie_params_init(&q->p_params);
394394
sch->limit = 10 * 1024;
@@ -500,7 +500,7 @@ static int fq_pie_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
500500
static void fq_pie_reset(struct Qdisc *sch)
501501
{
502502
struct fq_pie_sched_data *q = qdisc_priv(sch);
503-
u16 idx;
503+
u32 idx;
504504

505505
INIT_LIST_HEAD(&q->new_flows);
506506
INIT_LIST_HEAD(&q->old_flows);

tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
"setup": [
1010
"$IP link add dev $DUMMY type dummy || /bin/true"
1111
],
12-
"cmdUnderTest": "$TC qdisc add dev $DUMMY root fq_pie flows 65536",
13-
"expExitCode": "2",
12+
"cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root fq_pie flows 65536",
13+
"expExitCode": "0",
1414
"verifyCmd": "$TC qdisc show dev $DUMMY",
15-
"matchPattern": "qdisc",
16-
"matchCount": "0",
15+
"matchPattern": "qdisc fq_pie 1: root refcnt 2 limit 10240p flows 65536",
16+
"matchCount": "1",
1717
"teardown": [
1818
"$IP link del dev $DUMMY"
1919
]

0 commit comments

Comments
 (0)