From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 943877487 for ; Thu, 28 Dec 2023 11:50:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=idosch.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=idosch.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="K/c2lISJ" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 9526B5C010C; Thu, 28 Dec 2023 06:50:32 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 28 Dec 2023 06:50:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1703764232; x=1703850632; bh=5Tz+ddZhvIe/ipoqLbMxzYrK7vLl U9qHLQSpyFNKa/8=; b=K/c2lISJUFM8RTWb7gR5AwhUweZ/kKznDgCnaHMd0ZI0 g+TeBlCrKf+sct9qQkQIBfmQV6DFFOQixHnHzqqzUyj0kPTN0v/wvu9IjhV0vJp9 X4xsO8VTh4YldvWaVguWGTEgnVkMyFMvPWZdSEFx73nPZX1Jh0/fqwsSkftsodig mWyHy/1qW/adELPmmPmKzVsehKn76rv+5BGEOrmO4ZnZhO+p0TzeuD679SqxrH8h 3flig/T/FiwGcVo26NYKUL8cQrpKxy6d+jtS2vMrEDtLi0R7eFIqQwXA0q4+HjS+ sR9+WQntAAEuv8wmjQ2qi/dQG6J55KqD3oN1aDiRiQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdefuddgfeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepkfguohcu ufgthhhimhhmvghluceoihguohhstghhsehiughoshgthhdrohhrgheqnecuggftrfgrth htvghrnhepvddufeevkeehueegfedtvdevfefgudeifeduieefgfelkeehgeelgeejjeeg gefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih guohhstghhsehiughoshgthhdrohhrgh X-ME-Proxy: Feedback-ID: i494840e7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 28 Dec 2023 06:50:31 -0500 (EST) Date: Thu, 28 Dec 2023 13:50:29 +0200 From: Ido Schimmel To: Victor Nogueira Cc: jhs@mojatatu.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, mleitner@redhat.com, vladbu@nvidia.com, paulb@nvidia.com, pctammela@mojatatu.com, netdev@vger.kernel.org, kernel@mojatatu.com Subject: Re: [PATCH net-next v8 1/5] net/sched: Introduce tc block netdev tracking infra Message-ID: References: <20231219181623.3845083-1-victor@mojatatu.com> <20231219181623.3845083-2-victor@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231219181623.3845083-2-victor@mojatatu.com> On Tue, Dec 19, 2023 at 03:16:19PM -0300, Victor Nogueira wrote: > +static int qdisc_block_add_dev(struct Qdisc *sch, struct net_device *dev, > + struct netlink_ext_ack *extack) > +{ > + const struct Qdisc_class_ops *cl_ops = sch->ops->cl_ops; > + struct tcf_block *block; > + int err; > + > + block = cl_ops->tcf_block(sch, TC_H_MIN_INGRESS, NULL); Another problem, shouldn't there be a check that these operations are actually implemented? The following now crashes with a NULL pointer dereference: # tc qdisc replace dev swp1 root handle 1: tbf rate 1Mbit burst 256k limit 1M > + if (block) { > + err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL); > + if (err) { > + NL_SET_ERR_MSG(extack, > + "ingress block dev insert failed"); > + return err; > + } > + } > + > + block = cl_ops->tcf_block(sch, TC_H_MIN_EGRESS, NULL); > + if (block) { > + err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL); > + if (err) { > + NL_SET_ERR_MSG(extack, > + "Egress block dev insert failed"); > + goto err_out; > + } > + } > + > + return 0; > + > +err_out: > + block = cl_ops->tcf_block(sch, TC_H_MIN_INGRESS, NULL); > + if (block) > + xa_erase(&block->ports, dev->ifindex); > + > + return err; > +} > + > static int qdisc_block_indexes_set(struct Qdisc *sch, struct nlattr **tca, > struct netlink_ext_ack *extack) > { > @@ -1350,6 +1387,10 @@ static struct Qdisc *qdisc_create(struct net_device *dev, > qdisc_hash_add(sch, false); > trace_qdisc_create(ops, dev, parent); > > + err = qdisc_block_add_dev(sch, dev, extack); > + if (err) > + goto err_out4; > + > return sch; > > err_out4: