Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2096190ybl; Thu, 30 Jan 2020 11:17:15 -0800 (PST) X-Google-Smtp-Source: APXvYqysHRwJp8qaGYaBNnyXdjDzDMhYXdhMJS4j/T/2MDDm+FY01+CQDyOsxhE1JjhEwkmc/892 X-Received: by 2002:aca:56ce:: with SMTP id k197mr4076416oib.99.1580411835004; Thu, 30 Jan 2020 11:17:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411834; cv=none; d=google.com; s=arc-20160816; b=D9Nxwl+fboT0N+IU6arSzou+G/hqbJfcG6QPJO6qX6lD7+K+IgAU9r4iSvFMmTsL7c nL/Jggh1er9YYDp0dYxppcoxq0hWbQRmeEe3sCUmK2KWYB9dFebUMaM2LVdde56Sth/y 51ijGO7vnJpOTF6UbV2F+m970WY5JDyUEiL9wYVNAj5MpTIrDjkUZc8txK4M8TnUkJ5R kdwcOXZQ8QvNPY0S+hCiJKtY24GQAKxZYyTMHoP9UOvmO63Dj1vmbaTiqSzTIivl1hy6 7ZiYKOEeiwUy3t88QAtcD2aWoZMyeNI1djkcoNIiHgnR/1nmRo1O68OLF8zr6zMKBXMc 3Oow== 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=L/bTOtyzb+7qoxWsNu68KNniuYF+AaPTMy+NYvrwVH2A3wI08CmuRSNoaxxHTL3rxV h96EFdrFnzxOLtjPilV7JZYt9C/FUvpxT6IBoJB3evqCIsmuGiqWZOzBtn4bpgJ64cML ob2QicHu0SnU1pfvu4AsIUBlwwRtNQ1TnEGEwv+Ajxl5iDolUWU3jHgJySjC3WUHEWle 7+a1Y/8SmclDfwy/eyDjP6rz0zuCsnqjpdx3dpNEl7dpqjTXTzRcD50ybhYU76pUwEPX bhunHG1BigCR4J8cPzFK79hg1L6SIfYsw3DeeG8fcctSl+DGZWLd9jLFwImh7x5hsNWj BO7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="b/WIenSW"; 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 a13si3595994otq.201.2020.01.30.11.17.02; Thu, 30 Jan 2020 11:17:14 -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="b/WIenSW"; 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 S1730609AbgA3SnZ (ORCPT + 99 others); Thu, 30 Jan 2020 13:43:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:52020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730206AbgA3SnW (ORCPT ); Thu, 30 Jan 2020 13:43:22 -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 8BA2B20702; Thu, 30 Jan 2020 18:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409802; bh=4r41XwWnQLvKXg6Y4MxWnONC3/blYPnIxwt0j11V8nQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b/WIenSWuemwcJHUXZaXcguTfvQTa1Q0BOmkCCUjUpLMN1Uhzytogj0vnf9dHL4fC dzKl+gwoMqyASXreUNu4PtwXzojUBZ+pawXJraEGMCZtHc3a6HaVTpD+ldk01Kq/SP qe/dY2SD6ciqrnh1qhxjSa5zxTo0xDRlvaDsguE0= 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.4 037/110] net_sched: walk through all child classes in tc_bind_tclass() Date: Thu, 30 Jan 2020 19:38:13 +0100 Message-Id: <20200130183619.765651904@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@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