From patchwork Mon Jul 3 15:10:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13300228 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEA8A100A3 for ; Mon, 3 Jul 2023 15:11:19 +0000 (UTC) Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A27C7EE for ; Mon, 3 Jul 2023 08:11:18 -0700 (PDT) Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-1b078b34df5so4486168fac.2 for ; Mon, 03 Jul 2023 08:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1688397078; x=1690989078; 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=gE+nBbwn4SMzyJShReP15jNqF2zeb2VIQI1us3ERsko=; b=UoS3M6sPjZRQGivhAh2BUnab+HwNURo1lMxJ3YGVG6sJ02CsXCNwLRyjNBk2az/UKM CuL9C8AOnufWIqDIcK9rfETGLm8Jwt6RjdnyBJ2kJLCv+uiMgD+92zqVCz0L2HqWI21/ ZTowtUlFxSlz5+1Dvbb/XbbHXwbhA492zImb+cQJDzVW8BWbE8qxxhMeGAU1IKP/xue6 XdtfWJhoJ19q5ufuvvIGUXTPiaIvC+xBnm33XyDbdF6f3SZ60SmElP/LyjxeoFoU+tFK X3Xrvj4gUFMtU2yeWlwmw2XmJjGkisS5g3Bacy/WeG3eBG18nVTkgrKylK+4LKsnb2Jt V/6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688397078; x=1690989078; 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=gE+nBbwn4SMzyJShReP15jNqF2zeb2VIQI1us3ERsko=; b=PV1/j1EEEQH/dryB/0AbY1vRP0zx4fI5HLnUvDxiTL5D1ACXUKekLQOh08mbIPKEwT 5ikVnXC4RBbdWGaf1xm/6Hr5UoDyAnZ5mvpSHD76Zk0sN9UKinsu3N4YuY4KI/yp9IYN IIASg7h65F4UBthskwZ/Ij1pdKjhzMPl6QzRcGgU56QQdX616XBgwlpU+PORSYZGzLk3 ohEDutlXeYy/6flMTbxgOLobRX6mdzwboQneG5w2M/ib4SpghXPr3zWRcCshF11iOJEe ZPKyqO5LKG9wAvrqCeMqm/9XHVzMx0aySDgRP8TmPned6JGk8m+hyOyx8Dujama3nf4y ywww== X-Gm-Message-State: ABy/qLZSfK9H/PyeJFgOcP3TZACTJej1xFD4zYrporMAdqpLqB1+vlPs qsxabYa1XuENuACCbkVqxV5nbNpNEPe77w6XXeE= X-Google-Smtp-Source: APBJJlF2/5d2JrJNcfjW2UvwoOWLDeT10I/dB+7H4kAYQAMFNylq8b95iOvbvnjT3ABiPpxT9b3XAA== X-Received: by 2002:a05:6871:4e42:b0:1b0:432d:acae with SMTP id uj2-20020a0568714e4200b001b0432dacaemr9236252oab.39.1688397077922; Mon, 03 Jul 2023 08:11:17 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:7e4b:4854:9cb2:8ddc]) by smtp.gmail.com with ESMTPSA id cm9-20020a056870b60900b0019f188355a8sm12452600oab.17.2023.07.03.08.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 08:11:17 -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, shuah@kernel.org, shaozhengchao@huawei.com, victor@mojatatu.com, simon.horman@corigine.com, Pedro Tammela Subject: [PATCH net 1/2] net/sched: sch_qfq: reintroduce lmax bound check for MTU Date: Mon, 3 Jul 2023 12:10:37 -0300 Message-Id: <20230703151038.157771-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230703151038.157771-1-pctammela@mojatatu.com> References: <20230703151038.157771-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Commit 25369891fcef deletes a check for the case where no 'lmax' is specified which commit 3037933448f6 fixes as 'lmax' could be set to the device's MTU without any bound checking for QFQ_LMAX_MIN and QFQ_LMAX_MAX. Therefore, reintroduce the check. Fixes: 25369891fcef ("net/sched: sch_qfq: refactor parsing of netlink parameters") Signed-off-by: Pedro Tammela --- net/sched/sch_qfq.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index dfd9a99e6257..b624ae539c8c 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -425,8 +425,15 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, if (tb[TCA_QFQ_LMAX]) lmax = nla_get_u32(tb[TCA_QFQ_LMAX]); - else + else { + /* MTU size is user controlled */ lmax = psched_mtu(qdisc_dev(sch)); + if (lmax < QFQ_MIN_LMAX || lmax > QFQ_MAX_LMAX) { + NL_SET_ERR_MSG_MOD(extack, + "MTU size out of bounds for qfq"); + return -EINVAL; + } + } inv_w = ONE_FP / weight; weight = ONE_FP / inv_w; From patchwork Mon Jul 3 15:10:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13300229 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29C09100A3 for ; Mon, 3 Jul 2023 15:11:24 +0000 (UTC) Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85081114 for ; Mon, 3 Jul 2023 08:11:22 -0700 (PDT) Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1b05d63080cso4680972fac.2 for ; Mon, 03 Jul 2023 08:11:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1688397081; x=1690989081; 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=+T00GBwuyZ5EBjQMl3HlnUXfbDwtPDiAoLiMp41bcFI=; b=Gsz378OoYeiMZsqtalJquOHU8bvhgF4Wc4BX/4ve+dprrUIWWoMHfrlQnjfVhDusOp 3GyysxBCpx1nTg9gCwZq9onDCcVQJiXrB8Xvj9ByhORk4YFnt+2JrzNK8GGlzslc1Aqd fsf5op9XL5YbLCtVghjmpG6EMmNwmEkYXobOIuixQf0OJSoy3e44mqWRIFCCn2UgY5aQ nLVhz2Ew3bvBxKNUjCHxH2PDAgUFERqRz7E+YIg59y7lU2bBDFH7tlXXLL+Ne9npwkSu 6Q6H+YKINGr2RfiPdLnMfL8M3f/RugtUINOEBAah1y32+k9mAOwzzCBmvlcGOpy1V9lV RxAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688397081; x=1690989081; 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=+T00GBwuyZ5EBjQMl3HlnUXfbDwtPDiAoLiMp41bcFI=; b=Jd2iUxiMcdylaY4FU264193kjeDN0sTG01GRmonLzy9vy43VTvOU0zc/Jkd5tw7cGp v9b40B/ZUa9dzd1pUMRZIhZJLdDsFf/1tA4r+jkBPD1go/d7C1eXyeJ6xz/l78KIgNe1 eC6Bqi01ww0fyEIVJ8xTRh+Ruh49lwa221Ep0kLnLPcPXFIb9Dgy/pZ64JisBL7BxOTK bk1hbyAnThTWP/B6Vu7C7bO1eH3MUA8UOpol0JS2TCZGO0cOccpNuyEwRxfk7E8RUlJF Fp4rX3J5Jzv5qdkRCXYopL+JByPkdZVQWzTinbDCb8LkTRMjTbxu1+1PC/fEMKNbNjVD YqwQ== X-Gm-Message-State: ABy/qLb6n/6LbBGErxaJL7QBj/ZSPoX7sEbS/z5MLyPzFEnAI7H0PA0Y evVYOr3RYyjDlPY7larFZzix671WS3ZW1QWQXrw= X-Google-Smtp-Source: ACHHUZ58pq4NkOEKgl2jeP/0K+Jgqq/vZuH6S1qwL7nXLD8yG2Oi8gSEA0IoB0BkgHJQicpdOc5ojw== X-Received: by 2002:a05:6870:e891:b0:18e:b6d5:7451 with SMTP id q17-20020a056870e89100b0018eb6d57451mr12211597oan.13.1688397081706; Mon, 03 Jul 2023 08:11:21 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:7e4b:4854:9cb2:8ddc]) by smtp.gmail.com with ESMTPSA id cm9-20020a056870b60900b0019f188355a8sm12452600oab.17.2023.07.03.08.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 08:11:21 -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, shuah@kernel.org, shaozhengchao@huawei.com, victor@mojatatu.com, simon.horman@corigine.com, Pedro Tammela Subject: [PATCH net 2/2] selftests: tc-testing: add tests for qfq mtu sanity check Date: Mon, 3 Jul 2023 12:10:38 -0300 Message-Id: <20230703151038.157771-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230703151038.157771-1-pctammela@mojatatu.com> References: <20230703151038.157771-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org QFQ only supports a certain bound of MTU size so make sure we check for this requirement in the tests. Signed-off-by: Pedro Tammela Tested-by: Zhengchao Shao --- .../tc-testing/tc-tests/qdiscs/qfq.json | 48 +++++++++++++++++++ 1 file changed, 48 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 147899a868d3..965da7622dac 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/qfq.json +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/qfq.json @@ -213,5 +213,53 @@ "$TC qdisc del dev $DUMMY handle 1: root", "$IP link del dev $DUMMY type dummy" ] + }, + { + "id": "85ee", + "name": "QFQ with big MTU", + "category": [ + "qdisc", + "qfq" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true", + "$IP link set dev $DUMMY mtu 2147483647 || /bin/true", + "$TC qdisc add dev $DUMMY handle 1: root qfq" + ], + "cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100", + "expExitCode": "2", + "verifyCmd": "$TC class show dev $DUMMY", + "matchPattern": "class qfq 1:", + "matchCount": "0", + "teardown": [ + "$IP link del dev $DUMMY type dummy" + ] + }, + { + "id": "ddfa", + "name": "QFQ with small MTU", + "category": [ + "qdisc", + "qfq" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true", + "$IP link set dev $DUMMY mtu 256 || /bin/true", + "$TC qdisc add dev $DUMMY handle 1: root qfq" + ], + "cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100", + "expExitCode": "2", + "verifyCmd": "$TC class show dev $DUMMY", + "matchPattern": "class qfq 1:", + "matchCount": "0", + "teardown": [ + "$IP link del dev $DUMMY type dummy" + ] } ]