Commit 1c756093 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'ets-use-old-nbands-while-purging-unused-classes'

Davide Caratti says:

====================
ets: use old 'nbands' while purging unused classes

- patch 1/2 fixes a NULL dereference in the control path of sch_ets qdisc
- patch 2/2 extends kselftests to verify effectiveness of the above fix
====================

Link: https://patch.msgid.link/cover.1755016081.git.dcaratti@redhat.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 21212277 774a2ae6
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -651,6 +651,12 @@ static int ets_qdisc_change(struct Qdisc *sch, struct nlattr *opt,

	sch_tree_lock(sch);

	for (i = nbands; i < oldbands; i++) {
		if (i >= q->nstrict && q->classes[i].qdisc->q.qlen)
			list_del_init(&q->classes[i].alist);
		qdisc_purge_queue(q->classes[i].qdisc);
	}

	WRITE_ONCE(q->nbands, nbands);
	for (i = nstrict; i < q->nstrict; i++) {
		if (q->classes[i].qdisc->q.qlen) {
@@ -658,11 +664,6 @@ static int ets_qdisc_change(struct Qdisc *sch, struct nlattr *opt,
			q->classes[i].deficit = quanta[i];
		}
	}
	for (i = q->nbands; i < oldbands; i++) {
		if (i >= q->nstrict && q->classes[i].qdisc->q.qlen)
			list_del_init(&q->classes[i].alist);
		qdisc_purge_queue(q->classes[i].qdisc);
	}
	WRITE_ONCE(q->nstrict, nstrict);
	memcpy(q->prio2band, priomap, sizeof(priomap));

+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ ALL_TESTS="
	ets_test_strict
	ets_test_mixed
	ets_test_dwrr
	ets_test_plug
	classifier_mode
	ets_test_strict
	ets_test_mixed
+8 −0
Original line number Diff line number Diff line
@@ -224,3 +224,11 @@ ets_test_dwrr()
	ets_set_dwrr_two_bands
	xfail_on_slow ets_dwrr_test_01
}

ets_test_plug()
{
	ets_change_qdisc $put 2 "3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3" "1514 1514"
	tc qdisc add dev $put handle 20: parent 10:4 plug
	start_traffic_pktsize 100 $h1.10 192.0.2.1 192.0.2.2 00:c1:a0:c1:a0:00 "-c 1"
	ets_qdisc_setup $put 2
}