net sched actions: introduce timestamp for firsttime use
authorJamal Hadi Salim <jhs@mojatatu.com>
Mon, 6 Jun 2016 10:32:54 +0000 (06:32 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Jun 2016 22:53:43 +0000 (15:53 -0700)
Useful to know when the action was first used for accounting
(and debugging)

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
15 files changed:
include/net/act_api.h
include/uapi/linux/pkt_cls.h
net/sched/act_api.c
net/sched/act_bpf.c
net/sched/act_connmark.c
net/sched/act_csum.c
net/sched/act_gact.c
net/sched/act_ipt.c
net/sched/act_mirred.c
net/sched/act_nat.c
net/sched/act_pedit.c
net/sched/act_police.c
net/sched/act_simple.c
net/sched/act_skbedit.c
net/sched/act_vlan.c

index 9a9a8edc138f0c0cb958e2e2b6023407f9d8bbd9..8389c007076f31c585b0952456e625036e112ed8 100644 (file)
@@ -76,6 +76,8 @@ static inline void tcf_lastuse_update(struct tcf_t *tm)
 
        if (tm->lastuse != now)
                tm->lastuse = now;
+       if (unlikely(!tm->firstuse))
+               tm->firstuse = now;
 }
 
 struct tc_action {
index f4297c8a42fe4a500833fe13d5a89bdc3f677941..9ba1410bd21d3f8c5da9012d5e774e10d3a222bc 100644 (file)
@@ -124,6 +124,7 @@ struct tcf_t {
        __u64   install;
        __u64   lastuse;
        __u64   expires;
+       __u64   firstuse;
 };
 
 struct tc_cnt {
index 336774a535c3959f4f25b05d1732c014d0d1763c..5ebf6d6f85f66f673b848ad5b64ef5b2ff7a23f8 100644 (file)
@@ -283,6 +283,7 @@ err2:
        p->tcfc_index = index ? index : tcf_hash_new_index(tn);
        p->tcfc_tm.install = jiffies;
        p->tcfc_tm.lastuse = jiffies;
+       p->tcfc_tm.firstuse = 0;
        if (est) {
                err = gen_new_estimator(&p->tcfc_bstats, p->cpu_bstats,
                                        &p->tcfc_rate_est,
index c7123e01c2cabc9c58bbe4d3be2c3836d7f5e2e2..e4b877f9d322137c79a15d5a1fc1b273774d4ecb 100644 (file)
@@ -156,6 +156,7 @@ static int tcf_bpf_dump(struct sk_buff *skb, struct tc_action *act,
 
        tm.install = jiffies_to_clock_t(jiffies - prog->tcf_tm.install);
        tm.lastuse = jiffies_to_clock_t(jiffies - prog->tcf_tm.lastuse);
+       tm.firstuse = jiffies_to_clock_t(jiffies - prog->tcf_tm.firstuse);
        tm.expires = jiffies_to_clock_t(prog->tcf_tm.expires);
 
        if (nla_put_64bit(skb, TCA_ACT_BPF_TM, sizeof(tm), &tm,
index e0e6c6876bc711b21b13b36a406f434f8208334a..e3f64f2d620655c2532709ef5cf7b0496f42b0b6 100644 (file)
@@ -163,6 +163,7 @@ static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a,
        t.install = jiffies_to_clock_t(jiffies - ci->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - ci->tcf_tm.lastuse);
        t.expires = jiffies_to_clock_t(ci->tcf_tm.expires);
+       t.firstuse = jiffies_to_clock_t(jiffies - ci->tcf_tm.firstuse);
        if (nla_put_64bit(skb, TCA_CONNMARK_TM, sizeof(t), &t,
                          TCA_CONNMARK_PAD))
                goto nla_put_failure;
index 065f71618276ad4eb1c4e992a58eaa9141baddeb..7725eafbe58143f0fddd04d94c9994db46c32601 100644 (file)
@@ -548,6 +548,7 @@ static int tcf_csum_dump(struct sk_buff *skb,
                goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
+       t.firstuse = jiffies_to_clock_t(jiffies - p->tcf_tm.firstuse);
        t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
        if (nla_put_64bit(skb, TCA_CSUM_TM, sizeof(t), &t, TCA_CSUM_PAD))
                goto nla_put_failure;
index ec5cc8435238695d5fda1282ee8ae7e1890dd2a7..c9d59f38a3f89b07369b60017a8f25d69edb9fbe 100644 (file)
@@ -190,6 +190,7 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
 #endif
        t.install = jiffies_to_clock_t(jiffies - gact->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - gact->tcf_tm.lastuse);
+       t.firstuse = jiffies_to_clock_t(jiffies - gact->tcf_tm.firstuse);
        t.expires = jiffies_to_clock_t(gact->tcf_tm.expires);
        if (nla_put_64bit(skb, TCA_GACT_TM, sizeof(t), &t, TCA_GACT_PAD))
                goto nla_put_failure;
index 30e9087b35361f579a5d86e1d449ea485d483548..47525ee201a97cb91d92d64a60e1becb3f8d1821 100644 (file)
@@ -279,6 +279,7 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
                goto nla_put_failure;
        tm.install = jiffies_to_clock_t(jiffies - ipt->tcf_tm.install);
        tm.lastuse = jiffies_to_clock_t(jiffies - ipt->tcf_tm.lastuse);
+       tm.firstuse = jiffies_to_clock_t(jiffies - ipt->tcf_tm.firstuse);
        tm.expires = jiffies_to_clock_t(ipt->tcf_tm.expires);
        if (nla_put_64bit(skb, TCA_IPT_TM, sizeof(tm), &tm, TCA_IPT_PAD))
                goto nla_put_failure;
index d3ac73e90f002bb7a6ab91420f199f6ab095aaa5..1b06093f8ef8e4c7e2cb4195477ec8fb9da6c960 100644 (file)
@@ -220,6 +220,7 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind, i
                goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - m->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - m->tcf_tm.lastuse);
+       t.firstuse = jiffies_to_clock_t(jiffies - m->tcf_tm.firstuse);
        t.expires = jiffies_to_clock_t(m->tcf_tm.expires);
        if (nla_put_64bit(skb, TCA_MIRRED_TM, sizeof(t), &t, TCA_MIRRED_PAD))
                goto nla_put_failure;
index 9135aa8f2970d383058a6a80f2ed7c957c715690..9fbf780a04c76756923f7b2d2d02a5a626288e4a 100644 (file)
@@ -266,6 +266,7 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
                goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
+       t.firstuse = jiffies_to_clock_t(jiffies - p->tcf_tm.firstuse);
        t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
        if (nla_put_64bit(skb, TCA_NAT_TM, sizeof(t), &t, TCA_NAT_PAD))
                goto nla_put_failure;
index 67a17265c967be000a99a41d7c1b6d094c6152c2..fb89275bc5952a5a706a26270a2b08cc4d1f51b7 100644 (file)
@@ -202,6 +202,7 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
                goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
+       t.firstuse = jiffies_to_clock_t(jiffies - p->tcf_tm.firstuse);
        t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
        if (nla_put_64bit(skb, TCA_PEDIT_TM, sizeof(t), &t, TCA_PEDIT_PAD))
                goto nla_put_failure;
index b884dae692a162fccf5204f1dad27734748a69c2..820b11686f850ce88cb470a9125262cbee4586f1 100644 (file)
@@ -241,6 +241,7 @@ override:
                tcf_hash_new_index(tn);
        police->tcf_tm.install = jiffies;
        police->tcf_tm.lastuse = jiffies;
+       police->tcf_tm.firstuse = 0;
        h = tcf_hash(police->tcf_index, POL_TAB_MASK);
        spin_lock_bh(&hinfo->lock);
        hlist_add_head(&police->tcf_head, &hinfo->htab[h]);
@@ -347,6 +348,7 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
 
        t.install = jiffies_to_clock_t(jiffies - police->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - police->tcf_tm.lastuse);
+       t.firstuse = jiffies_to_clock_t(jiffies - police->tcf_tm.firstuse);
        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;
index f95d1c59698606c3db6d1259b71a226d95ea33b0..81040f1cc3bb5a3d80885507661fca7dab7b76a5 100644 (file)
@@ -160,6 +160,7 @@ static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
                goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse);
+       t.firstuse = jiffies_to_clock_t(jiffies - d->tcf_tm.firstuse);
        t.expires = jiffies_to_clock_t(d->tcf_tm.expires);
        if (nla_put_64bit(skb, TCA_DEF_TM, sizeof(t), &t, TCA_DEF_PAD))
                goto nla_put_failure;
index 82105c8cb60ff7e4f40a7331ee85c5b25c105cb0..cf34f31f41061447ca11b680e586c2292e5ca6a7 100644 (file)
@@ -170,6 +170,7 @@ static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a,
                goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse);
+       t.firstuse = jiffies_to_clock_t(jiffies - d->tcf_tm.firstuse);
        t.expires = jiffies_to_clock_t(d->tcf_tm.expires);
        if (nla_put_64bit(skb, TCA_SKBEDIT_TM, sizeof(t), &t, TCA_SKBEDIT_PAD))
                goto nla_put_failure;
index da5120f5513fa9b62c261017a2039aaf3a07356d..978ec4c89684808b1b7c641d7e18883455f2b379 100644 (file)
@@ -184,6 +184,7 @@ static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a,
 
        t.install = jiffies_to_clock_t(jiffies - v->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - v->tcf_tm.lastuse);
+       t.firstuse = jiffies_to_clock_t(jiffies - v->tcf_tm.firstuse);
        t.expires = jiffies_to_clock_t(v->tcf_tm.expires);
        if (nla_put_64bit(skb, TCA_VLAN_TM, sizeof(t), &t, TCA_VLAN_PAD))
                goto nla_put_failure;