From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cong Wang Subject: Re: [patch net-next v4 03/12] net: sched: introduce chain object to uapi Date: Wed, 25 Jul 2018 09:40:44 -0700 Message-ID: References: <20180723072312.4153-1-jiri@resnulli.us> <20180723072312.4153-4-jiri@resnulli.us> <20180725064645.GA2164@nanopsycho> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" 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: Jiri Pirko Return-path: Received: from mail-pl0-f49.google.com ([209.85.160.49]:36758 "EHLO mail-pl0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728653AbeGYRvN (ORCPT ); Wed, 25 Jul 2018 13:51:13 -0400 Received: by mail-pl0-f49.google.com with SMTP id e11-v6so3519203plb.3 for ; Wed, 25 Jul 2018 09:38:46 -0700 (PDT) In-Reply-To: <20180725064645.GA2164@nanopsycho> Sender: netdev-owner@vger.kernel.org List-ID: 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.