Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2095052ybl; Thu, 30 Jan 2020 11:16:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzxDg4Gz7sAxovrGSPI9zcL6XAKQgNE/JTXVzwdhnh44EWQAuF6LmHdrtWtSBs/Z4+M0FMR X-Received: by 2002:a9d:588c:: with SMTP id x12mr4681164otg.2.1580411759829; Thu, 30 Jan 2020 11:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411759; cv=none; d=google.com; s=arc-20160816; b=Z3JqqKNH/uWojyt0bLq62vq7iOihm7w+4Vbum5s8+36hWJ2KKJ8JcvNtJsgMY4Vf3U /5IlRYOC54YTXFKJS5atc0Zahmt2W9BvcioEUfzNq+wxk1NnVMi/mZt+VMco24RnA9NM xQ67YXlg6Ek7S3DJdTKU3oU+oQolftoD8M1ISWF2pReADMC1oa+cvYFzyoYLtslXXmTl DdyOZHkD/rN+hEh/WnihcD9pEdJB7iiUK2XU7UZA6MKlVKAS/DUj6lx3r+yWlBBq/qjH cEleZlSYzkHta7doYCOPzHhuXzhHFrvGEMZ+CbQAJEgmkelvtPO3J42opY8ZeR7zdpoY g++w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PHxEonA564V80RvM28aQ/X3/WUkL8cOlnQcgIwHbaAw=; b=xXN47FxR2LGBPADkEsRdkbu9nvmSnDU8g2SuScyCQDTCOujVo3CkxJ8ZSGzgKd6M3c yJyaqUg6tba13Js39dN27B+1pWBUr6O81Yuq/mnYojvrYllx20n7RKnAgJOFqy65SfBJ ZtrUR7Wz/4v3nGQUW2pbMl6YEx7lKsEiYoJhjxM2YlMYylcXiTishWFr0h7LNAm8EO07 muHcuGxxWugTHfhIV2EAWazLM3RYcpFMdQ4U4DgYo62eeEtiYou/bRi2AKyZ1yf03USH 3P4mdLFhQtSndnUABfAb/vln+pNRHi5VG93k3ju4y7yVRCf8oEHyCz8m30NrM/FuO1kq WkWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cOieot0H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c20si3016127oic.113.2020.01.30.11.15.48; Thu, 30 Jan 2020 11:15:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cOieot0H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730269AbgA3Slz (ORCPT + 99 others); Thu, 30 Jan 2020 13:41:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:49950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730256AbgA3Slx (ORCPT ); Thu, 30 Jan 2020 13:41:53 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6E7F4205F4; Thu, 30 Jan 2020 18:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409712; bh=4r41XwWnQLvKXg6Y4MxWnONC3/blYPnIxwt0j11V8nQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cOieot0HK/WhKxQ2ujirlVSwQd0NzEzSvjaFLR18lVUcsAWfwfBfcUKZUEudhpBIs 1Y7YeCzENR0HywEEI9/tng2iK7fFwO/Y9b5ZQUJzI7jeXXWsFK159JuUAK/29ASGGI EUX+W7nT/lvC+ndo8EW3eFxQKjPhWGAs5p1TqiyU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jamal Hadi Salim , Jiri Pirko , Cong Wang , "David S. Miller" Subject: [PATCH 5.5 39/56] net_sched: walk through all child classes in tc_bind_tclass() Date: Thu, 30 Jan 2020 19:38:56 +0100 Message-Id: <20200130183616.136744409@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183608.849023566@linuxfoundation.org> References: <20200130183608.849023566@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cong Wang [ Upstream commit 760d228e322e99cdf6d81b4b60a268b8f13cf67a ] In a complex TC class hierarchy like this: tc qdisc add dev eth0 root handle 1:0 cbq bandwidth 100Mbit \ avpkt 1000 cell 8 tc class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 100Mbit \ rate 6Mbit weight 0.6Mbit prio 8 allot 1514 cell 8 maxburst 20 \ avpkt 1000 bounded tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip \ sport 80 0xffff flowid 1:3 tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip \ sport 25 0xffff flowid 1:4 tc class add dev eth0 parent 1:1 classid 1:3 cbq bandwidth 100Mbit \ rate 5Mbit weight 0.5Mbit prio 5 allot 1514 cell 8 maxburst 20 \ avpkt 1000 tc class add dev eth0 parent 1:1 classid 1:4 cbq bandwidth 100Mbit \ rate 3Mbit weight 0.3Mbit prio 5 allot 1514 cell 8 maxburst 20 \ avpkt 1000 where filters are installed on qdisc 1:0, so we can't merely search from class 1:1 when creating class 1:3 and class 1:4. We have to walk through all the child classes of the direct parent qdisc. Otherwise we would miss filters those need reverse binding. Fixes: 07d79fc7d94e ("net_sched: add reverse binding for tc class") Cc: Jamal Hadi Salim Cc: Jiri Pirko Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_api.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1910,22 +1910,24 @@ static int tcf_node_bind(struct tcf_prot return 0; } -static void tc_bind_tclass(struct Qdisc *q, u32 portid, u32 clid, - unsigned long new_cl) +struct tc_bind_class_args { + struct qdisc_walker w; + unsigned long new_cl; + u32 portid; + u32 clid; +}; + +static int tc_bind_class_walker(struct Qdisc *q, unsigned long cl, + struct qdisc_walker *w) { + struct tc_bind_class_args *a = (struct tc_bind_class_args *)w; const struct Qdisc_class_ops *cops = q->ops->cl_ops; struct tcf_block *block; struct tcf_chain *chain; - unsigned long cl; - cl = cops->find(q, portid); - if (!cl) - return; - if (!cops->tcf_block) - return; block = cops->tcf_block(q, cl, NULL); if (!block) - return; + return 0; for (chain = tcf_get_next_chain(block, NULL); chain; chain = tcf_get_next_chain(block, chain)) { @@ -1936,12 +1938,29 @@ static void tc_bind_tclass(struct Qdisc struct tcf_bind_args arg = {}; arg.w.fn = tcf_node_bind; - arg.classid = clid; + arg.classid = a->clid; arg.base = cl; - arg.cl = new_cl; + arg.cl = a->new_cl; tp->ops->walk(tp, &arg.w, true); } } + + return 0; +} + +static void tc_bind_tclass(struct Qdisc *q, u32 portid, u32 clid, + unsigned long new_cl) +{ + const struct Qdisc_class_ops *cops = q->ops->cl_ops; + struct tc_bind_class_args args = {}; + + if (!cops->tcf_block) + return; + args.portid = portid; + args.clid = clid; + args.new_cl = new_cl; + args.w.fn = tc_bind_class_walker; + q->ops->cl_ops->walk(q, &args.w); } #else