From patchwork Sat Apr 22 15:56:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13221038 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 53538C7618E for ; Sat, 22 Apr 2023 15:56:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229692AbjDVP43 (ORCPT ); Sat, 22 Apr 2023 11:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbjDVP41 (ORCPT ); Sat, 22 Apr 2023 11:56:27 -0400 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ADB1171C for ; Sat, 22 Apr 2023 08:56:26 -0700 (PDT) Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1879fc89f5eso1243720fac.0 for ; Sat, 22 Apr 2023 08:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682178985; x=1684770985; 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=x+q0AgFphvfqCLesF90eoz4LFEfXln18/pdzho0hp7AWbuei+Au4AwJvG/rlGh3ND9 e7v1IezA59ke7dyl+c0Xz7fTRmonahMqvCtLBnLKQdVWNeOWPkeYRrubmZPj9DBohRzl fb3mJQR1El9AIO4pa/OWL+MPfDl2O4TyhCdMJZdtgcoobHMWUGmkuMnj+ZKPRMbaXU4i J3Ftys3utk9vqkLuMnQ8eivb4d7ewB11/TByvpy0eWax1TsYvt54qnrfcwStOZk6Hw2n u+BKEMGYxvvz9L+DtvLKDmPiDCivMVWw4CmRkcqCXbB2aPUAJFHyPphs5Jw7OdJ+3kRo x7vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682178985; x=1684770985; 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=NgfocYnJoPOGTfsQ/cM+9R8xaQdbfQOffO883VRnOn4B5h/GEmtztKe3KsDKKldsb8 972TvaQ0f+27hLaSpy2uUT2rya7kk4z2PYszEMGU46hJrtOyDaM3sFyCKk4l62OeWjKY kJ8s+n/HAyeOiU5zWHXn/MZQyl406c0avIk9eI0BDLjFcU3oJmzhx07Yv95VqG4jwaFg 7c0KgrvK55pC0x7UFbxw7pALYT+Mz52LSR6L2ljyuJ19CuLaRugbtvjl/XeEDDZNLBBR xcG2OZ6IgWQ5AdJ3TAbc2mTULs4MuFAlKzFouEBnc++7HYvpsJCztFFzqpcXGS9CDv9t x4HQ== X-Gm-Message-State: AAQBX9eZ7q6sLMbT9MaRbg7MJT0EC39g7CxaQY4OVeWOe+FVBv/eI3TB hiDAS2HFQhiVG4SSKQP3Jiiu6iGW7PMaUwSbMHw= X-Google-Smtp-Source: AKy350a0ZSM9r1ru91ONK283bOYujMxkaB/6t9XEdods5JALTbRPOyEcHKOU26hItE3ZGqxSeokylw== X-Received: by 2002:a05:6870:12d4:b0:188:10c1:555e with SMTP id 20-20020a05687012d400b0018810c1555emr4390329oam.24.1682178985669; Sat, 22 Apr 2023 08:56:25 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:da55:60e0:8cc2:c48e]) by smtp.gmail.com with ESMTPSA id v1-20020a05683018c100b006a32eb9e0dfsm2818255ote.67.2023.04.22.08.56.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 08:56:25 -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 v5 1/4] net/sched: sch_htb: use extack on errors messages Date: Sat, 22 Apr 2023 12:56:09 -0300 Message-Id: <20230422155612.432913-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230422155612.432913-1-pctammela@mojatatu.com> References: <20230422155612.432913-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 Sat Apr 22 15:56:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13221039 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 CCA6DC6FD18 for ; Sat, 22 Apr 2023 15:56:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229717AbjDVP4b (ORCPT ); Sat, 22 Apr 2023 11:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbjDVP4a (ORCPT ); Sat, 22 Apr 2023 11:56:30 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63D9B211C for ; Sat, 22 Apr 2023 08:56:29 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6a5f6349ec3so1277414a34.0 for ; Sat, 22 Apr 2023 08:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682178988; x=1684770988; 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=ayYzk57rDyqvIN2+5xjFydnjlJTouldiht70GPmNQTI=; b=X0pmgxlHW72W/p40LywXtbm0A4TXFeGBPv+Op1tDbd5xEzqR+YChz2pZnleszP9pYt DHLgizgE6kuKqWAdpFooLbFIPWEQhzhRRKL/wz05mwBumJoyUJgMWeDv6uAYQm49roET fVRuRcP86RsRrMbC70E7g3dNNmRd9IU+p+CoC+JdpEiN1NysjcHsyy5gvKU6R6TlsgVq 5UvLatB5r2tU3k4zSDRE+OqlboP3KfLcueSA2S8XKvwvZPRj3Jw5PfwOHohXqiROu9YI 4PcedvtwEI0jTZ47neum05nUwPGJUqA1Bbde5vFVu7AO8ZUlp2qLRbHTWhQq6K38LuoW CLmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682178988; x=1684770988; 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=ayYzk57rDyqvIN2+5xjFydnjlJTouldiht70GPmNQTI=; b=GhqpxXZGIsGEJDdIZu6HW2OTm/PX92Qc+OBJzoRxRKkJ5/+z/BaTTzsK5RJ0gi+D3K 25yvlPDibfQLxLBKkE2uLTNmsDnkGbIobdufsDnvbBh64D1u2pEAIfSIDDDOta4Kcc5F vMBnYO4GtHMR/uLroTkO6cRHxvxEyl4dwpJhRXGqL6GBaBK5tu+98IkpsDQFNxjZLkFg 1N5HuPninnoC4WBEc2WFOgqyICeyUxwPAEFkwZ5DGmj8Vx/WNqc6LuF7azeFO9Usy3bg +lK1ePGKMQfxN7DJw8rpaWVmMrPRNuRIXMHVja+ph0B32Yo+jF1mkANgTH6b5yy0IQWJ smkg== X-Gm-Message-State: AAQBX9eeb6pfFUQWG5QF1+P72dliLpSPK6KTysQIHd2P8GJ56NIn6x6h Ot1DT/ntF6v7be2wkES6Wfb9USvsM1+AJVdcA7I= X-Google-Smtp-Source: AKy350bY0SQ5wyVKELMrf8PWjE0O3L8diJ49yUANfaBYjib0CMb5bviR9tP1FMymChqqa70jm7UoPQ== X-Received: by 2002:a9d:7315:0:b0:6a6:36ed:b5a7 with SMTP id e21-20020a9d7315000000b006a636edb5a7mr3302243otk.31.1682178988618; Sat, 22 Apr 2023 08:56:28 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:da55:60e0:8cc2:c48e]) by smtp.gmail.com with ESMTPSA id v1-20020a05683018c100b006a32eb9e0dfsm2818255ote.67.2023.04.22.08.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 08:56:28 -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 v5 2/4] net/sched: sch_qfq: use extack on errors messages Date: Sat, 22 Apr 2023 12:56:10 -0300 Message-Id: <20230422155612.432913-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230422155612.432913-1-pctammela@mojatatu.com> References: <20230422155612.432913-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 02098a02943e..abcc48087831 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; } @@ -442,8 +442,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 Sat Apr 22 15:56:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13221040 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 5C7F4C7618E for ; Sat, 22 Apr 2023 15:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbjDVP4g (ORCPT ); Sat, 22 Apr 2023 11:56:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229721AbjDVP4d (ORCPT ); Sat, 22 Apr 2023 11:56:33 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B0F0213D for ; Sat, 22 Apr 2023 08:56:32 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6a5f8e1f6d1so1146951a34.0 for ; Sat, 22 Apr 2023 08:56:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682178992; x=1684770992; 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=9LmUoQ5b2vuw6KXLsLWGxWWma0zZZthDoge7urEQfZ8=; b=Fv6eKMf0hU9PDXH9209S4o6Rzi0W0m+OPoTPUBRdNaLSgmI6dbRWq3O/kXlYtm+NXX PsRGGuTIfGwxOFssTy+aV0gdT5QR4k+k1XSGBZjwsg1OMcko8W9MeP6phJ+UAuJQg8U4 Siwv1DV2oauz95Shhk3MQvas114se32snMbXj5+D/RnA0yk3pemiC7LLHeHetOywsiaz B4HSlroPPysbAW9reSvsG6pNoyMQZEBFVLpO7b+h8XSb6UNdUq0Hwzfx/VnFlUj+dhXg M9br7kWOnH3SyNd5aGu1se1sabMNnGUN7y2QfdyL+k9V8ic1iD5O4Bize1i6FufxZm3y AnwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682178992; x=1684770992; 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=9LmUoQ5b2vuw6KXLsLWGxWWma0zZZthDoge7urEQfZ8=; b=JSl6K14/QQ5LKCBzZ40oK3dbes+K7n8PNmbs2Yk2wiFcQRj+SR1YpX92yh6aBdlxEs +BkHQublKPQF7rSdAy/fkwFcBg+x9KlWKegGzgYNAqHhDEhAYcIS4s2lalLykmqewdkX MN2oo3822Pl+lwOp3dy3gchCk2AZlWsDL3Nk/9VsRFWer5eTKpA9LiNQ0heESKLIqMqQ 6wV2sCb0Xr8VZhhfBzo65MbqcFF+zNZRa4pg5lhmjvzBxacvNSaY5tLVLegZHkCK1B5r A80MSKnwVrqWDD13R0aSBBMY0eK3mAnxOaioLw10r8Xa7+WAN2GRpR4p3tlDh9gz+C+2 Z16g== X-Gm-Message-State: AAQBX9fbhJ+ybrcgSEldeXGSNOjl62AHaTKggh9O6+E6PmS/+SOjuCJW 8omhfNEz8gbM36u6cuoQ2KDWz4toR8cZwxCzL0I= X-Google-Smtp-Source: AKy350asMUkvE4OlWTOVQQpo8wWo52Ur/ioht0lHVYv0bzAZcmyXoqobaysIdz2smkED3PH/SkQamA== X-Received: by 2002:a05:6830:184:b0:6a6:46e9:787e with SMTP id q4-20020a056830018400b006a646e9787emr1350089ota.6.1682178991820; Sat, 22 Apr 2023 08:56:31 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:da55:60e0:8cc2:c48e]) by smtp.gmail.com with ESMTPSA id v1-20020a05683018c100b006a32eb9e0dfsm2818255ote.67.2023.04.22.08.56.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 08:56:31 -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 v5 3/4] net/sched: sch_qfq: refactor parsing of netlink parameters Date: Sat, 22 Apr 2023 12:56:11 -0300 Message-Id: <20230422155612.432913-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230422155612.432913-1-pctammela@mojatatu.com> References: <20230422155612.432913-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 | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index abcc48087831..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,17 +414,13 @@ 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]) @@ -426,11 +428,6 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, else lmax = psched_mtu(qdisc_dev(sch)); - if (lmax < QFQ_MIN_LMAX || lmax > (1UL << QFQ_MTU_SHIFT)) { - pr_notice("qfq: invalid max length %u\n", lmax); - return -EINVAL; - } - inv_w = ONE_FP / weight; weight = ONE_FP / inv_w; From patchwork Sat Apr 22 15:56:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13221041 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 B2D37C6FD18 for ; Sat, 22 Apr 2023 15:56:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbjDVP4j (ORCPT ); Sat, 22 Apr 2023 11:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbjDVP4i (ORCPT ); Sat, 22 Apr 2023 11:56:38 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24A352680 for ; Sat, 22 Apr 2023 08:56:35 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6a5f6349ec3so1277431a34.0 for ; Sat, 22 Apr 2023 08:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682178994; x=1684770994; 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=j1EgHZGzaBRiTpy1nhcjBtWw52HXceHCxhc5sGUfV0L2t9UiIYdkrCqNlCM+5xEk3C ixNbij7Z6oItoMEAJt2LtpmUVNdp/ziZ+8m42cjK3b2+Mbf8poTCZLWDACH+Nt2oy60i YkKptMeso8kG4rZARQdnyrIJsMRl0eni8b0GYc8NDnSXEPIK+5SUQVFHkf4+hg9aZu3h KHpHnwKRzfCaeMxZh79ULLV8kiel0acImhpZaG/Ru37teoAqgpHilTxhuJ/1ODFEgq1q OAKfojn2xXr/RkLNby4dlW0C+tvDG4ILhyXXQLHqU2uthK+XDlzPP7hoNngWAj9nS5qa 754A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682178994; x=1684770994; 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=Vj2oeSYUGsyZoZ03OFzPdGMnc16tl5w5poPOmp/eZpJIDjeWl1RRo2l1x8ouXHFWBN Z27YVR9sAkDT3LdGJhUzSgpijTwSudnXXfKdBbiez14wTeraWCCv0uqj50s44wQLrTsj JsGz54CZslZMNn5ISqcvProUWY+eav98Xr0hWHtVU0ikIFYASK9YnKFERVHERYZyT2B9 NWCZE3C4kAxqq3pbgvgF4m33o5QepH527H5FE1KrQoMqlk9TOZSt1FX9pmxfH7WQyZR6 Mb3N2k5iqDkRjnHtRH2N/rgObrbC9/lF7oP32saeipAKV0ufuN7F7h12PxUSzhgeo7Nm wEkw== X-Gm-Message-State: AAQBX9duXCKpHgUKiyGmcuZGIW/MlfJ7Gs4PaA04+Of7b5harTyHkqTn AN/w2cvaMh0D4WDf9BDYDjheuv6ZA7YKBMtE7dQ= X-Google-Smtp-Source: AKy350akYOZzLMJsxNVg/BCKYe1oJQt8YWQllbgL7KdzC2/1pHKi0sK2bta654U3Q9B4ceBo0oVQiw== X-Received: by 2002:a9d:6d89:0:b0:6a5:e8da:a220 with SMTP id x9-20020a9d6d89000000b006a5e8daa220mr4803607otp.0.1682178994716; Sat, 22 Apr 2023 08:56:34 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:da55:60e0:8cc2:c48e]) by smtp.gmail.com with ESMTPSA id v1-20020a05683018c100b006a32eb9e0dfsm2818255ote.67.2023.04.22.08.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 08:56:34 -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 v5 4/4] selftests: tc-testing: add more tests for sch_qfq Date: Sat, 22 Apr 2023 12:56:12 -0300 Message-Id: <20230422155612.432913-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230422155612.432913-1-pctammela@mojatatu.com> References: <20230422155612.432913-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",