From patchwork Wed Aug 26 03:06:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 510698 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 75E5C14055A for ; Wed, 26 Aug 2015 13:07:11 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752402AbbHZDGv (ORCPT ); Tue, 25 Aug 2015 23:06:51 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35414 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816AbbHZDGp (ORCPT ); Tue, 25 Aug 2015 23:06:45 -0400 Received: by pacdd16 with SMTP id dd16so144535806pac.2 for ; Tue, 25 Aug 2015 20:06:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vbqhGhVKPJj9p9aGxCmSs91qDpriNL10JizizoxVCp8=; b=eVTCcsCNTB8t+Y5Lt+9Kc8qQ3krvdsJ8eZmDZBcMAZcW//Pz+8HXB5on4ql5C83RGQ mMMWWc6yHggbFtgx4/4z4hBrmlQ5pULlgZldUCc+w6rezDlUbomAkwaZqAZSvP9tcRbi 96RnD9cU8Te9IAX9r0FjTs3D8i8waOOCQ+pIVQ/CCa1M5zjOczHsb9NGMrIX7SOAoY4H 1sgJLMVI6lpNssuT70NA0Iu/bnv62r+93td/sKViErj583GmTzQ1ODpsIdtv8fJMfHAD eDpi8Pz3BtnaaF5zR0XjxlDL16UldfC4EBy7jHtBVYa51IPjPlvkQSG4+z+dfTq9eB4O o5Ww== X-Gm-Message-State: ALoCoQkw6Zj1gwBMtXBqGcbXqgv9LNy4BFcOrMTK6TAkNR2XNo1i2VX9jFrYYnqMajg1uSbErAHp X-Received: by 10.68.134.169 with SMTP id pl9mr64622332pbb.164.1440558405024; Tue, 25 Aug 2015 20:06:45 -0700 (PDT) Received: from localhost.localdomain ([12.97.19.195]) by smtp.gmail.com with ESMTPSA id jy10sm22636552pbd.66.2015.08.25.20.06.44 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Aug 2015 20:06:44 -0700 (PDT) From: Alexei Starovoitov To: "David S. Miller" Cc: Eric Dumazet , Daniel Borkmann , netdev@vger.kernel.org Subject: [PATCH v2 net-next 3/5] net_sched: convert tcindex to call tcf_exts_destroy from rcu callback Date: Tue, 25 Aug 2015 20:06:33 -0700 Message-Id: <1440558395-7765-4-git-send-email-ast@plumgrid.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1440558395-7765-1-git-send-email-ast@plumgrid.com> References: <1440558395-7765-1-git-send-email-ast@plumgrid.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Adjust destroy path of cls_tcindex to call tcf_exts_destroy() after rcu grace period. Signed-off-by: Alexei Starovoitov Acked-by: Daniel Borkmann --- net/sched/cls_tcindex.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index a557dbaf5afe..944c8ff45055 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c @@ -27,6 +27,7 @@ struct tcindex_filter_result { struct tcf_exts exts; struct tcf_result res; + struct rcu_head rcu; }; struct tcindex_filter { @@ -133,8 +134,23 @@ static int tcindex_init(struct tcf_proto *tp) return 0; } -static int -tcindex_delete(struct tcf_proto *tp, unsigned long arg) +static void tcindex_destroy_rexts(struct rcu_head *head) +{ + struct tcindex_filter_result *r; + + r = container_of(head, struct tcindex_filter_result, rcu); + tcf_exts_destroy(&r->exts); +} + +static void tcindex_destroy_fexts(struct rcu_head *head) +{ + struct tcindex_filter *f = container_of(head, struct tcindex_filter, rcu); + + tcf_exts_destroy(&f->result.exts); + kfree(f); +} + +static int tcindex_delete(struct tcf_proto *tp, unsigned long arg) { struct tcindex_data *p = rtnl_dereference(tp->root); struct tcindex_filter_result *r = (struct tcindex_filter_result *) arg; @@ -162,9 +178,14 @@ found: rcu_assign_pointer(*walk, rtnl_dereference(f->next)); } tcf_unbind_filter(tp, &r->res); - tcf_exts_destroy(&r->exts); + /* all classifiers are required to call tcf_exts_destroy() after rcu + * grace period, since converted-to-rcu actions are relying on that + * in cleanup() callback + */ if (f) - kfree_rcu(f, rcu); + call_rcu(&f->rcu, tcindex_destroy_fexts); + else + call_rcu(&r->rcu, tcindex_destroy_rexts); return 0; }