From patchwork Mon Sep 19 23:02:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamal Hadi Salim X-Patchwork-Id: 672024 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 3sdLyq3yzLz9rvt for ; Tue, 20 Sep 2016 09:03:15 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b=byvxmEwm; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751532AbcISXDD (ORCPT ); Mon, 19 Sep 2016 19:03:03 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:32770 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751032AbcISXDC (ORCPT ); Mon, 19 Sep 2016 19:03:02 -0400 Received: by mail-io0-f193.google.com with SMTP id r145so177102ior.0 for ; Mon, 19 Sep 2016 16:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=9h1TpddX4rKUPdJyD8fQ0by3p8QbyUrRc+bAPlaM17U=; b=byvxmEwmjBlWfkk+zCLbrcXqVe5grxENoGN98UMJXqDwD7i3xDJv2ftK/KKSjqnFmC 7gRidcUsu3m7XQoxWUQa4fp/ZNUqmFT4HrsapeyWIciYF5PqZVecPJ60Acl6M2BWkj7w JJOvYXquG1qIsW1ReRdISdlJLkkONgrhSyxhsxD5zLbmAOW0nPwqq1QLHHLOQg/cgD0V Y/XEEYq0LqJBei8GrB/FHY32OFQhEPRqVr4KfzJ/PfmoacncLmi964eGLRFgT17eT9jJ 8Ix6szQtf9xLWbt4G7lxHPQjsr0NtQwocsFevcPzPOnO0GhRmtkFBuHR/mFYsBbcZkFE P6lw== 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; bh=9h1TpddX4rKUPdJyD8fQ0by3p8QbyUrRc+bAPlaM17U=; b=eroFAgc/sKfdTYwdohCeTeOpH8hmJ09oLF+dKre+pcqo+NTPi5SRRWJtNNjA4kQpbM hPU5H66d/+xBRGBL06vtrrFD3C+X3z3kCiyAcH+jR2KHzOXtJ0EGj97xu1l3KAghjGr3 dtCHeesqLJEMrWGtUtIKPtRgcv1FXpqWcbljnj482SZ/3/6mM9cZsFAfKY6aj4zeM7gE kgK0HQwgSpE31rZmcBywIC01n9YaFtKKLD+lVKg9sZTqd4T0hjNI5G0DytHTXozYtVOy lUXahrYTUJ2sYf4AZ66KeDKAOnYgPzJHt76LG/qHZTj1cxcsYIxToSwwnGfwEgGIVmbL as+Q== X-Gm-Message-State: AE9vXwPIFIPWT5584904GbOruyt+NXB+EGI/BNGMGBFR3EFpHtQdyHMSrNaplBIKswNxLg== X-Received: by 10.107.168.225 with SMTP id e94mr41948002ioj.111.1474326181240; Mon, 19 Sep 2016 16:03:01 -0700 (PDT) Received: from jhs-UX303LB.lan ([23.233.30.50]) by smtp.gmail.com with ESMTPSA id v69sm9070175itc.1.2016.09.19.16.02.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Sep 2016 16:02:58 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: netdev@vger.kernel.org, xiyou.wangcong@gmail.com, Jamal Hadi Salim Subject: [PATCH v5 net-next 1/1] net sched actions: fix GETing actions Date: Mon, 19 Sep 2016 19:02:51 -0400 Message-Id: <1474326171-29035-1-git-send-email-jhs@emojatatu.com> X-Mailer: git-send-email 1.9.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jamal Hadi Salim With the batch changes that translated transient actions into a temporary list lost in the translation was the fact that tcf_action_destroy() will eventually delete the action from the permanent location if the refcount is zero. Example of what broke: ...add a gact action to drop sudo $TC actions add action drop index 10 ...now retrieve it, looks good sudo $TC actions get action gact index 10 ...retrieve it again and find it is gone! sudo $TC actions get action gact index 10 Fixes: 22dc13c837c3 ("net_sched: convert tcf_exts from list to pointer array"), Fixes: 824a7e8863b3 ("net_sched: remove an unnecessary list_del()") Fixes: f07fed82ad79 ("net_sched: remove the leftover cleanup_a()") Acked-by: Cong Wang Signed-off-by: Jamal Hadi Salim --- net/sched/act_api.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index d09d068..411191b 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -592,6 +592,17 @@ err_out: return ERR_PTR(err); } +static void cleanup_a(struct list_head *actions, int ovr) +{ + struct tc_action *a; + + if (!ovr) + return; + + list_for_each_entry(a, actions, list) + a->tcfa_refcnt--; +} + int tcf_action_init(struct net *net, struct nlattr *nla, struct nlattr *est, char *name, int ovr, int bind, struct list_head *actions) @@ -612,8 +623,15 @@ int tcf_action_init(struct net *net, struct nlattr *nla, goto err; } act->order = i; + if (ovr) + act->tcfa_refcnt++; list_add_tail(&act->list, actions); } + + /* Remove the temp refcnt which was necessary to protect against + * destroying an existing action which was being replaced + */ + cleanup_a(actions, ovr); return 0; err: @@ -883,6 +901,8 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, goto err; } act->order = i; + if (event == RTM_GETACTION) + act->tcfa_refcnt++; list_add_tail(&act->list, &actions); }