From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Pirko Subject: Re: [patch net-next v4 03/12] net: sched: introduce chain object to uapi Date: Thu, 26 Jul 2018 14:27:45 +0200 Message-ID: <20180726122745.GH2222@nanopsycho> References: <20180723072312.4153-1-jiri@resnulli.us> <20180723072312.4153-4-jiri@resnulli.us> <20180725064645.GA2164@nanopsycho> <20180726073839.GB2222@nanopsycho> <20180726100614.GF2222@nanopsycho> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Linux Kernel Network Developers , David Miller , Jamal Hadi Salim , Jakub Kicinski , Simon Horman , john.hurley@netronome.com, David Ahern , mlxsw@mellanox.com, sridhar.samudrala@intel.com To: Cong Wang Return-path: Received: from mail-wr1-f67.google.com ([209.85.221.67]:45664 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729948AbeGZNqx (ORCPT ); Thu, 26 Jul 2018 09:46:53 -0400 Received: by mail-wr1-f67.google.com with SMTP id t13-v6so1527594wrv.12 for ; Thu, 26 Jul 2018 05:30:14 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20180726100614.GF2222@nanopsycho> Sender: netdev-owner@vger.kernel.org List-ID: Thu, Jul 26, 2018 at 12:06:14PM CEST, jiri@resnulli.us wrote: >Thu, Jul 26, 2018 at 09:38:39AM CEST, jiri@resnulli.us wrote: >>Wed, Jul 25, 2018 at 06:40:44PM CEST, xiyou.wangcong@gmail.com wrote: >>>On Tue, Jul 24, 2018 at 11:49 PM Jiri Pirko wrote: >>>> >>>> Wed, Jul 25, 2018 at 01:20:08AM CEST, xiyou.wangcong@gmail.com wrote: >>>> >So, you only send out notification when the last refcnt is gone. >>>> > >>>> >If the chain that is being deleted by a user is still used by an action, >>>> >you return 0 or -EPERM? >>>> >>>> 0 and the chain stays there until the action is removed. Hmm, do you thing >>>> that -EPERM should be returned in that case? The thing is, we have to >>>> flush the chain in order to see the action references are there. We would >>>> have to have 2 ref counters, one for filter, one for actions. >>>> What do you think? >>> >>>_If_ RTM_DELCHAIN does decrease the chain refcnt, then it is >>>broken: >>> >>># tc chain add X... (refcnt == 1) >>># tc action add ... goto chain X (refcnt==2) >>># tc chain del X ... (refcnt== 1) >>># tc chain del X ... (refcnt==0) >>> >>>RTM_DELCHAIN should just test if refcnt is 1, if it is, delete it, >>>otherwise return -EPERM. This is how we handle tc standalone >>>actions, see tcf_idr_delete_index(). >>> >>>Yes, you might need two refcnt's here. >> >>Okay. Sounds good. I'm on it. > >Actually, I found an issue. The action to "goto chain" might be attached >to a filter in the same chain. That is completely legitimate usage. >When I do: ># tc chain del X >I expect the chain to be flushed and removed. If there is an action >there with "goto" to the same chain, the command should be successful. >However, I don't see any easy way to find out if the chain is referenced >only by actions used by filters in the same chain :/ > >Thoughts? I'm now working on a patch that would treat empty chains implicitly created or deleted by user that only are referenced by action as a zombie ones. They won't be visible on dump. User won't know about them, they would only serve as a place holder for "goto chain" actions. I think it is reasonable. What do you think. Will send the RFC in few hours. >