Unverified Commit 0ec2c5ee authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!4360 net/sched: sch_hfsc: upgrade 'rt' to 'sc' when it becomes a inner curve

parents ace91c88 cd7b6140
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -913,6 +913,14 @@ hfsc_change_usc(struct hfsc_class *cl, struct tc_service_curve *usc,
	cl->cl_flags |= HFSC_USC;
}

static void
hfsc_upgrade_rt(struct hfsc_class *cl)
{
	cl->cl_fsc = cl->cl_rsc;
	rtsc_init(&cl->cl_virtual, &cl->cl_fsc, cl->cl_vt, cl->cl_total);
	cl->cl_flags |= HFSC_FSC;
}

static const struct nla_policy hfsc_policy[TCA_HFSC_MAX + 1] = {
	[TCA_HFSC_RSC]	= { .len = sizeof(struct tc_service_curve) },
	[TCA_HFSC_FSC]	= { .len = sizeof(struct tc_service_curve) },
@@ -1021,10 +1029,6 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
		if (parent == NULL)
			return -ENOENT;
	}
	if (!(parent->cl_flags & HFSC_FSC) && parent != &q->root) {
		NL_SET_ERR_MSG(extack, "Invalid parent - parent class must have FSC");
		return -EINVAL;
	}

	if (classid == 0 || TC_H_MAJ(classid ^ sch->handle) != 0)
		return -EINVAL;
@@ -1077,6 +1081,12 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
	cl->cf_tree = RB_ROOT;

	sch_tree_lock(sch);
	/* Check if the inner class is a misconfigured 'rt' */
	if (!(parent->cl_flags & HFSC_FSC) && parent != &q->root) {
		NL_SET_ERR_MSG(extack,
			       "Forced curve change on parent 'rt' to 'sc'");
		hfsc_upgrade_rt(parent);
	}
	qdisc_class_hash_insert(&q->clhash, &cl->cl_common);
	list_add_tail(&cl->siblings, &parent->children);
	if (parent->level == 0)