Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5100749rwd; Tue, 23 May 2023 18:29:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4I7RaSAx4lxGDft4xKRbEkQkGWwh4R5xU7CCnti2vhNmCC7at8mHd0Mn9+SZ5Jlfnzmzrh X-Received: by 2002:a05:6a21:9201:b0:106:4e09:151f with SMTP id tl1-20020a056a21920100b001064e09151fmr14001398pzb.60.1684891788667; Tue, 23 May 2023 18:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684891788; cv=none; d=google.com; s=arc-20160816; b=uVpGsfrl22NbDzVNGrLmej2YekepBtruOEY0ufrsdvOcwSRBW+EqZPEld+kYp69ufA Yj1b1Rc6BRByzF5nEJCGY/D1irve8kbh6sS8/dtSu8kKiL1LqzaC9t03Zjy/WbGSHIbW QVH17QeAMJcnVWj3W5ToTiVIHUYJ+tf6T8WMhJfqlZeSk5TPD8mku8O6cnf9BQ9GukYG EUIpC3BgLTUSe5gmMIsJgy6QBKk13qW1Sq/ppAGo6EGiv5m6GnVk55lvTcgbuaEfNsFL RiFIVYKC8v0C+8UEjun0HE7oZ7i/4/08TVjOxmVcNUlKK4GqIqom8DLcJzmuE1I4pROu B3Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TJv/Mw0cjZxSPI53855B262nqFR1u1C+NNKjhLR5zAc=; b=e4pTRH5OxhTik1l9chaogNnTeHaDT9L6anByuyFp+gx7pBAihvHHcuJNYheQ2Nr+nZ wrUbmGPB5RYoehx8/rjcJGl27JTW0mAThZolL7gD5L/bkSeYuZM3ib9pMU+U3MTOc316 7fI67/hPWHGh5p28VmzTtpwHChOa/qBsS0LT2FVuAr/P6s13N6X1dMH781stC4E6ROk3 NfcdW5QaQEHMfZ9xSh03kLRLuFcnH5f0l7+GTLTknVn0b4cGTktSHFn8puIkaRCFv22+ J/lohcLHyfZP0dqat/KU2tFtwDOmysIiDREK20bQkfUohsUnUwSFLra7zkqCzS+OlVY+ 3raw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=bHh2xG4v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv63-20020a632e42000000b0053059dfafe4si3021725pgb.86.2023.05.23.18.29.33; Tue, 23 May 2023 18:29:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=bHh2xG4v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237665AbjEXBTD (ORCPT + 99 others); Tue, 23 May 2023 21:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbjEXBTC (ORCPT ); Tue, 23 May 2023 21:19:02 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02C06E5; Tue, 23 May 2023 18:19:00 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-75affb4d0f9so49323085a.2; Tue, 23 May 2023 18:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684891140; x=1687483140; 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=TJv/Mw0cjZxSPI53855B262nqFR1u1C+NNKjhLR5zAc=; b=bHh2xG4vMLwDfNkJoMtqyCOK1LyFyld0lllv/VgIUkukjyDA+3SoBce0g0B/7yUrV3 a0NeiyWiF8xzqkzj2yCXi5XGoukztOJQjPKDJN47yZOBHkkdWZtSVIAOm3rw3dH5Bl1b Un1LlbsPAPrZm4FlKCbnIwLloVEKU0CDgmYXjLuVs6jI2Bef5IErYLRdZ7TFBDLAC4+h vn0cTwa3oOvHw+7yaYCnj/DiQiJizfg4GiPvHZ8nIPSs3b/EYMuuTor9mWI1w6NZV+Is Uex0+ruJrQfU9FvCu0g1Yy9+KLo6ZNpxNnlAec+Okm9RrLAh0K9izme21sMpzGlRn5qe gqtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684891140; x=1687483140; 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=TJv/Mw0cjZxSPI53855B262nqFR1u1C+NNKjhLR5zAc=; b=d2vUx0sQSHgujYZE12HEhxOV1wH/am9cYigjWKJNLUNBIpkR0F62kU+SDjsPO+4laN I04VHWtgcdL2zJzRzZiJEQHHmuJmiPeBuQJbioLNZMM1RCc3vSVlViuX4iknKaaD23kU Hxipj5Q9tiEsbnTyTYq/aD220mpIVpO6wSE8BQ0rtym03bK51DjvXg88fz5FO0sA8Fhl 6g8+dSno+ScnQWI69ZxvAmrC+9Z4ihJOENb+1tX5ZE+rpBpAhnPxeoFqmcOb1zbTpLkK K8qysq8lumu971GYbkM03zfN5qEskPvGuSTS+PTwpcsAYhQFc85UEhdDPUblzoGohFuP ajCA== X-Gm-Message-State: AC+VfDz/AmDuBxQE0rU+n6dDJJcqXfsaIv5X0/VvdHJF/ibuwcHbPt0p axYeNoUTVPzpGr1wog57rg== X-Received: by 2002:a05:620a:a9b:b0:75b:23a0:e7df with SMTP id v27-20020a05620a0a9b00b0075b23a0e7dfmr6174329qkg.64.1684891139934; Tue, 23 May 2023 18:18:59 -0700 (PDT) Received: from C02FL77VMD6R.bytedance.net ([2600:1700:d860:12b0:c32:b55:eaec:a556]) by smtp.gmail.com with ESMTPSA id ow21-20020a05620a821500b0074636e35405sm2913190qkn.65.2023.05.23.18.18.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 May 2023 18:18:59 -0700 (PDT) From: Peilin Ye X-Google-Original-From: Peilin Ye To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: Peilin Ye , Daniel Borkmann , John Fastabend , Vlad Buslov , Pedro Tammela , Hillf Danton , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang , Peilin Ye Subject: [PATCH v5 net 2/6] net/sched: sch_clsact: Only create under TC_H_CLSACT Date: Tue, 23 May 2023 18:18:35 -0700 Message-Id: <0c07bd5b72c67a2edf126cd2c6a9daadddb3ca95.1684887977.git.peilin.ye@bytedance.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peilin Ye clsact Qdiscs are only supposed to be created under TC_H_CLSACT (which equals TC_H_INGRESS). Return -EOPNOTSUPP if 'parent' is not TC_H_CLSACT. Fixes: 1f211a1b929c ("net, sched: add clsact qdisc") Signed-off-by: Peilin Ye --- change in v5: - avoid underflowing @egress_needed_key in ->destroy(), reported by Pedro change in v3, v4: - add in-body From: tag net/sched/sch_ingress.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c index f9ef6deb2770..35963929e117 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c @@ -225,6 +225,9 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt, struct net_device *dev = qdisc_dev(sch); int err; + if (sch->parent != TC_H_CLSACT) + return -EOPNOTSUPP; + net_inc_ingress_queue(); net_inc_egress_queue(); @@ -254,6 +257,9 @@ static void clsact_destroy(struct Qdisc *sch) { struct clsact_sched_data *q = qdisc_priv(sch); + if (sch->parent != TC_H_CLSACT) + return; + tcf_block_put_ext(q->egress_block, sch, &q->egress_block_info); tcf_block_put_ext(q->ingress_block, sch, &q->ingress_block_info); -- 2.20.1