From patchwork Wed Nov 27 20:31:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180342 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6655701ilf; Wed, 27 Nov 2019 13:08:38 -0800 (PST) X-Google-Smtp-Source: APXvYqzVNzP2pLFAXuI7HT1jQ4OqchEeN59u8HmOTnflACpGWMDETwwkoD+h4NdsFGAggWJXjHIJ X-Received: by 2002:a05:6402:799:: with SMTP id d25mr11441586edy.221.1574888918223; Wed, 27 Nov 2019 13:08:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888918; cv=none; d=google.com; s=arc-20160816; b=Mk8zX9Zt1rulSPz5F+UTygi37VmHBBQGQaXu7voiiZit1givxof24t+sTJFo623T5C 75hbkrMHoZYgepM50eMtABzlTt8axNGQdtIwNNF+41HAl0EyxQqkzB0HlQ1sPrtr8894 YkOHV4/2xxYGUJ0FSb9qGsuVNvvW/zoVOKdUabgs2+cWddocjoVG/CAs/VT9YQ86AzN8 R+baBVp+UiXOq2EXNTDgdmOlNFUt4OuQoaeR2caEGuBSirJBRsuPyl3b0M5D0cFlKkXO BZEEc4P6DX8qcoRtLIfOz0znQGgCJxiA90uBhTnPJIDr8fGmXEMY2WbRyxA9IJG+seC9 nEeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Qnc2CdgfcABSDRprKsFns19xdCDyzq7p0LLLRda5H6Q=; b=BZ3YrIoisIPtSRlHTYr+GDbKkQsVM0bsl+58M8GLa9q5K/lPWW9oahCpaAlMgx7EdT xILl1+5nzIF5nH68Pye3x/5XRbR6IF5JHkwVL0B0hQRNb5+cylfwTjvCR1/tLKb5U6Kl IdUmJtKgKGWb0SoBE3BEL9EWHMYXJQn1s1Sa6voTeNncHCD952ODkxwGuqZ0wRRwJkXu VFz5UD6Cq2EmL5XDU5M8DT68yQXh4NEyry0+THNLJwSyKaxbBZClzrf8iwn8KDfQZLAX bUpCG1ZDcHK/8S0e3HrhZfLZ/LemgnzaG0NuQo/EFJpl7fOlrhnIfwUbudJNXJr3VcK7 COgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rc+rEXBa; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si4330455ejd.274.2019.11.27.13.08.38; Wed, 27 Nov 2019 13:08:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rc+rEXBa; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732766AbfK0VIg (ORCPT + 15 others); Wed, 27 Nov 2019 16:08:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:35084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731761AbfK0VIg (ORCPT ); Wed, 27 Nov 2019 16:08:36 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0665F217BA; Wed, 27 Nov 2019 21:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888915; bh=Mu8/QGb2c/oeq4mNDzhCm1G0evuaFId6DUaoke7BP1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rc+rEXBaS15mmrE2CzycRSxJgBIYMhxr3r5G8RbuUn/A9DxTEBoAm6GnDbWEA3O1o 9og8uPGdd6Xm8lduq3FwgUopOjUwKYUIR6KlmRkMdhJjMEN0n6c3C8z2Oqs1MijZqC d17VXITZlzCdQ9XgKsrq8Fc8t75hpHorQ+faReo0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Vinicius Costa Gomes , Ivan Khoronzhuk , "David S. Miller" Subject: [PATCH 5.3 13/95] taprio: dont reject same mqprio settings Date: Wed, 27 Nov 2019 21:31:30 +0100 Message-Id: <20191127202850.086969835@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127202845.651587549@linuxfoundation.org> References: <20191127202845.651587549@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ivan Khoronzhuk [ Upstream commit b5a0faa3572ac70bd374bd66190ac3ad4fddab20 ] The taprio qdisc allows to set mqprio setting but only once. In case if mqprio settings are provided next time the error is returned as it's not allowed to change traffic class mapping in-flignt and that is normal. But if configuration is absolutely the same - no need to return error. It allows to provide same command couple times, changing only base time for instance, or changing only scheds maps, but leaving mqprio setting w/o modification. It more corresponds the message: "Changing the traffic mapping of a running schedule is not supported", so reject mqprio if it's really changed. Also corrected TC_BITMASK + 1 for consistency, as proposed. Fixes: a3d43c0d56f1 ("taprio: Add support adding an admin schedule") Reviewed-by: Vladimir Oltean Tested-by: Vladimir Oltean Acked-by: Vinicius Costa Gomes Signed-off-by: Ivan Khoronzhuk Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_taprio.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -842,7 +842,7 @@ static int taprio_parse_mqprio_opt(struc } /* Verify priority mapping uses valid tcs */ - for (i = 0; i < TC_BITMASK + 1; i++) { + for (i = 0; i <= TC_BITMASK; i++) { if (qopt->prio_tc_map[i] >= qopt->num_tc) { NL_SET_ERR_MSG(extack, "Invalid traffic class in priority to traffic class mapping"); return -EINVAL; @@ -1014,6 +1014,26 @@ static void setup_txtime(struct taprio_s } } +static int taprio_mqprio_cmp(const struct net_device *dev, + const struct tc_mqprio_qopt *mqprio) +{ + int i; + + if (!mqprio || mqprio->num_tc != dev->num_tc) + return -1; + + for (i = 0; i < mqprio->num_tc; i++) + if (dev->tc_to_txq[i].count != mqprio->count[i] || + dev->tc_to_txq[i].offset != mqprio->offset[i]) + return -1; + + for (i = 0; i <= TC_BITMASK; i++) + if (dev->prio_tc_map[i] != mqprio->prio_tc_map[i]) + return -1; + + return 0; +} + static int taprio_change(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) { @@ -1065,6 +1085,10 @@ static int taprio_change(struct Qdisc *s admin = rcu_dereference(q->admin_sched); rcu_read_unlock(); + /* no changes - no new mqprio settings */ + if (!taprio_mqprio_cmp(dev, mqprio)) + mqprio = NULL; + if (mqprio && (oper || admin)) { NL_SET_ERR_MSG(extack, "Changing the traffic mapping of a running schedule is not supported"); err = -ENOTSUPP; @@ -1132,7 +1156,7 @@ static int taprio_change(struct Qdisc *s mqprio->offset[i]); /* Always use supplied priority mappings */ - for (i = 0; i < TC_BITMASK + 1; i++) + for (i = 0; i <= TC_BITMASK; i++) netdev_set_prio_tc_map(dev, i, mqprio->prio_tc_map[i]); }