From patchwork Thu Apr 20 16:49:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13218994 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 AF1FBC77B73 for ; Thu, 20 Apr 2023 16:50:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbjDTQuM (ORCPT ); Thu, 20 Apr 2023 12:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbjDTQuK (ORCPT ); Thu, 20 Apr 2023 12:50:10 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71AC92721 for ; Thu, 20 Apr 2023 09:50:00 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6a604259983so921462a34.2 for ; Thu, 20 Apr 2023 09:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682009399; x=1684601399; 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=zFMh5tQFjusVCSykgY6uRLPRP+S8Y+4G/MmHCYM28EA8+qV296CN6j4ScLaxQrgoSh 3GVUxaB0+S5Ia2HUdrnwfrVcUGNiskbOtwItuKQR8sQAOjsfRodPXGilLh3+xjz/uxT3 TsvLSJaYYL13MsD2W6BtOKWDjApR8J9/rpCVebTouMVyEJCxqGXSlaxnpFoNbUgFHW3x Bl+UfJbwJiUk4elHQ1tNMi9MT/X5iCSeAYKtQO+gORWgxR0gOoHYolyknFKqGTRl04Pt 7kCcnALUOV4Bbw+fTD/UDpD91t6w+HoQptYII7s54ff0NKfsh5Ibgw7lSymT9m51dvVq n8qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682009399; x=1684601399; 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=GjpEPuw1w8nqg67FBS/wQJAXn8+E7Qj4OonGROsisk9ei/p+ihZ1EYPbKYB19BmxvI Mlv1wm/1cRdIC1uzE8XG0oWeLd424GXqX4Aek0ONqAi9CwYYXg4+pXDZbpyovKUedKBj oREymDH131FdwX5dXfpQEIez3w6rqpU2laje94YxGH94eA06NrJb0ASt38Z2S9V1kVMV RCs0KArKtvzZhnuNMpH69Wfaz12MtqidVTaFAWzVjx2BPyLKWcYP0kkfgC95SY5T7TYM vYkFg+IWVdJu/2Dt+e3m6R9ddkdUtz5WF7wSCRSyelw5F3s7aFCGRQJbZvyFY0l8fjOg YfwQ== X-Gm-Message-State: AAQBX9dFDRvL+JpgWH9VzfQAeA4qt72XNbif/ZoyHOJyKyYBSivZ86lI Loytl4fTSXIdunHTEo0ZYUKZDDynD+4DcdlxuZI= X-Google-Smtp-Source: AKy350bu3xBvJHDXxGzYOECNn984FArT0DfbmA2F8bd5vLiHow/01e65mWjir+z6vEDRhR05Mw30ow== X-Received: by 2002:a05:6870:d612:b0:187:fa5e:f209 with SMTP id a18-20020a056870d61200b00187fa5ef209mr1903241oaq.5.1682009399710; Thu, 20 Apr 2023 09:49:59 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:7668:3bb3:e9e3:6d75]) by smtp.gmail.com with ESMTPSA id p26-20020a9d695a000000b006a13dd5c8a2sm894542oto.5.2023.04.20.09.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 09:49:59 -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 v3 1/5] net/sched: sch_htb: use extack on errors messages Date: Thu, 20 Apr 2023 13:49:24 -0300 Message-Id: <20230420164928.237235-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230420164928.237235-1-pctammela@mojatatu.com> References: <20230420164928.237235-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 Thu Apr 20 16:49:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13218995 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 9771FC77B72 for ; Thu, 20 Apr 2023 16:50:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229906AbjDTQuP (ORCPT ); Thu, 20 Apr 2023 12:50:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbjDTQuM (ORCPT ); Thu, 20 Apr 2023 12:50:12 -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 9BD27270E for ; Thu, 20 Apr 2023 09:50:03 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6a5f9c1200eso461508a34.1 for ; Thu, 20 Apr 2023 09:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682009403; x=1684601403; 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=QwXLopqb1crD4VsKq4RtHetYbq6zMiRWJivpaehNlXAqJT7mCksUdQ/MmfGJPbtp4l un70gl/qg/qfYRS4O7G9X4/sSDRf0qbsCRUgldWMEkKNilGJi4LE9EYuMWPSRg5YgwPL Sza9lb3i3bf8q6kgoyIQV+gc5THbo+AQpxNi5UDUcF9wYr9r0f8oN9nC6P6xHkIjlghd QTTbW+NBsBO9NrpwJ1F09OdqLvg0jMOTzRD+z9Z6jHaxNuefCRgTtHm5HK/Prk0shl9B 0UUSG6ZFaJdFIIj6Te17jqTC+1QrQ8TdCf/oxZZO9kOQFSYYbcJMpWgfcmMGT4qZR/ey k13w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682009403; x=1684601403; 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=lH315XwMg2yKjwf8bBh24xB0fccdsqWSmyXS6QudwBtIc2tgZbwn7uGdtanpHi90al eUfsWIG4NgT+Lb8NZt/pXtysx5kodX6+LReIzmC2ekuFUoCR6If35Lndk5++6QAFk60I HHIvrV63hleRPyCEJ9zwSlYnyWZ5EBVA0jSNe0ewzqKTqUaM7CD8zgcEWW73y/CQwsRN trX4o2xlYcu+febinJfyByCLhP0pIwkstD+Wz8vV9r52Vpo4/11joMqtbMYYj8al8sF6 8Rwcy92AuKr7MybSdVcIar/4TldB99JHIvRSUGyAQTEtSP+pjFWbv453RF2vJo3uYMib ah+A== X-Gm-Message-State: AAQBX9eYpemHWt6KiZn+HYFEAE1lsIyEDXj6iTMaRr/TW0M45kRLXOuR ZbuCKBIUtWJm1wD0VboHpHzikthxQ4h6N5BjaW4= X-Google-Smtp-Source: AKy350ZvgboCT2ccJLIXLK4kuMNJch8iM8cmA26bESW8aVcp226OySryTc2HBUxDcHL5oRUfQbo5gQ== X-Received: by 2002:a9d:5c09:0:b0:6a5:f5ca:f36b with SMTP id o9-20020a9d5c09000000b006a5f5caf36bmr977789otk.18.1682009402876; Thu, 20 Apr 2023 09:50:02 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:7668:3bb3:e9e3:6d75]) by smtp.gmail.com with ESMTPSA id p26-20020a9d695a000000b006a13dd5c8a2sm894542oto.5.2023.04.20.09.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 09:50:02 -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 v3 2/5] net/sched: sch_qfq: use extack on errors messages Date: Thu, 20 Apr 2023 13:49:25 -0300 Message-Id: <20230420164928.237235-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230420164928.237235-1-pctammela@mojatatu.com> References: <20230420164928.237235-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 Thu Apr 20 16:49:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13218996 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 68BF7C77B72 for ; Thu, 20 Apr 2023 16:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229724AbjDTQuS (ORCPT ); Thu, 20 Apr 2023 12:50:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229707AbjDTQuP (ORCPT ); Thu, 20 Apr 2023 12:50:15 -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 587E5421F for ; Thu, 20 Apr 2023 09:50:07 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-6a5dd070aa1so456951a34.3 for ; Thu, 20 Apr 2023 09:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682009406; x=1684601406; 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=bhuF95tFnR5BSNbNOU0zibs//tjGPELumgfmxNTyHqKxvPGI3RCHaqGvOdXCJRxgWU izPz8HUJRrI8JaDkYg0IZl7yYGRkbR63iaSV1IQUuWke7xq//3vSQMwsyPXgPpFeliD5 i9Kj2V1osRrq6tgLBMcMcGje2Z82z+OiU29+0n5VEVHmrYpp8RVcGfPhyXHyPzS5MWag GW3Ui5H00HzozUDsYIZ4J3R/E36nKN6teBxe+jRPvniLe0fTBCdXSm6Fql5ewigvxg2l 3iuoWECEAv6XgJidTqwfKThAI9cLSVW5iNwK/IcTYQwVvFMoln3vN2b0htzs6Xqa6NnX ivLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682009406; x=1684601406; 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=aL1gJ0Ru0myjuNOqW8bK4htwU2xjLaOHva16I6XI1g75eBmwuDMgzEaCIXJvEhxM/c 361b69tyU0nZxUwVU7KADoRrJk0MPIuZ//lcqXU+QB64EZsjl5V4AMwWHI1AWDpbJifR Z5WZ7D0EIw4lNFbSQ1PWuQCoxq3H+8Stt/C5P+QQSNjzF4q/C4jjQliKCwWiNi1qodAq L9fqh10NDGxM7xTzoYznAC6UaYGIZ1R74IRd0SPOmzW/3v4Q5dF0/FKYc3qsav9CN+f3 ASjIt2lX+ouZ+feQpPJ5CSSzv21DfQZr6lWRWTah7vTPOBEXp6cPyJw7NBzV9koghvB4 4vTg== X-Gm-Message-State: AAQBX9fm/KC4t5TH6MYIzcS3yD4vDb7JUU7gzcQ9cg6zLtPPhBS2+U0d m/VvFEhMzL+x877up6xKTrCKqs0Kd9CialRMU2g= X-Google-Smtp-Source: AKy350aNK2fXWVjT3fB6jMMYG82atp+zAIsHab3GI433oKZjmI1Z0moNzNQ9NXhps14DnWc/ESMM9g== X-Received: by 2002:a9d:6c86:0:b0:6a5:d450:1c30 with SMTP id c6-20020a9d6c86000000b006a5d4501c30mr1167207otr.33.1682009406329; Thu, 20 Apr 2023 09:50:06 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:7668:3bb3:e9e3:6d75]) by smtp.gmail.com with ESMTPSA id p26-20020a9d695a000000b006a13dd5c8a2sm894542oto.5.2023.04.20.09.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 09:50:05 -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 v3 3/5] net/sched: sch_qfq: refactor parsing of netlink parameters Date: Thu, 20 Apr 2023 13:49:26 -0300 Message-Id: <20230420164928.237235-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230420164928.237235-1-pctammela@mojatatu.com> References: <20230420164928.237235-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 Thu Apr 20 16:49:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13218997 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 B589DC77B7C for ; Thu, 20 Apr 2023 16:50:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230023AbjDTQuU (ORCPT ); Thu, 20 Apr 2023 12:50:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbjDTQuQ (ORCPT ); Thu, 20 Apr 2023 12:50:16 -0400 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BF244691 for ; Thu, 20 Apr 2023 09:50:12 -0700 (PDT) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-187b70ab997so5943789fac.0 for ; Thu, 20 Apr 2023 09:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682009409; x=1684601409; 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=UAFL1ZXG2vVX4JKyvW/eFhG3uLZOYmMJ2Y3Vlpou+DsRC+oCUx5Qpx3CKDbGtbbZcH IftH0WubSAmF7Qr1MKASpaMvHY57BUXc0f1MfuSka3N3msqkQgoziFQZbNSqVDoTThlg O+p7g0oTHOg5Waj7DR4vJF/Fm91e51p8Z//5SShNLvVdS0i5cDeh9iG3LYFYC7E4v3BQ BfTwM0qSdtehp4e+xE1RtNGODTUfRUvCt6SwIy+ZH/xPDBRQgdtVb9jbBKzK0Di7SUfG WP9oWfdFqus1gH67qot8cYncRicskDzfCEcbPmygwT7i+g9AS6HQ3FRr+q+/DZeJ4VtN aTdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682009409; x=1684601409; 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=b9etZ1r0jGfK2nEnP1Z7fOwt7pw14Styaug/MhbLNQ3n43ZPkgI2jh88JOs1mtyj2V MAFouBlFmiSVMqODcpz0V9pOH0LqwzJmacCQ5RKVBNwfPnM4+bpzmS9Zjae8Y9MLOVWi r0za54bH/aqXnVkppiioNi8in3XGFsM1vUdg75dg1WoTumBUu71WDjyLwTadvzF04E41 n5UaIj4Ms12qn3ObGSM0y6lhR7fgIifwF+3V97vwPRdQiZEUBtGa49siPfkzvsPc7mvH SCm2Sddfg3Cp/742HIfdZi6TlpRz0TvmXO0i78zJG1dLGcWmUqZBk8TrAeFAay2xlQnb WoTw== X-Gm-Message-State: AAQBX9eaaDjms4TXSbUVJt9iSzWg10GtPFRk1KmgCRxW13TM5Z6dQXur gKE7jXM62mAUiZn0/kdHV0X0Z1PCYFsZKYzyQEs= X-Google-Smtp-Source: AKy350Z5+e7baaV/1ROqBa9ykfVEA641rwuwdKHT6kodeMpiTWjNoekrywx87q5qL8MP0GxashD+Fg== X-Received: by 2002:a05:6830:32b8:b0:6a5:dd70:38d0 with SMTP id m56-20020a05683032b800b006a5dd7038d0mr1017235ott.12.1682009409422; Thu, 20 Apr 2023 09:50:09 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:7668:3bb3:e9e3:6d75]) by smtp.gmail.com with ESMTPSA id p26-20020a9d695a000000b006a13dd5c8a2sm894542oto.5.2023.04.20.09.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 09:50: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 v3 4/5] selftests: tc-testing: add more tests for sch_qfq Date: Thu, 20 Apr 2023 13:49:27 -0300 Message-Id: <20230420164928.237235-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230420164928.237235-1-pctammela@mojatatu.com> References: <20230420164928.237235-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", From patchwork Thu Apr 20 16:49:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13218998 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 2A420C77B72 for ; Thu, 20 Apr 2023 16:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbjDTQu2 (ORCPT ); Thu, 20 Apr 2023 12:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbjDTQuR (ORCPT ); Thu, 20 Apr 2023 12:50:17 -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 4D362423C for ; Thu, 20 Apr 2023 09:50:13 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-6a606135408so950691a34.0 for ; Thu, 20 Apr 2023 09:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1682009412; x=1684601412; 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=Cs1rgUVYEUaBUygucR5J5yk/3/ZXB2QN68zo7YB/Jr4=; b=zno2wKqhtyUkUyK+a5wIl5yEklpqUNQ9dKdjQPoBTWI89fChlEmKJ46iqeGCSQ+UhV kSgxKO++PVS/nttb4Fb+80QBudyDHm9MTKXb1vK2yJ6MvWsQEuK+aBpRA+8wb6lTe1sU QVKg1CCslMGqm52vB+EhHj+HtGAN+xLEQX3BQ42pinSqA0NTHOauY8TShh5Z4Z1ARDSF kbX7mzdtDZA26MUuu0tF9u8bm6kqfGDoGFhPywkVsZtUCrjTR+kwCTHSH51WbDonfe5t r9TkLuhsnpTHNarCY26ONe71/gmoXISwkPC4pcd2byFVv1GcE5usJ47zjWTOl+BqTegL wDxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682009412; x=1684601412; 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=Cs1rgUVYEUaBUygucR5J5yk/3/ZXB2QN68zo7YB/Jr4=; b=WzilExYdQnL9y/Cqge1OFLN330SKg4Fms0ArvuLmchcVv6evxVVeVr72fjHJdjI0QC GfauHGsakLv1d1BoThjYSLrv1Mmo7asAfzvJInlqacbL/Eyg1sDES1VjMqnrMztQ5BS3 N73Z7QgjhuxvxzBuGMp05tQvkIAmJAGl2lh1hEFshHEsty1HzU1wlrZOPDBF/JGrCgAC 8KSsFh0Ezfy1rC8JWIRyY7qPJxGXqC2p8ez0lrbvjU5IvVZyCFqx6RMWcCze6ynwo0Sj bi2WAQmw+B2meofv4OwCraZKGl4Yr2Mpl/dFTc7uUKYXxW8xaCxwPZGqO9mje76W1cid GSIA== X-Gm-Message-State: AAQBX9c/38LAJKQl2ERA6PeYRIX+pSUZ/GJWK32Fxjvx7Qgw4EMhLHHY 5DFBOV2qPjsVJoZylvAKqbyHj4GBCmipOaB6lvo= X-Google-Smtp-Source: AKy350arIE6PnmoAqenvkRkEPwnVOWcw+HdiDRRGijMSjOXc+C2Iv8X6CmIlpTdKG4tTD7YnEPtkLw== X-Received: by 2002:a9d:6251:0:b0:69f:8fe4:38b9 with SMTP id i17-20020a9d6251000000b0069f8fe438b9mr1020373otk.21.1682009412571; Thu, 20 Apr 2023 09:50:12 -0700 (PDT) Received: from localhost.localdomain ([2804:14d:5c5e:44fb:7668:3bb3:e9e3:6d75]) by smtp.gmail.com with ESMTPSA id p26-20020a9d695a000000b006a13dd5c8a2sm894542oto.5.2023.04.20.09.50.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 09:50: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 v3 5/5] net/sched: sch_qfq: BITify two bound definitions Date: Thu, 20 Apr 2023 13:49:28 -0300 Message-Id: <20230420164928.237235-6-pctammela@mojatatu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230420164928.237235-1-pctammela@mojatatu.com> References: <20230420164928.237235-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 For the sake of readability, change these two definitions to BIT() macros. Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela Reviewed-by: Simon Horman --- net/sched/sch_qfq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index dfd9a99e6257..4b9cc8a46e2a 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -105,7 +105,7 @@ #define QFQ_MAX_INDEX 24 #define QFQ_MAX_WSHIFT 10 -#define QFQ_MAX_WEIGHT (1<