From patchwork Fri Apr 21 17:53:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13220566 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 D14D7C7618E for ; Fri, 21 Apr 2023 17:54:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233455AbjDURyR (ORCPT ); Fri, 21 Apr 2023 13:54:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233241AbjDURyL (ORCPT ); Fri, 21 Apr 2023 13:54:11 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 487111736 for ; Fri, 21 Apr 2023 10:54:10 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-6a606135408so2125064a34.0 for ; Fri, 21 Apr 2023 10:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682099649; x=1684691649; 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=tgTuNzspbyApr+G6Zp0R1bfTdKEOJFb43e3NBF/vvss=; b=Jt8ImvbAP7idaoHevr2O8eHLGhhqU3XSMSSmG0lZotMeQ3n0+aZA67Gdn7owlBZddN qH0HKn2TIVmo8TI4/+IKyDn7NAdkDIjdEtIdMzRMX4Lscpkc4hzy7TQTJFFFpJnfOb/g HZCmysfI3Xlj4BgIKKaBiq0adEPvoeK+rkmt1B/KsiE+zb75r5eMsNSTYpI9wo8+WhaU aejSogGlgR/0WqVLEYrwDM+LZKgws2m/wTF0uWP7uo/9XDNxZcN8jNTtkF7/P7o3VbPe cknshYFfQKLxxTRhDe3f0/qNhBgzEfT1HBI9SyeExFPWGdTgfvr7Ja8qAhuEvNOc12RO SzBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682099649; x=1684691649; 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=tgTuNzspbyApr+G6Zp0R1bfTdKEOJFb43e3NBF/vvss=; b=EkNxFRIfrGvt3eOXntzUBLDtnfxzjvGe6Zu02y2UQbzAv77UMTyMmofenICj4jKsBE f2aP67FYwbpcSuoQzqzExAv61AYPV/oVoZ0BNYjTOM2j9Ug5wllYduZL3bH3Tw/9+CBJ 5JESxWOwbA0vkU5ydCx3xUD/Lp3xYS/UAC6T60t04ucrwZC3jsVM/ChiFN6VJQlGxWrJ oFpQ4UMh4oYAJdW5gQRAIQdkd6EeE3Ik51Yq8Tf8+fXUJFlxlTU/riKvUsOy2rLq72Sq 0ZbgDHLC4Nck6FWS02iDZeDg2fAS8dz3sXEngZuLcZOUSvM1N0YlHNAxkvORGee/Ibm5 bpcg== X-Gm-Message-State: AAQBX9c2cM8+MwnIBSZjLig1TOuYsjcYr1mm/TxC1/b9kpap4G5V1gNH MoVywEgRa5FI9KCqZ+5np7W4ibEoIZHJjAlTf6k= X-Google-Smtp-Source: AKy350bPc4fx0iCckesT6yIY7yga0wD7eeAUWx6y6jnNNhd4lLiOxEfnl+gcn4xS4CXKC1pIUob1LA== X-Received: by 2002:a9d:6c0c:0:b0:6a6:191b:c7d0 with SMTP id f12-20020a9d6c0c000000b006a6191bc7d0mr3387571otq.9.1682099649539; Fri, 21 Apr 2023 10:54:09 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:7380:c348:a30c:7e82]) by smtp.gmail.com with ESMTPSA id e3-20020a9d5603000000b006a633d75310sm850426oti.16.2023.04.21.10.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 10:54:09 -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, simon.horman@corigine.com, Pedro Tammela Subject: [PATCH net-next v4 1/4] net/sched: sch_htb: use extack on errors messages Date: Fri, 21 Apr 2023 14:53:41 -0300 Message-Id: <20230421175344.299496-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421175344.299496-1-pctammela@mojatatu.com> References: <20230421175344.299496-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. Reviewed-by: Simon Horman Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela --- 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..8aef7dd9fb88 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_WEAK(extack, + "Failed to offload TC_HTB_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_WEAK(extack, + "Failed to offload TC_HTB_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 Fri Apr 21 17:53:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13220565 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 CEE54C77B76 for ; Fri, 21 Apr 2023 17:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233379AbjDURyP (ORCPT ); Fri, 21 Apr 2023 13:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233439AbjDURyO (ORCPT ); Fri, 21 Apr 2023 13:54:14 -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 35AA51738 for ; Fri, 21 Apr 2023 10:54:13 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6a5ec0d8d8aso1692383a34.2 for ; Fri, 21 Apr 2023 10:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682099652; x=1684691652; 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=XWV7EHFDukvZMAhe+Tm4Xz36bsKeCMT2Vv3MRpmyjsE=; b=JEUYJRsmwBtJN3rd+wqOpq6nrfSNPemLJS8HKBDwRODiIir8AD0SeHfPiVaA0y6MOt mgfTfNdk16W5E+miL5/f8zUszNgVoZNrLvSY7yndg1MpFodfRrr5Ct1Qk7ooQR2XZdBH L4pl7UPnJ0V0egVhHQWfemjB+hK2dSTlYYq9QxGkR9gnuYFkNeVUEpU7P31sCEJQvPrK cC1cQWl2UvNujp/fTCuVILUp3jWW1SSKpVJwS7i3fn+/6Y3EkEgaNIUjNuP8VVj2rB+r lP3A0fbsW27H3T0dLHnPfb9bMTzlTnMs+ZvpuZd2R57d9QvvntTyiWIGieL0RnSZHtnf iOJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682099652; x=1684691652; 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=XWV7EHFDukvZMAhe+Tm4Xz36bsKeCMT2Vv3MRpmyjsE=; b=gcwfeI/Pse8zWDCP9TUE+jYJPz7/2kzr7FJGw3VwNbIT+P3Y9izRKdr2RKK6EdYdxd RrGHBvceOL6gZmfyhM/b4dVnkdllHbspBTM6rSMxmTOrwCf6CIIPZTIH7Y/DmfXUXkFB 2c31227Pf4JxaZTOkzsI0SDc6RkPYoEMOnzLOJ9Cexf7GXLTH39MFoGTFozJPC/D7IE1 KPkOzW/6st5QhXNIuba2y4MEkpRkV+dSvmoXXTfiWWu/0pY28PZT1/8DKFuo8553qxBu JM3wAcmn05rC+rW445POC2/A56DiXTLRxmRPV64F7pyqpjXUxaBZS/qSArcdAAbtzbVM 4rJg== X-Gm-Message-State: AAQBX9eGMRtoQ2oiDz5impOENAtot4B6MmGI37taWcmldNCKZILXCwHb drTOgTjIxf2rVLfb+G3vQIhRqN4MWKcapFqMjyU= X-Google-Smtp-Source: AKy350a+jgXwf1vufNAilkmKy/5EEBPsWeeM76Qui/QMOo4BYgxM1MKkGt9pP3UrPP2zzcQwnF4Zqg== X-Received: by 2002:a9d:5f04:0:b0:6a5:f3ee:f7ba with SMTP id f4-20020a9d5f04000000b006a5f3eef7bamr2815242oti.38.1682099652444; Fri, 21 Apr 2023 10:54:12 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:7380:c348:a30c:7e82]) by smtp.gmail.com with ESMTPSA id e3-20020a9d5603000000b006a633d75310sm850426oti.16.2023.04.21.10.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 10:54:12 -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, simon.horman@corigine.com, Pedro Tammela Subject: [PATCH net-next v4 2/4] net/sched: sch_qfq: use extack on errors messages Date: Fri, 21 Apr 2023 14:53:42 -0300 Message-Id: <20230421175344.299496-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421175344.299496-1-pctammela@mojatatu.com> References: <20230421175344.299496-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. Reviewed-by: Simon Horman Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela --- 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 Fri Apr 21 17:53:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13220569 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 92527C77B78 for ; Fri, 21 Apr 2023 17:54:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233345AbjDURyS (ORCPT ); Fri, 21 Apr 2023 13:54:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233476AbjDURyR (ORCPT ); Fri, 21 Apr 2023 13:54:17 -0400 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 325CB1738 for ; Fri, 21 Apr 2023 10:54:16 -0700 (PDT) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-18807540d5aso1752292fac.3 for ; Fri, 21 Apr 2023 10:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682099655; x=1684691655; 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=6oCjMzDCo666o0o05nA5ZEezvfE07tQGy7QyCkzH2Wo=; b=dmoSKZqWMov0zlKYNIcMyn+vp1yRCW7GED8f/zdXObiNrGZQbEXcfseEs1BUm1Rr7+ sXkkJMXJbeokEQSypJZ1vmeLgaZ/ERBwxmlQl7zphRvKlTlfBzQKC16U4Vg2nwrhiDVJ KatTcM7st5YiGvS0XlPXkYMLM3yuoa0+nYWNfYqcEuK4gijwQm8K2Pi7U+geLMfRj4MK mJm0AgHm5bLDpmH4FNv2Na0kbN0S2Xq92bZ2H6ZlFS32DE69BEOIcX6WcJI3qm+NFOkx QYE/YdI/kk+HiYG0ur8MZD2m0dYYmiIl93p7Bl1eZrFTHA3lHp4a6kvi7v5kZJk5qXvq 13zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682099655; x=1684691655; 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=6oCjMzDCo666o0o05nA5ZEezvfE07tQGy7QyCkzH2Wo=; b=U6aHOHwJhE8eG4WMxfRCrE+UPQAY4FGC4VNdILdcvZgAMqYuc1NpH1xo8d1uxwcGoQ dcdMcw1DGcYHUCJ8/mpKm4185Q6JONmU8gV8PGVjrTkd+HeL/sPv0/Ik0y7exJv0mHW/ JtMWYtjGzCU6+yehTDHEtvafUv2w++YO53hbj46JwW+awG9G8J21GfiasPMVtcTuiMoE m9R8aIhmQq7r4gSOrlqEK4+MuSeNmOKlm0O4npY4qyxR/Pt2BL6OYLWIl/gQNkgX3BYk H60MdhMwbNot0TZ35e3vz7AhDGymylW2yUTat4E+Lyl+rB0WxS7+FBf0iGfQRrvBBFiH i+Bw== X-Gm-Message-State: AAQBX9dsKEtncMctu2Y8/gVuHNJ5jrWUjrXhuh90F0CN0cdQ86LIJixx SGst7R34LmKFaoCmV3dMMObsQ8DPgrwGfx/BF60= X-Google-Smtp-Source: AKy350a3j2HAk56TX7umB9Jbq+QKeEpRRWWK8c2lySDCH8JvRqUlIGuD5dMuS8wjic1/rQpUAH7HQA== X-Received: by 2002:a05:6870:c0c6:b0:184:832b:baf9 with SMTP id e6-20020a056870c0c600b00184832bbaf9mr4792869oad.3.1682099655392; Fri, 21 Apr 2023 10:54:15 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:7380:c348:a30c:7e82]) by smtp.gmail.com with ESMTPSA id e3-20020a9d5603000000b006a633d75310sm850426oti.16.2023.04.21.10.54.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 10:54:15 -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, simon.horman@corigine.com, Pedro Tammela Subject: [PATCH net-next v4 3/4] net/sched: sch_qfq: refactor parsing of netlink parameters Date: Fri, 21 Apr 2023 14:53:43 -0300 Message-Id: <20230421175344.299496-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421175344.299496-1-pctammela@mojatatu.com> References: <20230421175344.299496-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. Reviewed-by: Simon Horman Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela --- 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..dfd9a99e6257 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -113,6 +113,7 @@ #define QFQ_MTU_SHIFT 16 /* to support TSO/GSO */ #define QFQ_MIN_LMAX 512 /* see qfq_slot_insert */ +#define QFQ_MAX_LMAX (1UL << QFQ_MTU_SHIFT) #define QFQ_MAX_AGG_CLASSES 8 /* max num classes per aggregate allowed */ @@ -214,9 +215,14 @@ 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 = QFQ_MAX_LMAX, +}; + 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, QFQ_MAX_WEIGHT), + [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 Fri Apr 21 17:53:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13220570 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 619B6C77B76 for ; Fri, 21 Apr 2023 17:54:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233476AbjDURyZ (ORCPT ); Fri, 21 Apr 2023 13:54:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233241AbjDURyU (ORCPT ); Fri, 21 Apr 2023 13:54:20 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 237712109 for ; Fri, 21 Apr 2023 10:54:19 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6a5e905e15aso899610a34.1 for ; Fri, 21 Apr 2023 10:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682099658; x=1684691658; 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=kKHEhvhi5X9v79lAnk62wuG3F2ZBKRJ/RIhY0ooY81x+TaF6RK/dkyaYjk6EerJrwT XLuvwFSba4p4GWS66a4F+SolJ2XGqQviDtRppZxtO49qnqyMcqYhc/UrInM6qrIzNcLR fWodLpFfuOeAUCS2lnMmXwzqto25w1gNIbnMTDTVfohrELiIXSg6XnEfb+PPuJhrvSEy eLwJ/g0gSYHXxxuICJupcspsh+8mp3yV+TPxuY6XRAkTTZKRTK56oEszSBmpxUWK934e WzSRRjlYBdsjjCRDw0DHr2rjrPB2yWgUiQTrawjprthqUzVLJ7bpuCQXuPtv+ltUXTwV dtAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682099658; x=1684691658; 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=PfYbUgh2hoj8xSBjL+h6DPbMls33lGSlGy5N6mPqJ5JEh30emWst361fDh3OHU+tHq oHThKIbHE9oEKS4r5Pg/SQmfqSxN8oR/TMqIl+cP1O9jmEgXmUEouO5w5IU+uc48IzAZ c553qylSQEeVtVBB0YI516cqQh1y/WWlUQs86bp3aMnpfS09l6RgArkb0XgHSLWysRe9 Pr+EwhlJBUO3bMOrv9JjfFay899EEFdkw/sOtMY4WYOL7pTSqavkNKTRMOYvkUFiOnrL zl2aTMH0hfzJtgeOjfA9Y2KK9K83RU76MbySIS8KRTQYJiDZKKw1rGQSu8mgFkktzTsB 3+sw== X-Gm-Message-State: AAQBX9dh75OY3cdLi33fC4OSVrcOVoa3FmOjeA7KqJs/fjyk9Qx1Kt/u cVT+FPZpJDVFwrFr5RXClUGnWZJ0rjfxg4Mt6p4= X-Google-Smtp-Source: AKy350awwlT7B7pJ8pQQ6cbzYe5V0chAJKhg+s2YEkzJJimPXA1paZbyiLchYdbfxw0BFkOMLwR9lg== X-Received: by 2002:a9d:77cb:0:b0:6a6:2d87:e2ec with SMTP id w11-20020a9d77cb000000b006a62d87e2ecmr2987735otl.14.1682099658302; Fri, 21 Apr 2023 10:54:18 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:7380:c348:a30c:7e82]) by smtp.gmail.com with ESMTPSA id e3-20020a9d5603000000b006a633d75310sm850426oti.16.2023.04.21.10.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 10:54:18 -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, simon.horman@corigine.com, Pedro Tammela Subject: [PATCH net-next v4 4/4] selftests: tc-testing: add more tests for sch_qfq Date: Fri, 21 Apr 2023 14:53:44 -0300 Message-Id: <20230421175344.299496-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421175344.299496-1-pctammela@mojatatu.com> References: <20230421175344.299496-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",