Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4216199rwr; Mon, 8 May 2023 04:53:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4FrYhKmkpCca54aEsmzmuB0xYbQPc2p7sBeXDyEIrQhPAEEb5gnT8uPmDG4epYE9XKGjQV X-Received: by 2002:a17:902:b184:b0:1ac:6c46:8c70 with SMTP id s4-20020a170902b18400b001ac6c468c70mr4215933plr.9.1683546803079; Mon, 08 May 2023 04:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683546803; cv=none; d=google.com; s=arc-20160816; b=M//Bk3dyWs/fnALfRBMa1ETzuNqJG45tisTZDfy22d3E2IHMfnSJ/+CFxlvHrRYeYr erzDq4OdQ1ARo9V1NA2pgOxeNcmo2nzcnurnve0rxA7nVufb8djd3thfMIxnSZATYjTV lzIun7Kj55pm8ybJrs5Q6mgu/jFNTlrResPad+U35Rj8VysKV1Wlnsan9SRi/Z8WJ6kG Lbbd+LEePiduA32tRySiws5DdHOpLmz+66Q357nDgn2XUA5hew6X00SfRQta/vLq5Eo+ LPeqKXOtONYJz+ZvAbX1B9WjaePW7vDWwqmQjee46sAsA/rNVriINPuiRt8J586y7xMa SUqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=OIGhf3eRAjihUJXQEWIYc02wnTiI4XPwL0ihUb83Waw=; b=aJ+9uVT7O5huNUoY/D77pr9Xi3OxGAMr7OIaVvqF0WrUu5SoMSOnbiPoJjefYgGyR+ cXMLt4op3yQqHiJukUSeZsQ0BtmqCg2g6NchqSRvs0kUB7efMVBdQhVEB8udRJOxjX6+ mMGKa0cwQ88MKMM7XO5WBVAVEO/DksS3TCNFhmQMZei5f4Lzd1oR/0eoF/2CKzKQna/x FhVG1GJGDmjmLRimEUiRcDQorHO8FH9jAS3ObRXYuuCAACRP6Urc4vOIzFDu/ZVYHfxD GSuXa+cvVU3hgYZJTlU2CuPZoHYk859xt3KVeP6DCe+gcNWUe40R9MbeHKFuAyzqHuXg utOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mojatatu-com.20221208.gappssmtp.com header.s=20221208 header.b=OmtuiNHh; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020a170902708b00b001ac6c5900f7si150903plk.191.2023.05.08.04.53.11; Mon, 08 May 2023 04:53:23 -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=@mojatatu-com.20221208.gappssmtp.com header.s=20221208 header.b=OmtuiNHh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235701AbjEHLY6 (ORCPT + 99 others); Mon, 8 May 2023 07:24:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235681AbjEHLYl (ORCPT ); Mon, 8 May 2023 07:24:41 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B6D43A5D8 for ; Mon, 8 May 2023 04:24:37 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-ba1911d60f5so6899604276.2 for ; Mon, 08 May 2023 04:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1683545076; x=1686137076; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OIGhf3eRAjihUJXQEWIYc02wnTiI4XPwL0ihUb83Waw=; b=OmtuiNHh/0mYopJ2E3ln7anz6SL7k7OlWoQ+Jjv4kFH7ceI9OnXCKkqFmmjd7G2vV+ PfvuJUD6KWGOgRRzAkYRgLP02ubjYdYebw1QIy7OXai0nGFtS/r+7PxB1x7cdlYbppNt CSkebv+h1HWH2679CKhDW12tjbgP/7EysinpQUiDvrsPSWbeg1Qy5f2kr8Z62aeHkwi4 DXeQL8ZSTHhhuzKAXoYe94sIzYSDgEz1C0tCx00QH7ebBJJpd5HRs2Klfyzso3DZ21bh IaOFGCJrcL66d85IwuVBasel48pJpWQ2YY92NRzKgvDJEqAemaA9AF0mZQ7LS31fNRia MUKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683545076; x=1686137076; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OIGhf3eRAjihUJXQEWIYc02wnTiI4XPwL0ihUb83Waw=; b=VntQr2wCJ+4iKCKG4IFLrkTee2v2RHvAqom/rWOUudX1SOiaXwDWCRHqeEBMj2ki/t YwLrK0buSh5ZYgDoKiFjUme1Zz760XCQbDHQF1uVqoFTalAOhf4+H2fv2uO98qAoqZMn u8DmKiXm1DfHnhJmIdJivKoL74eyak6f2TGIPQ1MRkgBGQm5uBwaACG2v9pChbifGpw2 jyrdYwN5ZLQwsT30r9ahsXDj5toj2vn/qLKCTz3u7c/cWYYKwYSrHKynDQMDvAS3OQoM yaeMh94u6+r0raRnWhbnYjv3+2Skb76PUxgGfYbaX76TUpANfOy3/UuCIYy004ffO1CP E7AA== X-Gm-Message-State: AC+VfDy9saL+PEzGEa8xbxkV9pVpupa2aVfSM2KnU5yTpUNSIGgikQ9F OHqnCPDK0nwws3OnSatywWC6e+Z7DkQx8hfJYc1oSg== X-Received: by 2002:a25:6fc6:0:b0:b9e:6894:289c with SMTP id k189-20020a256fc6000000b00b9e6894289cmr9519837ybc.59.1683545076214; Mon, 08 May 2023 04:24:36 -0700 (PDT) MIME-Version: 1.0 References: <846336873bfba19914397a1656ba1eb42051ed87.1683326865.git.peilin.ye@bytedance.com> In-Reply-To: <846336873bfba19914397a1656ba1eb42051ed87.1683326865.git.peilin.ye@bytedance.com> From: Jamal Hadi Salim Date: Mon, 8 May 2023 07:24:25 -0400 Message-ID: Subject: Re: [PATCH net 4/6] net/sched: Prohibit regrafting ingress or clsact Qdiscs To: Peilin Ye Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Cong Wang , Jiri Pirko , Peilin Ye , Daniel Borkmann , John Fastabend , Vlad Buslov , Pedro Tammela , Hillf Danton , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 5, 2023 at 8:14=E2=80=AFPM Peilin Ye wr= ote: > > Currently, after creating an ingress (or clsact) Qdisc and grafting it > under TC_H_INGRESS (TC_H_CLSACT), it is possible to graft it again under > e.g. a TBF Qdisc: > > $ ip link add ifb0 type ifb > $ tc qdisc add dev ifb0 handle 1: root tbf rate 20kbit buffer 1600 limi= t 3000 > $ tc qdisc add dev ifb0 clsact > $ tc qdisc link dev ifb0 handle ffff: parent 1:1 > $ tc qdisc show dev ifb0 > qdisc tbf 1: root refcnt 2 rate 20Kbit burst 1600b lat 560.0ms > qdisc clsact ffff: parent ffff:fff1 refcnt 2 > ^^^^^^^^ > > clsact's refcount has increased: it is now grafted under both > TC_H_CLSACT and 1:1. > > ingress and clsact Qdiscs should only be used under TC_H_INGRESS > (TC_H_CLSACT). Prohibit regrafting them. > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Fixes: 1f211a1b929c ("net, sched: add clsact qdisc") > Signed-off-by: Peilin Ye Reviewed-by: Jamal Hadi Salim Acked-by: Jamal Hadi Salim cheers, jamal > --- > net/sched/sch_api.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c > index 383195955b7d..49b9c1bbfdd9 100644 > --- a/net/sched/sch_api.c > +++ b/net/sched/sch_api.c > @@ -1596,6 +1596,11 @@ static int tc_modify_qdisc(struct sk_buff *skb, st= ruct nlmsghdr *n, > NL_SET_ERR_MSG(extack, "Invalid q= disc name"); > return -EINVAL; > } > + if (q->flags & TCQ_F_INGRESS) { > + NL_SET_ERR_MSG(extack, > + "Cannot regraft in= gress or clsact Qdiscs"); > + return -EINVAL; > + } > if (q =3D=3D p || > (p && check_loop(q, p, 0))) { > NL_SET_ERR_MSG(extack, "Qdisc par= ent/child loop detected"); > -- > 2.20.1 >