From patchwork Mon Apr 17 17:12:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13214381 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69E00C77B76 for ; Mon, 17 Apr 2023 17:12:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbjDQRMi (ORCPT ); Mon, 17 Apr 2023 13:12:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjDQRMh (ORCPT ); Mon, 17 Apr 2023 13:12:37 -0400 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B6344C37 for ; Mon, 17 Apr 2023 10:12:36 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id x11-20020a056830244b00b006a5f4f2cf62so528217otr.0 for ; Mon, 17 Apr 2023 10:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1681751555; x=1684343555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DXdXDzyGk6iT5YQWWTrZVDCFohkn9nQAvWnRKQAv8zM=; b=G8L5sFBGLdfuLG3/QbJYQgNaPiMJLfNqcQ6qgODjnYusqPFw0cE8nPx6fE8i9knj70 7t8XRxPdZljSMkrSPuct8gVATFnIA2ULe3qsOiMUMul+IC/8StEkp59i+sZoc/6+uL5r WlgtFUIRTYK9fWHNtLtnewVTzLZ8RCtHe03Z1dLiDPDIKC3hXMjAdySHGi2Ap0QHGZTr e/rwkIgD5iY8zE4CqZ5bNWQYEOVpHydpECvClbQc8JsxsOFaDz9rp2gSTaKPQQZZ63Pk 9g70n4yCAuZ1k0RuLcaYb53lb7WwK+l9u/0LOWnMDHuUZQ1X5ParoUe/c3iEwnZBlwim ge7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681751555; x=1684343555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DXdXDzyGk6iT5YQWWTrZVDCFohkn9nQAvWnRKQAv8zM=; b=Z2QUqeMDx1LMa8gaN2s3CqWJ1gfNWnJss7v+96XjmS52HLwF9OA7REkbsIsPNWlkgO M1V61N3xBi1cKwxJSNm1s3LAqxzd2NqdlG2kYwCvGlmGk70GEjpqGVrvKenqWwv8mmS6 F8LxsV4vpdZGamiiVqU6wmqt5jOYFFFCnfs+6H2Rqe50iZH0VzJuz11fFOWMCklIS3Gq I93bYlhgJaunFBrePGjK1cerNTDYA91ka2/Qvrm/wf9zpL5G/QK0evSfU2CbTCsgagZJ n/6gvXtrQi84Pery4xY8gXjgk7/gkr2vIRIdNTPIIcn5EygqaanQaKrlYgJKpHIUY5vW uenQ== X-Gm-Message-State: AAQBX9c21lrFPEaxhnQa5rag9hDEL/j9lHtg1Zw/GlchpDVMsO+D6sTc NKah3r1GZOZUtysjTzCVxFU3KA2KxjLoinAPeuQ= X-Google-Smtp-Source: AKy350Yopg3tlNImacX//7muwu6vlMVBs4WAVHBhxKWDcbcEE1W0Kpwku9ewgBbJZkUUlZwbgJPERQ== X-Received: by 2002:a05:6830:1144:b0:6a5:f719:c2f2 with SMTP id x4-20020a056830114400b006a5f719c2f2mr30679otq.30.1681751555506; Mon, 17 Apr 2023 10:12:35 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:150:be5b:9489:90ac]) by smtp.gmail.com with ESMTPSA id v17-20020a9d5a11000000b006a205a8d5bdsm4761248oth.45.2023.04.17.10.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 10:12:35 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Pedro Tammela Subject: [PATCH net-next v2 1/4] net/sched: sch_htb: use extack on errors messages Date: Mon, 17 Apr 2023 14:12:15 -0300 Message-Id: <20230417171218.333567-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230417171218.333567-1-pctammela@mojatatu.com> References: <20230417171218.333567-1-pctammela@mojatatu.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Some error messages are still being printed to dmesg. Since extack is available, provide error messages there. Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela Reviewed-by: Simon Horman --- net/sched/sch_htb.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 92f2975b6a82..79f5c4454fc3 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -1786,7 +1786,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, goto failure; err = nla_parse_nested_deprecated(tb, TCA_HTB_MAX, opt, htb_policy, - NULL); + extack); if (err < 0) goto failure; @@ -1858,7 +1858,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, /* check maximal depth */ if (parent && parent->parent && parent->parent->level < 2) { - pr_err("htb: tree is too deep\n"); + NL_SET_ERR_MSG_MOD(extack, "tree is too deep"); goto failure; } err = -ENOBUFS; @@ -1917,8 +1917,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, }; err = htb_offload(dev, &offload_opt); if (err) { - pr_err("htb: TC_HTB_LEAF_ALLOC_QUEUE failed with err = %d\n", - err); + NL_SET_ERR_MSG(extack, + "Failed to offload leaf alloc queue"); goto err_kill_estimator; } dev_queue = netdev_get_tx_queue(dev, offload_opt.qid); @@ -1937,8 +1937,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, }; err = htb_offload(dev, &offload_opt); if (err) { - pr_err("htb: TC_HTB_LEAF_TO_INNER failed with err = %d\n", - err); + NL_SET_ERR_MSG(extack, + "Failed to offload leaf to inner"); htb_graft_helper(dev_queue, old_q); goto err_kill_estimator; } @@ -2067,8 +2067,9 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, qdisc_put(parent_qdisc); if (warn) - pr_warn("HTB: quantum of class %X is %s. Consider r2q change.\n", - cl->common.classid, (warn == -1 ? "small" : "big")); + NL_SET_ERR_MSG_FMT_MOD(extack, + "quantum of class %X is %s. Consider r2q change.", + cl->common.classid, (warn == -1 ? "small" : "big")); qdisc_class_hash_grow(sch, &q->clhash); From patchwork Mon Apr 17 17:12:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13214382 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18D97C77B7A for ; Mon, 17 Apr 2023 17:12:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbjDQRMq (ORCPT ); Mon, 17 Apr 2023 13:12:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230113AbjDQRMn (ORCPT ); Mon, 17 Apr 2023 13:12:43 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 724FFF2 for ; Mon, 17 Apr 2023 10:12:39 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id cg19-20020a056830631300b0069f922cd5ceso12503261otb.12 for ; Mon, 17 Apr 2023 10:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1681751558; x=1684343558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XrgOqbQ8tfhAtqn08b0XzePIyM6gaBBRIcqWgwZFTtY=; b=CVqzSS/L0JlyAGNcnWHyUkRIn5nbbn/sne3l4oxTU6izLlnDmazZLLZhbnnVITu/m7 JPm37IQ3+oeM3eXNWX/1Glu5UijVxs2RqkKkpX1xi+HZ1l4oQo3uspwsdepV3LgHkrXS +9GSyzIJvzQ7YdlkRyDA976L02KROz/A6QVmmVVYJ/aKX4bAAlsOtK8avt2lrG/Elngb CXrPWaC/Y7Op4XLPvFITLsdJfiee10IXmDbOsMo0ID2oa0rP2qcF9i3oEHX2BcUhBYia qLHHT1GU7YE+W3VMPBO2QRBx8Z7cfspshOF5XlNiDnY6PYe9090Rrv2T37ozwHMZVv5t TbaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681751558; x=1684343558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XrgOqbQ8tfhAtqn08b0XzePIyM6gaBBRIcqWgwZFTtY=; b=E0Bud5EXlD9hOoWzTt9Rc50Kylgk/i8af1Yp53Cyc7yivJd6ksuIUKmOCuidp6OCXj nPbr1YBQCul0/k64hpY5y2iqseb6IAby0rxxp78BEj50Dz4CRSgHtJDbcyiivdKlVfG9 jnzZzzJQ1NyS4UiX8bLqb7syQpebeLipgarihZc8h3fCYbDmhXZ2VDE6AqXcY6z4Bw26 EODzfWqZMwLOVpCk3JduDN86TtWVdfmP3uWac9mxRB/B/egQEr58z2MCSXUcyTCGSaWw nAIVmqu2BMDhL9Jb7DWgq3KAO1V6qThm6PiFy2TJWfS2bivHqjFxCUZBRmTGMIUhmO3d lt4w== X-Gm-Message-State: AAQBX9ed80w7ZPzlsbqyukUjohR1VEgVWotNIhUkaaIvhxvPpZEASp4n RuFY6+N0QUTwa1JHJRsN2HjCM0BYclhsMGH7/D4= X-Google-Smtp-Source: AKy350Z/f06YBcQHgG3xzFhTkvDD0ncb7+9crVenr8v/1LmnlY3dgd25bmknb/9KBYD8DByYQXM0xw== X-Received: by 2002:a9d:7384:0:b0:6a4:32e7:e559 with SMTP id j4-20020a9d7384000000b006a432e7e559mr6567837otk.33.1681751558592; Mon, 17 Apr 2023 10:12:38 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:150:be5b:9489:90ac]) by smtp.gmail.com with ESMTPSA id v17-20020a9d5a11000000b006a205a8d5bdsm4761248oth.45.2023.04.17.10.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 10:12:38 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Pedro Tammela Subject: [PATCH net-next v2 2/4] net/sched: sch_qfq: use extack on errors messages Date: Mon, 17 Apr 2023 14:12:16 -0300 Message-Id: <20230417171218.333567-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230417171218.333567-1-pctammela@mojatatu.com> References: <20230417171218.333567-1-pctammela@mojatatu.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Some error messages are still being printed to dmesg. Since extack is available, provide error messages there. Signed-off-by: Pedro Tammela Acked-by: Jamal Hadi Salim Reviewed-by: Simon Horman --- net/sched/sch_qfq.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index cf5ebe43b3b4..323609cfbc67 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -402,8 +402,8 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, int err; int delta_w; - if (tca[TCA_OPTIONS] == NULL) { - pr_notice("qfq: no options\n"); + if (NL_REQ_ATTR_CHECK(extack, NULL, tca, TCA_OPTIONS)) { + NL_SET_ERR_MSG_MOD(extack, "missing options"); return -EINVAL; } @@ -441,8 +441,9 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, delta_w = weight - (cl ? cl->agg->class_weight : 0); if (q->wsum + delta_w > QFQ_MAX_WSUM) { - pr_notice("qfq: total weight out of range (%d + %u)\n", - delta_w, q->wsum); + NL_SET_ERR_MSG_FMT_MOD(extack, + "total weight out of range (%d + %u)\n", + delta_w, q->wsum); return -EINVAL; } From patchwork Mon Apr 17 17:12:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13214383 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73B93C77B76 for ; Mon, 17 Apr 2023 17:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230089AbjDQRMs (ORCPT ); Mon, 17 Apr 2023 13:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbjDQRMp (ORCPT ); Mon, 17 Apr 2023 13:12:45 -0400 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B4876A7B for ; Mon, 17 Apr 2023 10:12:42 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id k101-20020a9d19ee000000b006a14270bc7eso10080937otk.6 for ; Mon, 17 Apr 2023 10:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1681751561; x=1684343561; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XAykbLVeHziw0JUwYHoJmyn/25zTSaV2zD2m1EHgVFo=; b=oIYtJ0vmwaCldoTz/3/9KbR9ugwcYFmhZOvUgE2KJzM6ytLR6JXrTMohzOEiHQ/ISb iaIg/WzZ95f0/glBak3MIEl1hIW3svxMLAk8u/ZD+k+DtXNt5ClE2m1eBhC/FPDegTzL 45M+SlY8ItNGD0LFr9irE1uEoTwCm/5o3d8nKLEZUTYQcDyfRVyktydqdOc9DQORundR +FSxGSG7GLrKevXcBhK4wEFoBVOxQOXgGuOgH39Sz1n0ShMDP5H8sns1wbaOttpFuGwE jYuOgKWZHlt6DZ549ZrWcafZLWDB37fHwXMdAmkX8oJVMmia3RcvMXv/4aOwTznBtJ6a Js6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681751561; x=1684343561; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XAykbLVeHziw0JUwYHoJmyn/25zTSaV2zD2m1EHgVFo=; b=gVZ/86F6McXqdtr7ghHqorwLunWRiqK5QUDriMQbnz2YORYP5HkhuENeZuosa0k5oM Vh0G/F4HKDfo4W/yoLm/MDDp7nOmNPYlq1ndOsSokIC8EDJA984kBCKWh5A3ZVyU9rob FYEny0HHTOPNVBZ7VrtruZcOuu14TN8LOuXzix9j/sy0PQ14speJrEiEU2/3du1/fgM8 mf7+9CzmQtt/V9OvtkGoX5/8LKIEw03Ei9vZLxZswSTAxq3fD3U/L0CwpAMZ0p77wWre htrankt7KUlkFV81PKQizkYAz69XfDnFssyITOCzezEvqyyy38+pkLT0UKqKBmvvleuX R3Ww== X-Gm-Message-State: AAQBX9dgxokQ8hLYWFnfrjNwsZcBV8XnrJHub5/j+h8iT56YFfnqzZKG 9EgXahbXuqbd+YlkMM0FmCh2FqGQWb9bQsRiuoo= X-Google-Smtp-Source: AKy350bLZJts96elB29dckb3mEn3vrZtrZ6JEHAqbeum2zxZxLtVNpabLWvI1gllSOKZE9Vas5jZXA== X-Received: by 2002:a05:6830:4424:b0:6a5:dafc:3d1e with SMTP id q36-20020a056830442400b006a5dafc3d1emr5868371otv.5.1681751561711; Mon, 17 Apr 2023 10:12:41 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:150:be5b:9489:90ac]) by smtp.gmail.com with ESMTPSA id v17-20020a9d5a11000000b006a205a8d5bdsm4761248oth.45.2023.04.17.10.12.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 10:12:41 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Pedro Tammela Subject: [PATCH net-next v2 3/4] net/sched: sch_qfq: refactor parsing of netlink parameters Date: Mon, 17 Apr 2023 14:12:17 -0300 Message-Id: <20230417171218.333567-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230417171218.333567-1-pctammela@mojatatu.com> References: <20230417171218.333567-1-pctammela@mojatatu.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Two parameters can be transformed into netlink policies and validated while parsing the netlink message. Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela Reviewed-by: Simon Horman --- net/sched/sch_qfq.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index 323609cfbc67..151102ac8cce 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -214,9 +214,15 @@ static struct qfq_class *qfq_find_class(struct Qdisc *sch, u32 classid) return container_of(clc, struct qfq_class, common); } +static struct netlink_range_validation lmax_range = { + .min = QFQ_MIN_LMAX, + .max = (1UL << QFQ_MTU_SHIFT), +}; + static const struct nla_policy qfq_policy[TCA_QFQ_MAX + 1] = { - [TCA_QFQ_WEIGHT] = { .type = NLA_U32 }, - [TCA_QFQ_LMAX] = { .type = NLA_U32 }, + [TCA_QFQ_WEIGHT] = + NLA_POLICY_RANGE(NLA_U32, 1, (1UL << QFQ_MAX_WSHIFT)), + [TCA_QFQ_LMAX] = NLA_POLICY_FULL_RANGE(NLA_U32, &lmax_range), }; /* @@ -408,26 +414,18 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, } err = nla_parse_nested_deprecated(tb, TCA_QFQ_MAX, tca[TCA_OPTIONS], - qfq_policy, NULL); + qfq_policy, extack); if (err < 0) return err; - if (tb[TCA_QFQ_WEIGHT]) { + if (tb[TCA_QFQ_WEIGHT]) weight = nla_get_u32(tb[TCA_QFQ_WEIGHT]); - if (!weight || weight > (1UL << QFQ_MAX_WSHIFT)) { - pr_notice("qfq: invalid weight %u\n", weight); - return -EINVAL; - } - } else + else weight = 1; - if (tb[TCA_QFQ_LMAX]) { + if (tb[TCA_QFQ_LMAX]) lmax = nla_get_u32(tb[TCA_QFQ_LMAX]); - if (lmax < QFQ_MIN_LMAX || lmax > (1UL << QFQ_MTU_SHIFT)) { - pr_notice("qfq: invalid max length %u\n", lmax); - return -EINVAL; - } - } else + else lmax = psched_mtu(qdisc_dev(sch)); inv_w = ONE_FP / weight; From patchwork Mon Apr 17 17:12:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13214384 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70DF2C77B7A for ; Mon, 17 Apr 2023 17:12:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230147AbjDQRMz (ORCPT ); Mon, 17 Apr 2023 13:12:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbjDQRMr (ORCPT ); Mon, 17 Apr 2023 13:12:47 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95E31F2 for ; Mon, 17 Apr 2023 10:12:45 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id w15-20020a056830410f00b006a386a0568dso19884108ott.4 for ; Mon, 17 Apr 2023 10:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1681751564; x=1684343564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p/7fpClabt1h4pcpC7HxEyBgNGm9OTr9vYERAOjx5rc=; b=tzuHy+Q9wuaK2d5QCbPDSXitKZIB15wfbz/rUhHB6E7JCa2YtqgDsDycQl324QeqJm sMBaXnUEYqnwiCDR8DN/NgVXbtdUvKzM/U/vw9dR+CyBp57e03+Jhzoo6fsFWDH3iSS1 wB1qc5/VcqNT/vEg7u5dN78WyWFlrgHMxMXWbLgB4JWZ0Mmf0muT0LAkf9JtKAzTb5PU izh/HHcM0Gz+Ftjp2OBdhRVaeX53bVz/MZfrekIL8SOIvzqtv4XvDx6w7uRSGSHbzvZY aJUxrqiLG3vwfok1qKgiuhgbR9Q55+PttGAN/4S4ZSNt9heWlUhPa4Dzi7ZajidmCRVv vZAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681751564; x=1684343564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p/7fpClabt1h4pcpC7HxEyBgNGm9OTr9vYERAOjx5rc=; b=k2/dN6LJpj8JcMkOpsy09QcZCXRE6gJTjDW7ygOCm9hzM4PpJVLI7nf30dDlpV52E6 nzV0BfRtbNsdxWU6Vcx7oNT3P/ytQJOUhPUv8uZVlSGfTRVgedPDA2tmjIRWy2PaD3SN vfDLMhdvLcPe2L4Bt7w3/f1VtnjTq1LExbrYhvegRzNjzxnWRrgDE84VuECpZO6xNhjy QMiVBSNuOkutT+InncJwAJ5HTqB/AGRyLtofBT9S/Qccff1QYqdOLueVsmZzKltPpsr/ q1FxO+REtnX6MZwLAYdN0dAhiQLAS8llEId4GzoDoNawkWJvr6Tn/lCvyd0mIik/uqrg vBZA== X-Gm-Message-State: AAQBX9fD2sbb7RQ7z9rvSQ4M+CNusQx/IPWx6MVeiCmfLUbDLQz7RLnN f7EwBLkz/3M6vJ8ZnAKzjBkMvmC8KxUT1LkvJOw= X-Google-Smtp-Source: AKy350b1FTyNbmMo9Q4Dv5Py7ZRknTpiZ0oi+KkO+ontzSnCV7+21zGASB+4qRv1ULf7FdAgnoxGjw== X-Received: by 2002:a9d:7ad1:0:b0:6a5:f62d:471d with SMTP id m17-20020a9d7ad1000000b006a5f62d471dmr250057otn.34.1681751564676; Mon, 17 Apr 2023 10:12:44 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:150:be5b:9489:90ac]) by smtp.gmail.com with ESMTPSA id v17-20020a9d5a11000000b006a205a8d5bdsm4761248oth.45.2023.04.17.10.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 10:12:44 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Pedro Tammela Subject: [PATCH net-next v2 4/4] selftests: tc-testing: add more tests for sch_qfq Date: Mon, 17 Apr 2023 14:12:18 -0300 Message-Id: <20230417171218.333567-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230417171218.333567-1-pctammela@mojatatu.com> References: <20230417171218.333567-1-pctammela@mojatatu.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The QFQ qdisc class has parameter bounds that are not being checked for correctness. Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela --- .../tc-testing/tc-tests/qdiscs/qfq.json | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/qfq.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/qfq.json index 330f1a25e0ab..147899a868d3 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/qfq.json +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/qfq.json @@ -46,6 +46,30 @@ "$IP link del dev $DUMMY type dummy" ] }, + { + "id": "d364", + "name": "Test QFQ with max class weight setting", + "category": [ + "qdisc", + "qfq" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true", + "$TC qdisc add dev $DUMMY handle 1: root qfq" + ], + "cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 9999", + "expExitCode": "2", + "verifyCmd": "$TC class show dev $DUMMY", + "matchPattern": "class qfq 1:1 root weight 9999 maxpkt", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY handle 1: root", + "$IP link del dev $DUMMY type dummy" + ] + }, { "id": "8452", "name": "Create QFQ with class maxpkt setting", @@ -70,6 +94,54 @@ "$IP link del dev $DUMMY type dummy" ] }, + { + "id": "22df", + "name": "Test QFQ class maxpkt setting lower bound", + "category": [ + "qdisc", + "qfq" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true", + "$TC qdisc add dev $DUMMY handle 1: root qfq" + ], + "cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq maxpkt 128", + "expExitCode": "2", + "verifyCmd": "$TC class show dev $DUMMY", + "matchPattern": "class qfq 1:1 root weight 1 maxpkt 128", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY handle 1: root", + "$IP link del dev $DUMMY type dummy" + ] + }, + { + "id": "92ee", + "name": "Test QFQ class maxpkt setting upper bound", + "category": [ + "qdisc", + "qfq" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true", + "$TC qdisc add dev $DUMMY handle 1: root qfq" + ], + "cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq maxpkt 99999", + "expExitCode": "2", + "verifyCmd": "$TC class show dev $DUMMY", + "matchPattern": "class qfq 1:1 root weight 1 maxpkt 99999", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY handle 1: root", + "$IP link del dev $DUMMY type dummy" + ] + }, { "id": "d920", "name": "Create QFQ with multiple class setting",