From patchwork Fri Jul 28 15:35:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13332064 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 A8EC114268 for ; Fri, 28 Jul 2023 15:35:57 +0000 (UTC) Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA585B5 for ; Fri, 28 Jul 2023 08:35:55 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3a425ef874dso1796808b6e.0 for ; Fri, 28 Jul 2023 08:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1690558555; x=1691163355; 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=0L8MdedY0X8wnsjs4lzrDqZOSVz+oJAJQEkJT7CT0w8=; b=GOa/lzPz76CtHeOJW1QMngqdDhJeap5Cham6fZh3fQ0HdUqvQj1638C0pemyxi60a6 hu+LDzqWNnFzGBy3NWtoh67WiW4bMcnPgqWQYy+8wQLtfegidiZUFI6RUNmCUD03lcvq Yjay/xRYCtLxFav3AiXSfrn1YpABi3urBa0SfeZB832axe97mAj2hOCfbcgnHANQsdQi Yxe1zxEfI7RCIUre4EyDIYGqervnC3pAZ9dr3KbjY8OIJmbBc4VQ4Vb6/d6L7Jo7EIwk 21Cnjxp8oA1jBkmDd+GoBBfiT393UnPBb1YTtFL7sew8DuMk85EVBigQcwKgZSH/j7PE MSWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690558555; x=1691163355; 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=0L8MdedY0X8wnsjs4lzrDqZOSVz+oJAJQEkJT7CT0w8=; b=PmV2+eZh4A6HHKkS2+j6ZGK3A8yfv18qzRT42wD6oRcbPwMoKpby+LEUJV8vRLZ0Nu o0A5V2ew/CeY1G2AofqTFX6ymMx9lf1MP+V2o7R19ypu0ie55tPM+hgkpyTT4tQq4Zd/ lPj8RQRIcmtbdvwnZEhi6nLhVolnPUt96S378NgDq2wiepzmo7Fq6dYOZzsBn4se3vZ/ vySHPoEN/nmUC16DwABOrj1GD5dtf86XSKciPjlYBCNkigJaqUC5jCZgnUTY5y37HKJK lpblbNa5MvUxv5cdzg3OneCWR2PRJnilqClW+SiLHX22cgMW6d25gmFZtp/6kd9VF2Er zXTA== X-Gm-Message-State: ABy/qLbzCtKv2jguwZEAxzVY8fvBxPMGgoxYgKYfufgrKWwnKAvUSqDA pK4H+p+Ya/Eq07xzHMMCrNx3LW3Uq0iKpyEgMsI= X-Google-Smtp-Source: APBJJlFrsMEPTAqml/qDO/HvtY2cU2tZrSCyeKfAFqGRQPbdCV/yvVh0SadIR2FPJ8X1Be57I4OmHQ== X-Received: by 2002:a05:6808:2a6c:b0:3a4:17b0:2b12 with SMTP id fu12-20020a0568082a6c00b003a417b02b12mr3023412oib.11.1690558555023; Fri, 28 Jul 2023 08:35:55 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:81ef:7444:5901:c19d]) by smtp.gmail.com with ESMTPSA id u8-20020a544388000000b003a3b321712fsm1732893oiv.35.2023.07.28.08.35.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 08:35:54 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, Pedro Tammela Subject: [PATCH net-next v2 1/5] net/sched: wrap open coded Qdics class filter counter Date: Fri, 28 Jul 2023 12:35:33 -0300 Message-Id: <20230728153537.1865379-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230728153537.1865379-1-pctammela@mojatatu.com> References: <20230728153537.1865379-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_BLOCKED,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 The 'filter_cnt' counter is used to control a Qdisc class lifetime. Each filter referecing this class by its id will eventually increment/decrement this counter in their respective 'add/update/delete' routines. As these operations are always serialized under rtnl lock, we don't need an atomic type like 'refcount_t'. It also means that we lose the overflow/underflow checks already present in refcount_t, which are valuable to hunt down bugs where the unsigned counter wraps around as it aids automated tools like syzkaller to scream in such situations. Wrap the open coded increment/decrement into helper functions and add overflow checks to the operations. Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela --- include/net/sch_generic.h | 26 ++++++++++++++++++++++++++ net/sched/sch_drr.c | 9 ++++----- net/sched/sch_hfsc.c | 8 ++++---- net/sched/sch_htb.c | 8 +++----- net/sched/sch_qfq.c | 10 ++++------ 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 15be2d96b06d..f232512505f8 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -599,6 +599,7 @@ get_default_qdisc_ops(const struct net_device *dev, int ntx) struct Qdisc_class_common { u32 classid; + unsigned int filter_cnt; struct hlist_node hnode; }; @@ -633,6 +634,31 @@ qdisc_class_find(const struct Qdisc_class_hash *hash, u32 id) return NULL; } +static inline bool qdisc_class_in_use(const struct Qdisc_class_common *cl) +{ + return cl->filter_cnt > 0; +} + +static inline void qdisc_class_get(struct Qdisc_class_common *cl) +{ + unsigned int res; + + if (check_add_overflow(cl->filter_cnt, 1, &res)) + WARN(1, "Qdisc class overflow"); + + cl->filter_cnt = res; +} + +static inline void qdisc_class_put(struct Qdisc_class_common *cl) +{ + unsigned int res; + + if (check_sub_overflow(cl->filter_cnt, 1, &res)) + WARN(1, "Qdisc class underflow"); + + cl->filter_cnt = res; +} + static inline int tc_classid_to_hwtc(struct net_device *dev, u32 classid) { u32 hwtc = TC_H_MIN(classid) - TC_H_MIN_PRIORITY; diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c index e35a4e90f4e6..1b22b3b741c9 100644 --- a/net/sched/sch_drr.c +++ b/net/sched/sch_drr.c @@ -17,7 +17,6 @@ struct drr_class { struct Qdisc_class_common common; - unsigned int filter_cnt; struct gnet_stats_basic_sync bstats; struct gnet_stats_queue qstats; @@ -150,7 +149,7 @@ static int drr_delete_class(struct Qdisc *sch, unsigned long arg, struct drr_sched *q = qdisc_priv(sch); struct drr_class *cl = (struct drr_class *)arg; - if (cl->filter_cnt > 0) + if (qdisc_class_in_use(&cl->common)) return -EBUSY; sch_tree_lock(sch); @@ -187,8 +186,8 @@ static unsigned long drr_bind_tcf(struct Qdisc *sch, unsigned long parent, { struct drr_class *cl = drr_find_class(sch, classid); - if (cl != NULL) - cl->filter_cnt++; + if (cl) + qdisc_class_get(&cl->common); return (unsigned long)cl; } @@ -197,7 +196,7 @@ static void drr_unbind_tcf(struct Qdisc *sch, unsigned long arg) { struct drr_class *cl = (struct drr_class *)arg; - cl->filter_cnt--; + qdisc_class_put(&cl->common); } static int drr_graft_class(struct Qdisc *sch, unsigned long arg, diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 70b0c5873d32..896cb401fdb9 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -116,7 +116,6 @@ struct hfsc_class { struct net_rate_estimator __rcu *rate_est; struct tcf_proto __rcu *filter_list; /* filter list */ struct tcf_block *block; - unsigned int filter_cnt; /* filter count */ unsigned int level; /* class level in hierarchy */ struct hfsc_sched *sched; /* scheduler data */ @@ -1094,7 +1093,8 @@ hfsc_delete_class(struct Qdisc *sch, unsigned long arg, struct hfsc_sched *q = qdisc_priv(sch); struct hfsc_class *cl = (struct hfsc_class *)arg; - if (cl->level > 0 || cl->filter_cnt > 0 || cl == &q->root) + if (cl->level > 0 || qdisc_class_in_use(&cl->cl_common) || + cl == &q->root) return -EBUSY; sch_tree_lock(sch); @@ -1223,7 +1223,7 @@ hfsc_bind_tcf(struct Qdisc *sch, unsigned long parent, u32 classid) if (cl != NULL) { if (p != NULL && p->level <= cl->level) return 0; - cl->filter_cnt++; + qdisc_class_get(&cl->cl_common); } return (unsigned long)cl; @@ -1234,7 +1234,7 @@ hfsc_unbind_tcf(struct Qdisc *sch, unsigned long arg) { struct hfsc_class *cl = (struct hfsc_class *)arg; - cl->filter_cnt--; + qdisc_class_put(&cl->cl_common); } static struct tcf_block *hfsc_tcf_block(struct Qdisc *sch, unsigned long arg, diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 333800a7d4eb..05c8291865ae 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -102,7 +102,6 @@ struct htb_class { struct tcf_proto __rcu *filter_list; /* class attached filters */ struct tcf_block *block; - int filter_cnt; int level; /* our level (see above) */ unsigned int children; @@ -1710,7 +1709,7 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg, * tc subsys guarantee us that in htb_destroy it holds no class * refs so that we can remove children safely there ? */ - if (cl->children || cl->filter_cnt) + if (cl->children || qdisc_class_in_use(&cl->common)) return -EBUSY; if (!cl->level && htb_parent_last_child(cl)) @@ -2107,7 +2106,7 @@ static unsigned long htb_bind_filter(struct Qdisc *sch, unsigned long parent, * be broken by class during destroy IIUC. */ if (cl) - cl->filter_cnt++; + qdisc_class_get(&cl->common); return (unsigned long)cl; } @@ -2115,8 +2114,7 @@ static void htb_unbind_filter(struct Qdisc *sch, unsigned long arg) { struct htb_class *cl = (struct htb_class *)arg; - if (cl) - cl->filter_cnt--; + qdisc_class_put(&cl->common); } static void htb_walk(struct Qdisc *sch, struct qdisc_walker *arg) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index befaf74b33ca..7addc15f01b5 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -130,8 +130,6 @@ struct qfq_aggregate; struct qfq_class { struct Qdisc_class_common common; - unsigned int filter_cnt; - struct gnet_stats_basic_sync bstats; struct gnet_stats_queue qstats; struct net_rate_estimator __rcu *rate_est; @@ -545,7 +543,7 @@ static int qfq_delete_class(struct Qdisc *sch, unsigned long arg, struct qfq_sched *q = qdisc_priv(sch); struct qfq_class *cl = (struct qfq_class *)arg; - if (cl->filter_cnt > 0) + if (qdisc_class_in_use(&cl->common)) return -EBUSY; sch_tree_lock(sch); @@ -580,8 +578,8 @@ static unsigned long qfq_bind_tcf(struct Qdisc *sch, unsigned long parent, { struct qfq_class *cl = qfq_find_class(sch, classid); - if (cl != NULL) - cl->filter_cnt++; + if (cl) + qdisc_class_get(&cl->common); return (unsigned long)cl; } @@ -590,7 +588,7 @@ static void qfq_unbind_tcf(struct Qdisc *sch, unsigned long arg) { struct qfq_class *cl = (struct qfq_class *)arg; - cl->filter_cnt--; + qdisc_class_put(&cl->common); } static int qfq_graft_class(struct Qdisc *sch, unsigned long arg, From patchwork Fri Jul 28 15:35:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13332065 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 B04AA14268 for ; Fri, 28 Jul 2023 15:35:59 +0000 (UTC) Received: from mail-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1A55B5 for ; Fri, 28 Jul 2023 08:35:58 -0700 (PDT) Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-565db4666d7so1571595eaf.0 for ; Fri, 28 Jul 2023 08:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1690558558; x=1691163358; 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=FNuNpQZuFjNXy4RfY928yv7WL3BURqXGLN3Mv2kKb3E=; b=zYiTJKW1rmUw8aaIJ4R+lAXHknrv5DB1zIjvIhoqFiKcZUIn8TBwRK7Veq3+x5Z8+Z Vd54YRCOGkuTkXkRcTQsqTz9C2YOgZd3kAj1s94tTofi7Z5jqLcb42c7d0M8jdKlQkhu p+aAU3Rixg7OD2tw3QVWJ3UjBeS9MfoQaCgD6b2X06WkqsaUPPdoM8oqGpuOyrlPYJij n5UvkDJ/cZB7Ak3WKnVaJQUBMT1idqk9i+cIETPUg9bQvflCTUL9NzYa0f2z3V6ThpKO 3M8koISWse+rr6x5VcsCMlGZfWX6romPuijUEKkUU9qdTpI+XZ1aEIqGNFYID5UkeJvg a46Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690558558; x=1691163358; 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=FNuNpQZuFjNXy4RfY928yv7WL3BURqXGLN3Mv2kKb3E=; b=Z2QyLhSHCOOk8FD9+zzgzDGAzLvhZsUISn+rdt5BQv1jdsO4M21T5C0fsfOHF6ur2e JbELV02CX7UzTHPDXgnxCWXaGWDPgYHInxeT+ocNRW6lEAUZG3maNMwYlVd+AUAECPWT mTu4UMQ34MRvfV9y1OdFOzWlmARMWfob4m7RiMBMsbd2qH2e4DDaXMmqONGKQdN3KUHW AP3bFQUfO1C7wV0H8J5bswxZvV4OYnH29QALbSBi/PhOtsjKsNRQFtpi1YJrAHVU/pea /J1Hw+jrY20AigONTbD1X24zodu5iUrE3Pq5n59xUDj9xq7Z6Z19kBjRMUGu2jF0gnGX sGVQ== X-Gm-Message-State: ABy/qLZiDvMrW3m46ZOL1WRMvFu+6vdcy9MhkrOGsdlrPO5yLeT0zm4y tQWZvAvm5Gn1loK2ZKGK3M1SdOdLlnwwYpdpvDY= X-Google-Smtp-Source: APBJJlE7XubeWkvLXb+bBjo2VzBt4crGCSVwyYiopZYW0aSPO7uFz0WKz+PLuIHQWkCnxn37SVT2JQ== X-Received: by 2002:a05:6808:14cf:b0:3a3:fbf0:37db with SMTP id f15-20020a05680814cf00b003a3fbf037dbmr3633937oiw.59.1690558557774; Fri, 28 Jul 2023 08:35:57 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:81ef:7444:5901:c19d]) by smtp.gmail.com with ESMTPSA id u8-20020a544388000000b003a3b321712fsm1732893oiv.35.2023.07.28.08.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 08:35:57 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, Pedro Tammela Subject: [PATCH net-next v2 2/5] net/sched: sch_drr: warn about class in use while deleting Date: Fri, 28 Jul 2023 12:35:34 -0300 Message-Id: <20230728153537.1865379-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230728153537.1865379-1-pctammela@mojatatu.com> References: <20230728153537.1865379-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 Add extack to warn that delete was rejected because the class is still in use Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela --- net/sched/sch_drr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c index 1b22b3b741c9..19901e77cd3b 100644 --- a/net/sched/sch_drr.c +++ b/net/sched/sch_drr.c @@ -149,8 +149,10 @@ static int drr_delete_class(struct Qdisc *sch, unsigned long arg, struct drr_sched *q = qdisc_priv(sch); struct drr_class *cl = (struct drr_class *)arg; - if (qdisc_class_in_use(&cl->common)) + if (qdisc_class_in_use(&cl->common)) { + NL_SET_ERR_MSG(extack, "DRR class is in use"); return -EBUSY; + } sch_tree_lock(sch); From patchwork Fri Jul 28 15:35:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13332066 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 6D44C14268 for ; Fri, 28 Jul 2023 15:36:02 +0000 (UTC) Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B85DE4F for ; Fri, 28 Jul 2023 08:36:01 -0700 (PDT) Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3a1d9b64837so1810494b6e.0 for ; Fri, 28 Jul 2023 08:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1690558560; x=1691163360; 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=fIamuhhg5Mo4/lvYDmdnWkqTyyPCd0CWOrZsKWqJUdQ=; b=q4J7lr9cSgYE/yNTxv203Q29zFoXQugTSczGcFjVW9uj1T3khbo01KWGELIz2uTSVV 0xRgTpp+XoQwza0HO+BBZHq6hQjZBtN09DqxU0DT7qtUOQFDv2NdF+THqrH+3316qxSR tPG5/CNxW4/55UoRqzvoxa/JzdCyj4SExKTT7iPpLzaLfHidzP7kulu0fTB3zDJKhJad w+bwzl3IWNQf9AoK/LH/9aArTvNVmCk6O571wWdCuuWnGY3nN1VBWLFb7htY7AxWWn7d B4FdmPHjOEwIhm2G43H+MvWQLe3N/3L+J6JbwVUYPAmVpBfBWdAyjDVRvzBC+uRYCy7S nncA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690558560; x=1691163360; 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=fIamuhhg5Mo4/lvYDmdnWkqTyyPCd0CWOrZsKWqJUdQ=; b=e+D43JgtHj+/RHSfMowxpuC+/8/CkccOXVT+yD0L0pFGSupbraiGzxkv0sxydI28qZ 085lwFmkuEzuIzSozs/w4rbMwwCXnRUP3pvqf3fDFmm9tIChIFB3kvkTtCwI1SqrKIz+ n9z32ZFdUY6ZU7NpmI6z3GFLFRYnXBW9JxNQ/xH5QGpP1UDJw3taWtTD6uIEXUi5MwAl eu1HpqVG37u1UFEumqv0T/nR0142E0y3sRdykVQ11Amz3+DxRhA2rl050xjaW7De7EFZ Z9ThtNeFGUBULBE0cH+z2VaXownW5pFWrhCFkMCjwWBq/U4QlkeIY71d6qJZBZK75hG5 /hCw== X-Gm-Message-State: ABy/qLYKhmipePtPRs+n68IbenxQfQZ7hW202eoYlXf6pJyEMUFeDYYk LT98eFYP8Die2pHFdhGCYs0PB+3Vt6bNnpIaLIY= X-Google-Smtp-Source: APBJJlH43BGdQY2i39brIl27smPY/M6uFM+dPAeRVqKW/kOv8OFzvVkMACUjS45EoMcYM4YD11ASXw== X-Received: by 2002:aca:f0c1:0:b0:3a4:8590:90f2 with SMTP id o184-20020acaf0c1000000b003a4859090f2mr2739720oih.47.1690558560646; Fri, 28 Jul 2023 08:36:00 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:81ef:7444:5901:c19d]) by smtp.gmail.com with ESMTPSA id u8-20020a544388000000b003a3b321712fsm1732893oiv.35.2023.07.28.08.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 08:36:00 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, Pedro Tammela Subject: [PATCH net-next v2 3/5] net/sched: sch_hfsc: warn about class in use while deleting Date: Fri, 28 Jul 2023 12:35:35 -0300 Message-Id: <20230728153537.1865379-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230728153537.1865379-1-pctammela@mojatatu.com> References: <20230728153537.1865379-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_BLOCKED,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 Add extack to warn that delete was rejected because the class is still in use Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela --- net/sched/sch_hfsc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 896cb401fdb9..98805303218d 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1094,8 +1094,10 @@ hfsc_delete_class(struct Qdisc *sch, unsigned long arg, struct hfsc_class *cl = (struct hfsc_class *)arg; if (cl->level > 0 || qdisc_class_in_use(&cl->cl_common) || - cl == &q->root) + cl == &q->root) { + NL_SET_ERR_MSG(extack, "HFSC class in use"); return -EBUSY; + } sch_tree_lock(sch); From patchwork Fri Jul 28 15:35:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13332067 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 3A9B914A86 for ; Fri, 28 Jul 2023 15:36:05 +0000 (UTC) Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36EB1E4F for ; Fri, 28 Jul 2023 08:36:04 -0700 (PDT) Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-563531a3ad2so1623912eaf.3 for ; Fri, 28 Jul 2023 08:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1690558563; x=1691163363; 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=iO4gG3RNXbc8CK10QgS8sY57Q/Zq1jk/6wJgK1vauZM=; b=zxL11t5Ms8co4jDxcS+qcQcljRmtd754G6R52wpIRjUeHLBwxy3FAISZKpUjMxfAIJ 9yFOH3Z6o9yL1xCZNjtptBTR/v4v7sW1Wkzl4xRevvs7e7X3+EZap9Antqd+ti3caV2a 0CXilq8fKS17HBxg9tzDvCw0xUbctSk97qlD1or2fx0bRl/BGBpMCIC0m5N34vHMkEQr gdxE7gtzZnn9aLAFj96p5iJJS9ppRsEo/L5nbyz2gpddxPwOvK18n0m6RAi5GgzA9EtZ iucmK55g1BfoIhujW+nybxX+JKzEYLo6BwDzLiOF4P1SmaA8bA7CMhlW9Evw/WUthbXd OGpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690558563; x=1691163363; 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=iO4gG3RNXbc8CK10QgS8sY57Q/Zq1jk/6wJgK1vauZM=; b=BGGZYckPVWIYFXYEMxeEQ3jj8K3nsaxpWRCGA3DW0HYKd+GpiWjWaYl277LFnVdI16 d+ejrSVIijqMv4Ar25ecYmZnxXpmq6uxSSmL+c9yzgXHhlBTYa5wlnG6htaKdD3oVm/W sc6t/m4G940t8r6G/lelTYz4MjvM+irl7GXw1ss555sFYYuwuqazYOLMjOT/fnJpkYY2 Sd1qPVRq9nh7yCwpRCfe2CEBDiuuZJkLOmSQB6+dsXajMsGYtG+xhfEGqcxEuVHA+VMh vGWTIhOiN+vk5KLu9d/4cXu04lJmruHG9z3PqibuPle3E3keZ8hpru1zJjfqGf4/0H+a wDeg== X-Gm-Message-State: ABy/qLalD/WHXB7KPVNxigXzEdPnTaKxoUByq9MU7HBb63x43wezWHxE Rmt657OPafcPeT/D0/6ZKd2hrG5VeR4+o8LwR2A= X-Google-Smtp-Source: APBJJlF2WKJGlO2oexifgnK+drVCLkjQBiLAQ9GA1Sfn6cdmoX+8MqEcpBnhlP/NF4JWueuEEM8mMw== X-Received: by 2002:a54:448d:0:b0:3a4:232c:5d7e with SMTP id v13-20020a54448d000000b003a4232c5d7emr3760203oiv.5.1690558563439; Fri, 28 Jul 2023 08:36:03 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:81ef:7444:5901:c19d]) by smtp.gmail.com with ESMTPSA id u8-20020a544388000000b003a3b321712fsm1732893oiv.35.2023.07.28.08.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 08:36:03 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, Pedro Tammela Subject: [PATCH net-next v2 4/5] net/sched: sch_htb: warn about class in use while deleting Date: Fri, 28 Jul 2023 12:35:36 -0300 Message-Id: <20230728153537.1865379-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230728153537.1865379-1-pctammela@mojatatu.com> References: <20230728153537.1865379-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_BLOCKED,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 Add extack to warn that delete was rejected because the class is still in use Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela --- net/sched/sch_htb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 05c8291865ae..0d947414e616 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -1709,8 +1709,10 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg, * tc subsys guarantee us that in htb_destroy it holds no class * refs so that we can remove children safely there ? */ - if (cl->children || qdisc_class_in_use(&cl->common)) + if (cl->children || qdisc_class_in_use(&cl->common)) { + NL_SET_ERR_MSG(extack, "HTB class in use"); return -EBUSY; + } if (!cl->level && htb_parent_last_child(cl)) last_child = 1; From patchwork Fri Jul 28 15:35: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: 13332068 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 35A091401F for ; Fri, 28 Jul 2023 15:36:07 +0000 (UTC) Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07026B5 for ; Fri, 28 Jul 2023 08:36:07 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3a5ad6087a1so1502953b6e.2 for ; Fri, 28 Jul 2023 08:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1690558566; x=1691163366; 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=wAET9AIuuSytohoQkAuGEwlGHg61B9zRlti8aFOkjnE=; b=bu5jAoFWna8XJVFKiq5tIgZtwOfFhcRljVgjxsmKO+8kRANQZs6AgVko9K+aAAeqnm 2RktRQXrgJD10/DE+3MBootgEyeK8YHEYJGNeR7egBSdurbN+/V777mlV395hpJYKduP FQM+CiLS7kiM8aoulN9Wt60mnS36hNPzVo8ZiDmThjb0LW8f3i3EKt3XU80+2qAGZkYE gyD+Nf5dKGo8+9RygcgH96v1/ehUz0AY68l2NkaYlT02TcE3flILutLQ5gxpTx7t5SPi peKTwSAtgLi1IWyTAxlR2A4hTgO/a4fn2HzLaaGaYU/v330Ocp41o2SbB6BGroeAApDz B2TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690558566; x=1691163366; 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=wAET9AIuuSytohoQkAuGEwlGHg61B9zRlti8aFOkjnE=; b=iBmtTesQUJWeNUajvkMgfEIUMBs7hEudRrGR/u5LW93JAymFnIbVJCXt2oSREgcm2h mg9TYdBZ2VNZWY0N6pOoBSQtWydkRrmmA/XBTFAVnytVbrOh9iKHiI+P/za9B2sRYEHU qkW+ki1BUl4iNAdovOp0foqpdEZGDURchtBW9RZQmuGYKTuqCTXz07jLOv5hPMQEzERL fjoJ88+wql37sLVYw8pzkuKvvUxVRazzekgsvtfwiRrJpchgUXFqAf6elQcglT6sybxb EKV9ke7asKNBM2LJuPCsc96zNc+wDdn1QxbOz7tOGlgbtTHwvIwnusp9fACZfcDthFv+ qkVw== X-Gm-Message-State: ABy/qLa0Mp1qD5uT7d3wwB1Zh3ZP3Jocl8uX0dsszvUfPDZr5HWNlxQ+ fs7QLScgfnK+jJ2xSUm9muZ8zn04NQGKIL8A4Dk= X-Google-Smtp-Source: APBJJlE/1xvVOGg+8M3D/XznvK0xbVcDQfzNa9TRXc/GRvZ7BpebtitUSfoNh0Yhrtx3E3pxUXZS2g== X-Received: by 2002:a05:6808:1893:b0:3a3:63b8:fdc7 with SMTP id bi19-20020a056808189300b003a363b8fdc7mr3564077oib.38.1690558566249; Fri, 28 Jul 2023 08:36:06 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:81ef:7444:5901:c19d]) by smtp.gmail.com with ESMTPSA id u8-20020a544388000000b003a3b321712fsm1732893oiv.35.2023.07.28.08.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 08:36:06 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, Pedro Tammela Subject: [PATCH net-next v2 5/5] net/sched: sch_qfq: warn about class in use while deleting Date: Fri, 28 Jul 2023 12:35:37 -0300 Message-Id: <20230728153537.1865379-6-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230728153537.1865379-1-pctammela@mojatatu.com> References: <20230728153537.1865379-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_BLOCKED,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 Add extack to warn that delete was rejected because the class is still in use Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela --- net/sched/sch_qfq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index 7addc15f01b5..1a25752f1a9a 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -543,8 +543,10 @@ static int qfq_delete_class(struct Qdisc *sch, unsigned long arg, struct qfq_sched *q = qdisc_priv(sch); struct qfq_class *cl = (struct qfq_class *)arg; - if (qdisc_class_in_use(&cl->common)) + if (qdisc_class_in_use(&cl->common)) { + NL_SET_ERR_MSG_MOD(extack, "QFQ class in use"); return -EBUSY; + } sch_tree_lock(sch);