Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4647471imm; Mon, 14 May 2018 10:30:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo0BhtODd6MxIWqktyeCXUnF/Z1bX7TA8+JUnRE3hwU3qw3dXa5+NbxCXAy0zeFoFTPKmw4 X-Received: by 2002:a62:e0cf:: with SMTP id d76-v6mr11462379pfm.52.1526319017811; Mon, 14 May 2018 10:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526319017; cv=none; d=google.com; s=arc-20160816; b=t65wN4R5LG1eiYNCI99Z3sn+qlFGi1fOyEWj5N++QF+BXnzaJOZI5+dvLwAzkPfZK7 o+kvyaZcRHYzUy7UQ/aaAyVW3W8oeUqdjkSDFDrrFY3nFjqS3XL1LcIrjteeohzBsWGA P32vnCVpb7s192XRHBBW7KCrWQzzzXr0G0qpnaXR1ew7LkED742QcDcdI+k5RbyTLwmo 9u5vrPdTsQkadlz4mG8mf+gvB7bmGlfAHiTf3LyFzr8Tx0p3Vq8YSuXrdaosN6L/PR3Q 32Coplebya5pGbcodOwikApWo5EGWG6L9En+yfQhCxq/EqC9DeS8M06R2fKs7c0hMa0B h0Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=xIBdDLFuyVgGZV3bueTzRpxUVbXemL0JipzEqC/kxmg=; b=yuu5GbbI3AlRmsW0BeXhvb22oIwqG6hbCoxOgu/VMD2yOwCG+UYE3Iqxh5ipmeLMQT TV5tdR39lZWWtpy6D/Fvaq9v+gEEwI19I/3IJ9FYQYS3d9U3siFHeHwhpseD0U5VIRNt EffqDmQMBA1hEps7BhzIBK/yFeB5Xpf6aiPYjVuJQLLy04k1rjX6JLRefLHiEQOpqwTs JX7pJNt+VR04BhB03SKH9AzpnQtAsFO/dRg6z1EnEz9+j2PJFAb+lBdB7NGmp1DXFXp6 3tVb6oZQOWN4SV7KwKJSVJuT4UC/zSUgBEirrF3PY2BvgcrQgymf0K4Utc35UV2UPnl4 1w0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=ybQPFAtU; 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 92-v6si9250832plw.299.2018.05.14.10.30.02; Mon, 14 May 2018 10:30:17 -0700 (PDT) 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=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=ybQPFAtU; 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 S1753624AbeENQr5 (ORCPT + 99 others); Mon, 14 May 2018 12:47:57 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:34680 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753468AbeENQrz (ORCPT ); Mon, 14 May 2018 12:47:55 -0400 Received: by mail-wr0-f194.google.com with SMTP id p18-v6so13080752wrm.1 for ; Mon, 14 May 2018 09:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xIBdDLFuyVgGZV3bueTzRpxUVbXemL0JipzEqC/kxmg=; b=ybQPFAtUxlsRApw9DiEa0aqC6ixPC4Uu2Cwi0M900eyhmSrFpckjL9dNwHgfLUCx80 OPU+luItZ+T7b2gkA83idc3/wX8uZoOb/kbxi6zrMTKmCje1rAyXMyEu4WaWvVvctdKx hGA9HCmlUBPUkZg7XepLtuWhvW9ENp07KhTwy+1YOuBleA+az4sF4Mujl08PNa7QG3EB yh1U6BKFfKokKZjnWr1AzX06fexUeV37QhezlAK2RXzEnMmeAnfUjPhDQrQTn+qsb4EI m35+nFCM5kTONcjrycxdo+xc5EDerYAOONge3A9tIzrBpiYCaRXA5OQ51XKSL44D7hw7 miCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xIBdDLFuyVgGZV3bueTzRpxUVbXemL0JipzEqC/kxmg=; b=YFL97SDLhVjVLzLlTU82rXSsIDOSimGAJxHEWc/uRExu7jUnEY9EKvJIQGQUQEx3KU krLmetMAzdNcekXi+B9Nw3WGdkGi6cPahZvoWLK15Gy2ZUekEFIMSfgiCnt2uwxY1j80 7n5E73MThYbA641B5WvREOWjp7u90zvzuij7sqbeDuBWcdQ+mzl352MEGqw6dD9hUa+G 7IXTJSGhfOcuaVGxfHNAtawq10gOf14qvZb6HxFk9LtFXX0GuEOOWEgSKBKH3BOdBTrG Dd+jA5GXn8VysisjxLvpKnwCs3RhjegN/NbfhOpXYrRpBuFPyRqL4uc3xUQ2Q0421qXc iajQ== X-Gm-Message-State: ALKqPwfVdYNwpRpgj6vDjwAwukTJM5azfNEymN3gEnC2PMeg1cmYrDC6 RN63bmQWkcldrJnfdIY82bFCRA== X-Received: by 2002:adf:b083:: with SMTP id i3-v6mr7368321wra.52.1526316474128; Mon, 14 May 2018 09:47:54 -0700 (PDT) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id j1-v6sm12501813wre.25.2018.05.14.09.47.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 09:47:53 -0700 (PDT) Date: Mon, 14 May 2018 18:47:53 +0200 From: Jiri Pirko To: Vlad Buslov Cc: netdev@vger.kernel.org, davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com, pablo@netfilter.org, kadlec@blackhole.kfki.hu, fw@strlen.de, ast@kernel.org, daniel@iogearbox.net, edumazet@google.com, keescook@chromium.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, kliteyn@mellanox.com Subject: Re: [PATCH 06/14] net: sched: implement reference counted action release Message-ID: <20180514164753.GF2134@nanopsycho.orion> References: <1526308035-12484-1-git-send-email-vladbu@mellanox.com> <1526308035-12484-7-git-send-email-vladbu@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1526308035-12484-7-git-send-email-vladbu@mellanox.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mon, May 14, 2018 at 04:27:07PM CEST, vladbu@mellanox.com wrote: [...] >+static int tcf_action_del_1(struct net *net, char *kind, u32 index, >+ struct netlink_ext_ack *extack) >+{ >+ const struct tc_action_ops *ops; >+ int err = -EINVAL; >+ >+ ops = tc_lookup_action_n(kind); >+ if (!ops) { How this can happen? Apparently you hold reference to the module since you put it couple lines below. In that case, I don't really understand why you need to lookup and just don't use "ops" pointer you have in tcf_action_delete(). >+ NL_SET_ERR_MSG(extack, "Specified TC action not found"); >+ goto err_out; >+ } >+ >+ if (ops->delete) >+ err = ops->delete(net, index); >+ >+ module_put(ops->owner); >+err_out: >+ return err; >+} >+ > static int tca_action_flush(struct net *net, struct nlattr *nla, > struct nlmsghdr *n, u32 portid, > struct netlink_ext_ack *extack) >@@ -1052,6 +1088,36 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, > return err; > } > >+static int tcf_action_delete(struct net *net, struct list_head *actions, >+ struct netlink_ext_ack *extack) >+{ >+ int ret; >+ struct tc_action *a, *tmp; >+ char kind[IFNAMSIZ]; >+ u32 act_index; >+ >+ list_for_each_entry_safe(a, tmp, actions, list) { >+ const struct tc_action_ops *ops = a->ops; >+ >+ /* Actions can be deleted concurrently >+ * so we must save their type and id to search again >+ * after reference is released. >+ */ >+ strncpy(kind, a->ops->kind, sizeof(kind) - 1); >+ act_index = a->tcfa_index; >+ >+ list_del(&a->list); >+ if (tcf_action_put(a)) >+ module_put(ops->owner); >+ >+ /* now do the delete */ >+ ret = tcf_action_del_1(net, kind, act_index, extack); >+ if (ret < 0) >+ return ret; >+ } >+ return 0; >+} >+ [...]