[v5,net,3/6] net/sched: Reserve TC_H_INGRESS (TC_H_CLSACT) for ingress (clsact) Qdiscs
Message ID | 9815766bb41f8413d90c14936974a528870044fa.1684887977.git.peilin.ye@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2525315vqo; Tue, 23 May 2023 18:21:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ddk8jZhRmw0eO3wAMxc66zGIKEG1idiMTv/ltyBSlS9q9nV9yHbJ1Z0DAlwcwaBITXmWN X-Received: by 2002:a05:6a20:8e13:b0:10c:2a14:a357 with SMTP id y19-20020a056a208e1300b0010c2a14a357mr6532501pzj.26.1684891269548; Tue, 23 May 2023 18:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684891269; cv=none; d=google.com; s=arc-20160816; b=JtMD8FgBwyb3i+BonjwsIFvQt7ibMDz/IJR8TD3GsnAShwZc9tEGBLVLr9eK+iG2jf Xypj3zjYzqYaV4dDk0h2x4lQgw81guKZCRFoxzXeaPyYowF3eujwGQafkQuKrw1y5YNz pwG6PKmefelW6GR+ZLMAinRm6eHSmBxdnjw6aF4Bv9wpac+pOO+wvlW7pKDl7HR+SS2w aKmCBClB4gwvps2oHs67PngODHdU6d1zW+fZWrMaW4W03uSgsSGntAVAeayGIPWONqci ud0zLMm8SXA2N26K8Ywd4qq3QaUCWsauOeCl5LZXB6G/EtmacXyGFvya8fPwljs0K6jO /MCA== 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=kk5Fbp1XDe1Iwik6nOEtU3rLxoAf3ax2ERfkaCeUvsg=; b=0jr0d41We0YhI4Lu9ekh10ILB+pEaDkV92wdI1JkAd57ZL33JIKoePFxGI+AYi3DNg 9wEKKcJBetn4vtgzAUbHL6MLx7qyq4b5UGCZqkSEKcbZKxoS+p3WEk6IL91eG7n4nG7c j6mrGdrheeO8zyJvgD0nE0XeaglHSkKCDWYK2ZDdU4X4O3RmUKvN0FMKYfps0a0CqLT6 nog1TKee09CcJc+g9zWQNEOnkaA6vsO2V56HTXHzIAhldtbHltYz0D6GqFc15CEn3/ZH ZLyfSVuNkwDLoxmyHoH5RbP+CA3zSEpjWg0QSNeEkbLVqXw7q93P3wI61ilrqspYiDOo 3wew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=OPUEswG9; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r191-20020a632bc8000000b0052cc0c1c39bsi5476204pgr.684.2023.05.23.18.20.56; Tue, 23 May 2023 18:21:09 -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=OPUEswG9; 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 S230299AbjEXBTZ (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Tue, 23 May 2023 21:19:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238867AbjEXBTX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 23 May 2023 21:19:23 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49974139; Tue, 23 May 2023 18:19:21 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id d75a77b69052e-3f6c0d651adso5380031cf.2; Tue, 23 May 2023 18:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684891160; x=1687483160; 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=kk5Fbp1XDe1Iwik6nOEtU3rLxoAf3ax2ERfkaCeUvsg=; b=OPUEswG9EUu6RwEkbOrd4uxrF/03QDQsRiIQBb/h+o4SSpw49e243AraXpmv2Y/N2v X/tr0xbtzYRrrg0+dYo14ypY3LD9P18XH/15tFFKEjyZCpTVwHlro62EhZ/xGpq3T26Y 2ZoDL5OTAw7uFvqFBqtJSCo/MZgn5LPSeOqKcu+vHFP0lAdxZw9W5gvZHtE4C6GpbSSW 3+oBQ8uoHBqVxv6sIW+C/kEQFHWh+QrmbbnWyHeCETkbNFlvxoflfSQhZspke83T2yuq RjSTp4365coJTuxm1cb4jWDEJb426TEULx4X4SrI22kWVWPCaPzLNwhEwkpKU1aZLwjw GQ6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684891160; x=1687483160; 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=kk5Fbp1XDe1Iwik6nOEtU3rLxoAf3ax2ERfkaCeUvsg=; b=MsbVaiTGfaHhxV43P1C1Osl83iav4v49sqbzJgS5SEzLUyMExrA3PkT5NIB41CdD4A 12Io25SfIz2yBexUD6JmqD2db/ZtLN8wyIRtj61tt6nikBPYbFcQjgkSxboi0zOP/YcB zCby1aQ3z4TRbQG5t6IU4eNQp/7Ud/3AcBY5bvw9inNm4h03aHB6JkVAZ1lDAoMVnMoS NB//uPKtfHMXKg75YeRv137cG6VuVctUQUOaeZvqDuaAGEd8AMohLCh8GmdJwyZGct+c /gc8MM2EZdMvpAdYdnhzF7XM9B9VIO2An3FHwbEwTZBMpIJaaqPzVJCLc8Gbe9wlcIrH DoRQ== X-Gm-Message-State: AC+VfDzWrabRkzgO2+wcdXEVK2QGeYULPLHgay9yAPXegUTRBPydUtmd vVw/A17R18odwYBmrUDsmA== X-Received: by 2002:a05:622a:1115:b0:3f5:1f9c:5b35 with SMTP id e21-20020a05622a111500b003f51f9c5b35mr25002785qty.63.1684891160401; Tue, 23 May 2023 18:19:20 -0700 (PDT) Received: from C02FL77VMD6R.bytedance.net ([2600:1700:d860:12b0:c32:b55:eaec:a556]) by smtp.gmail.com with ESMTPSA id r6-20020ac85c86000000b003f6b22de8f8sm1815119qta.91.2023.05.23.18.19.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 May 2023 18:19:20 -0700 (PDT) From: Peilin Ye <yepeilin.cs@gmail.com> X-Google-Original-From: Peilin Ye <peilin.ye@bytedance.com> To: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Jamal Hadi Salim <jhs@mojatatu.com>, Cong Wang <xiyou.wangcong@gmail.com>, Jiri Pirko <jiri@resnulli.us> Cc: Peilin Ye <peilin.ye@bytedance.com>, Daniel Borkmann <daniel@iogearbox.net>, John Fastabend <john.fastabend@gmail.com>, Vlad Buslov <vladbu@mellanox.com>, Pedro Tammela <pctammela@mojatatu.com>, Hillf Danton <hdanton@sina.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang <cong.wang@bytedance.com>, Peilin Ye <yepeilin.cs@gmail.com> Subject: [PATCH v5 net 3/6] net/sched: Reserve TC_H_INGRESS (TC_H_CLSACT) for ingress (clsact) Qdiscs Date: Tue, 23 May 2023 18:19:08 -0700 Message-Id: <9815766bb41f8413d90c14936974a528870044fa.1684887977.git.peilin.ye@bytedance.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <cover.1684887977.git.peilin.ye@bytedance.com> References: <cover.1684887977.git.peilin.ye@bytedance.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766736547716412696?= X-GMAIL-MSGID: =?utf-8?q?1766736547716412696?= |
Series |
net/sched: Fixes for sch_ingress and sch_clsact
|
|
Commit Message
Peilin Ye
May 24, 2023, 1:19 a.m. UTC
From: Peilin Ye <peilin.ye@bytedance.com> Currently it is possible to add e.g. an HTB Qdisc under ffff:fff1 (TC_H_INGRESS, TC_H_CLSACT): $ ip link add name ifb0 type ifb $ tc qdisc add dev ifb0 parent ffff:fff1 htb $ tc qdisc add dev ifb0 clsact Error: Exclusivity flag on, cannot modify. $ drgn ... >>> ifb0 = netdev_get_by_name(prog, "ifb0") >>> qdisc = ifb0.ingress_queue.qdisc_sleeping >>> print(qdisc.ops.id.string_().decode()) htb >>> qdisc.flags.value_() # TCQ_F_INGRESS 2 Only allow ingress and clsact Qdiscs under ffff:fff1. Return -EINVAL for everything else. Make TCQ_F_INGRESS a static flag of ingress and clsact Qdiscs. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Fixes: 1f211a1b929c ("net, sched: add clsact qdisc") Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Peilin Ye <peilin.ye@bytedance.com> --- change in v3, v4: - add in-body From: tag net/sched/sch_api.c | 7 ++++++- net/sched/sch_ingress.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-)
Comments
On 23/05/2023 22:19, Peilin Ye wrote: > From: Peilin Ye <peilin.ye@bytedance.com> > > Currently it is possible to add e.g. an HTB Qdisc under ffff:fff1 > (TC_H_INGRESS, TC_H_CLSACT): > > $ ip link add name ifb0 type ifb > $ tc qdisc add dev ifb0 parent ffff:fff1 htb > $ tc qdisc add dev ifb0 clsact > Error: Exclusivity flag on, cannot modify. > $ drgn > ... > >>> ifb0 = netdev_get_by_name(prog, "ifb0") > >>> qdisc = ifb0.ingress_queue.qdisc_sleeping > >>> print(qdisc.ops.id.string_().decode()) > htb > >>> qdisc.flags.value_() # TCQ_F_INGRESS > 2 > > Only allow ingress and clsact Qdiscs under ffff:fff1. Return -EINVAL > for everything else. Make TCQ_F_INGRESS a static flag of ingress and > clsact Qdiscs. > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Fixes: 1f211a1b929c ("net, sched: add clsact qdisc") > Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com> > Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> > Signed-off-by: Peilin Ye <peilin.ye@bytedance.com> Tested-by: Pedro Tammela <pctammela@mojatatu.com> > --- > change in v3, v4: > - add in-body From: tag > > net/sched/sch_api.c | 7 ++++++- > net/sched/sch_ingress.c | 4 ++-- > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c > index fdb8f429333d..383195955b7d 100644 > --- a/net/sched/sch_api.c > +++ b/net/sched/sch_api.c > @@ -1252,7 +1252,12 @@ static struct Qdisc *qdisc_create(struct net_device *dev, > sch->parent = parent; > > if (handle == TC_H_INGRESS) { > - sch->flags |= TCQ_F_INGRESS; > + if (!(sch->flags & TCQ_F_INGRESS)) { > + NL_SET_ERR_MSG(extack, > + "Specified parent ID is reserved for ingress and clsact Qdiscs"); > + err = -EINVAL; > + goto err_out3; > + } > handle = TC_H_MAKE(TC_H_INGRESS, 0); > } else { > if (handle == 0) { > diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c > index 35963929e117..e43a45499372 100644 > --- a/net/sched/sch_ingress.c > +++ b/net/sched/sch_ingress.c > @@ -140,7 +140,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = { > .cl_ops = &ingress_class_ops, > .id = "ingress", > .priv_size = sizeof(struct ingress_sched_data), > - .static_flags = TCQ_F_CPUSTATS, > + .static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS, > .init = ingress_init, > .destroy = ingress_destroy, > .dump = ingress_dump, > @@ -281,7 +281,7 @@ static struct Qdisc_ops clsact_qdisc_ops __read_mostly = { > .cl_ops = &clsact_class_ops, > .id = "clsact", > .priv_size = sizeof(struct clsact_sched_data), > - .static_flags = TCQ_F_CPUSTATS, > + .static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS, > .init = clsact_init, > .destroy = clsact_destroy, > .dump = ingress_dump,
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index fdb8f429333d..383195955b7d 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1252,7 +1252,12 @@ static struct Qdisc *qdisc_create(struct net_device *dev, sch->parent = parent; if (handle == TC_H_INGRESS) { - sch->flags |= TCQ_F_INGRESS; + if (!(sch->flags & TCQ_F_INGRESS)) { + NL_SET_ERR_MSG(extack, + "Specified parent ID is reserved for ingress and clsact Qdiscs"); + err = -EINVAL; + goto err_out3; + } handle = TC_H_MAKE(TC_H_INGRESS, 0); } else { if (handle == 0) { diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c index 35963929e117..e43a45499372 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c @@ -140,7 +140,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = { .cl_ops = &ingress_class_ops, .id = "ingress", .priv_size = sizeof(struct ingress_sched_data), - .static_flags = TCQ_F_CPUSTATS, + .static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS, .init = ingress_init, .destroy = ingress_destroy, .dump = ingress_dump, @@ -281,7 +281,7 @@ static struct Qdisc_ops clsact_qdisc_ops __read_mostly = { .cl_ops = &clsact_class_ops, .id = "clsact", .priv_size = sizeof(struct clsact_sched_data), - .static_flags = TCQ_F_CPUSTATS, + .static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS, .init = clsact_init, .destroy = clsact_destroy, .dump = ingress_dump,