Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3953252rwd; Tue, 23 May 2023 00:31:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4HAJk7xIyeZlAEOWgwnA8gIXxt1mKeAIaLjeEBo3ZTXf/j0gcYeGe8QyOox+ORStG+UbOD X-Received: by 2002:a17:902:b48f:b0:1a8:1c9a:f68 with SMTP id y15-20020a170902b48f00b001a81c9a0f68mr11847372plr.36.1684827065236; Tue, 23 May 2023 00:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684827065; cv=none; d=google.com; s=arc-20160816; b=XLBzJ7nV6t7OjIcjZMdV/b/BaZsdhULcY6l0jYvIxwqsm6+tj82u2dyXyipzm7VoGp sfguijtbjbhaABQGVPoxxjRb4eq/2HpNMd0aCcht9R8Kgxk0GNCOgJRFBb7bgdUu36H1 o9GvTvf1et89Uy4wp8xudfCLYWMAqJ6dFwGeXyGeOJtlmhpX7CpmpFRp+6vrCRDEzQlJ s+REBttBsuhSNgw6tnX4P2vKnCvAJNg2TssLKLjW+5s9599GXlDfu3uuFaKF4acWgOfh Wzph/C292f3OcYizH7xLfb5jinh96Et5SJTZDEOrII4x1+9g8wIphw19oz8yVfkQz/S0 E9rg== 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=563KIW1CbzbOZG9uSI1EL/wqRfnJk9ZwfZaE6UMFES0=; b=lScS8rLGglaXRi/NSQXsTT0cnFvvCdM9w9Ce1lcXjMKP6EyhsXNnsvp5+FeKnEkTiR nLyrFyIF02IMchJna2sejS2Jj9HSA2iVKasKeSJDA4o8fbch7JFTOgdXLKIG6CL+b4kk wzW38Vi5QA60PmXRHTCeyfjkoEt8FwzBbfKzpiypgZ04JlyGdngR3clA/2DUOhpxFA1A iw8REuworW/x3jMdtxpsfKm5G2eIHL8ehGOkF/8WJuW0ycckl06ym2aXlcZ/aecmcZQh jgpUHnAJo+rzh/UfTOpW53AUW4A5WO330sY/r5oofmV1RUMOD/xzwXwntOOaq0GYnsmO N9Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mn4z2tVM; 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 li12-20020a170903294c00b001ab1b0c5b21si3397891plb.5.2023.05.23.00.30.50; Tue, 23 May 2023 00:31:05 -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=mn4z2tVM; 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 S235390AbjEWHPk (ORCPT + 99 others); Tue, 23 May 2023 03:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234429AbjEWHPf (ORCPT ); Tue, 23 May 2023 03:15:35 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 370EA120; Tue, 23 May 2023 00:15:34 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-75b08ceddd1so223432385a.1; Tue, 23 May 2023 00:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684826133; x=1687418133; 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=563KIW1CbzbOZG9uSI1EL/wqRfnJk9ZwfZaE6UMFES0=; b=mn4z2tVM//02hqXXjrXG9gO1+9fntZx7Pztl6I3viEgASGZw9b/LDeZrBjwRpDH+y0 vydlCZlOECuydOBQ0EF2Hnvqua1k3BcF5B0vkgkleDs6iiJjHJtqcYXZK1N0io/1CxO1 7rtnufvF3wKI4o2xk5m3KnFnWpGK8MqDVJwt1CAGCEPHzoOCP999/P7VUpB35kLyuZZa jkMtpzQTJFLqmKiqv8EfbSwI1oYn5nLUkR3zaCkT/lj4ZwXIpS1ejlGHI/53v3LkCumB eXYaygFCQV7wBWOvDCSUKVwGC8xAj+WZeVLaQaLz57U9bah0Ee0s7O/mIDIx4XuPklPh ZPrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684826133; x=1687418133; 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=563KIW1CbzbOZG9uSI1EL/wqRfnJk9ZwfZaE6UMFES0=; b=baje/lPfisOUOiXTFdcqC8av6XtElSTf+0ytywAboOe2Ijgd38+J+qlJ9LDfEMv+WE /D9kJT4DubiqyU6cub5yFX3MxiF6JFS+IoN9mEQOfmAJRbmQsxIwSHH+QV2G8k2aIXmH 3TgXuFRph8d2DPl6gA2HK0Zykw13wSphxbjHE7XTYYUEBieNsyOqrscz5NP52pVbyumk yUUzuGVO+4HBfCKMJolHW8iMkM9/J4A38N1xby8CnFLjO7nEUeulNu6+zvTiRBnjs2U6 cvsHN1HVbd7c6u/nH+xn2LArvZZriaFkbyC/qmbLWx7RA/wNzyuQGxjMjNrEVUNKvrCz tg/w== X-Gm-Message-State: AC+VfDyNgDFyt6FrmeJdJkXPpotRu3KPApmqLAEJmjx23cnoSmtUjAbH BJFwV5fMy1+NA9e8uKFLQw== X-Received: by 2002:a05:620a:8a05:b0:75b:23a0:de84 with SMTP id qt5-20020a05620a8a0500b0075b23a0de84mr2969184qkn.2.1684826133352; Tue, 23 May 2023 00:15:33 -0700 (PDT) Received: from C02FL77VMD6R.bytedance.net ([2600:1700:d860:12b0:18c1:dc19:5e29:e9a0]) by smtp.gmail.com with ESMTPSA id m9-20020ae9e709000000b0074e21136a77sm2292040qka.127.2023.05.23.00.15.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 May 2023 00:15:33 -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 v4 net 3/6] net/sched: Reserve TC_H_INGRESS (TC_H_CLSACT) for ingress (clsact) Qdiscs Date: Tue, 23 May 2023 00:14:57 -0700 Message-Id: <5e55909fafc7afcde9b7795d39dac0d10f5f45da.1684825171.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 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 Acked-by: Jamal Hadi Salim Signed-off-by: Peilin Ye --- change since v2: - 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 13218a1fe4a5..caea51e0d4e9 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c @@ -137,7 +137,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, @@ -275,7 +275,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, -- 2.20.1