From patchwork Tue May 24 01:07:20 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: 625454 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 3rDHM90WYBz9t6X for ; Tue, 24 May 2016 11:07:33 +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=Uz7r8jLo; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752637AbcEXBHa (ORCPT ); Mon, 23 May 2016 21:07:30 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:34795 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751158AbcEXBHa (ORCPT ); Mon, 23 May 2016 21:07:30 -0400 Received: by mail-io0-f194.google.com with SMTP id d197so526785ioe.1 for ; Mon, 23 May 2016 18:07:29 -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=yhDE5J9BxEVuYh3RbJdgyKJbUpxCMNNphpaHOZCVFpw=; b=Uz7r8jLovIVt81JO1du5gcOx1d+iFumSwq8F7qIf1XIYN5eIglLDmdfGKF7vXdOrAV yBEXXhhG+nedfr3UFQ7DIPT9DH1NA36QrnU36hleC4Ip4jFpKOLD0BSrJMJz40GAF73a AKFMCQBiu1sv9J/FgbUY6PL1QGlSCQL0lNtMXOwIKAjeMTcqtp6WXqSs5jxdczbteS17 tbBjv+iIZtCu7wsm7XHZec0YdnsABl2hODmBYNGhceYUUZ1gDfvmi/AEGh0sSxhyQF8u PT2vNdxBn9V6rDjxshShUQwJ9Lrl+akRFTHhyVCTDqXMQM43L71plHbG0dN/JdjQ6fh/ WK9Q== 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=yhDE5J9BxEVuYh3RbJdgyKJbUpxCMNNphpaHOZCVFpw=; b=TIgL71SYkZY7aDLaRV4ym8J4rbBVHo3h7k/2dncuU4vQ+2RmXELJelOsSwFy6sO6XR yIbYdNurkIYlw3B7JEPuIcV+7OFZ1gbkB4DKEoELgouKRvrcndRHdg1BmgpYFNPyp7LX jMYHDtUNYLcl3Gg+qWAdp9NgqXnjP9WiaP805AZO/ZVPB2lIxSHK+LVqOY9TmhhQBukI Sv5/tMYlRqMMYDCOvwUjwRK0vq9u3fzDIcI3Cj5yKOPUfy3fZm+eshVKw3Xyrp95n3YD RFCa4KzFSqMB7aI9sylJ426IN6jpMl3nCiN0DoiXfHiP7jzm8PATNzg/1xo62qWXfn5u hf9w== X-Gm-Message-State: ALyK8tKFKPnYatiIX603gmW5QYTgeN9AJ1578fp4GIz/gwA9CSASDMVSUAeZK0ZHB52gVg== X-Received: by 10.107.33.1 with SMTP id h1mr7080314ioh.30.1464052049033; Mon, 23 May 2016 18:07:29 -0700 (PDT) Received: from localhost.localdomain ([23.233.30.50]) by smtp.gmail.com with ESMTPSA id m88sm328278iod.28.2016.05.23.18.07.27 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 May 2016 18:07:28 -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: [net PATCH v2 1/1] net sched actions: policer missing timestamp processing Date: Mon, 23 May 2016 21:07:20 -0400 Message-Id: <1464052040-25783-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 Policer was not dumping or updating timestamps Signed-off-by: Jamal Hadi Salim Acked-by: Cong Wang --- include/uapi/linux/pkt_cls.h | 4 +++- net/sched/act_police.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index eba5914..f4297c8 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -145,6 +145,8 @@ enum { TCA_POLICE_PEAKRATE, TCA_POLICE_AVRATE, TCA_POLICE_RESULT, + TCA_POLICE_TM, + TCA_POLICE_PAD, __TCA_POLICE_MAX #define TCA_POLICE_RESULT TCA_POLICE_RESULT }; @@ -173,7 +175,7 @@ enum { TCA_U32_DIVISOR, TCA_U32_SEL, TCA_U32_POLICE, - TCA_U32_ACT, + TCA_U32_ACT, TCA_U32_INDEV, TCA_U32_PCNT, TCA_U32_MARK, diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 330f14e..b884dae 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -239,6 +239,8 @@ override: police->tcfp_t_c = ktime_get_ns(); police->tcf_index = parm->index ? parm->index : tcf_hash_new_index(tn); + police->tcf_tm.install = jiffies; + police->tcf_tm.lastuse = jiffies; h = tcf_hash(police->tcf_index, POL_TAB_MASK); spin_lock_bh(&hinfo->lock); hlist_add_head(&police->tcf_head, &hinfo->htab[h]); @@ -268,6 +270,7 @@ static int tcf_act_police(struct sk_buff *skb, const struct tc_action *a, spin_lock(&police->tcf_lock); bstats_update(&police->tcf_bstats, skb); + tcf_lastuse_update(&police->tcf_tm); if (police->tcfp_ewma_rate && police->tcf_rate_est.bps >= police->tcfp_ewma_rate) { @@ -327,6 +330,7 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref) .refcnt = police->tcf_refcnt - ref, .bindcnt = police->tcf_bindcnt - bind, }; + struct tcf_t t; if (police->rate_present) psched_ratecfg_getrate(&opt.rate, &police->rate); @@ -340,6 +344,13 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref) if (police->tcfp_ewma_rate && nla_put_u32(skb, TCA_POLICE_AVRATE, police->tcfp_ewma_rate)) goto nla_put_failure; + + t.install = jiffies_to_clock_t(jiffies - police->tcf_tm.install); + t.lastuse = jiffies_to_clock_t(jiffies - police->tcf_tm.lastuse); + t.expires = jiffies_to_clock_t(police->tcf_tm.expires); + if (nla_put_64bit(skb, TCA_POLICE_TM, sizeof(t), &t, TCA_POLICE_PAD)) + goto nla_put_failure; + return skb->len; nla_put_failure: