net/sched: fq_pie: re-factor fix for fq_pie endless loop
authorDavide Caratti <dcaratti@redhat.com>
Sat, 22 May 2021 13:14:45 +0000 (15:14 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Jun 2021 07:00:28 +0000 (09:00 +0200)
commite583eb5e7282b22c51a482ee6bf01fca1f0543f0
tree962c172452976e3e0758ca7f971b8f5e9fd6b515
parent47da4f61422991c42af6fbbc75ccdd747f392068
net/sched: fq_pie: re-factor fix for fq_pie endless loop

commit 3a62fed2fd7b6fea96d720e779cafc30dfb3a22e 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 bb2f930d6dd708469a587dc9ed1efe1ef969c0bf.

[1] https://lore.kernel.org/netdev/20210407163808.499027-1-colin.king@canonical.com/

CC: Colin Ian King <colin.king@canonical.com>
CC: stable@vger.kernel.org
Fixes: bb2f930d6dd7 ("net/sched: fix infinite loop in sch_fq_pie")
Fixes: ec97ecf1ebe4 ("net: sched: add Flow Queue PIE packet scheduler")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sched/sch_fq_pie.c
tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json