net sched actions: aggregate dumping of actions timeinfo
authorJamal Hadi Salim <jhs@mojatatu.com>
Mon, 6 Jun 2016 10:32:55 +0000 (06:32 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Jun 2016 22:53:43 +0000 (15:53 -0700)
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
13 files changed:
include/net/act_api.h
net/sched/act_bpf.c
net/sched/act_connmark.c
net/sched/act_csum.c
net/sched/act_gact.c
net/sched/act_ife.c
net/sched/act_ipt.c
net/sched/act_mirred.c
net/sched/act_nat.c
net/sched/act_pedit.c
net/sched/act_simple.c
net/sched/act_skbedit.c
net/sched/act_vlan.c

index 8389c007076f31c585b0952456e625036e112ed8..a891978310e9c5f2f40a66312f445c975fb271eb 100644 (file)
@@ -80,6 +80,14 @@ static inline void tcf_lastuse_update(struct tcf_t *tm)
                tm->firstuse = now;
 }
 
+static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm)
+{
+       dtm->install = jiffies_to_clock_t(jiffies - stm->install);
+       dtm->lastuse = jiffies_to_clock_t(jiffies - stm->lastuse);
+       dtm->firstuse = jiffies_to_clock_t(jiffies - stm->firstuse);
+       dtm->expires = jiffies_to_clock_t(stm->expires);
+}
+
 struct tc_action {
        void                    *priv;
        const struct tc_action_ops      *ops;
index e4b877f9d322137c79a15d5a1fc1b273774d4ecb..ae0e7cbe488cd6abecf78377e1efb3550f2a7d3a 100644 (file)
@@ -154,11 +154,7 @@ static int tcf_bpf_dump(struct sk_buff *skb, struct tc_action *act,
        if (ret)
                goto nla_put_failure;
 
-       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);
-
+       tcf_tm_dump(&tm, &prog->tcf_tm);
        if (nla_put_64bit(skb, TCA_ACT_BPF_TM, sizeof(tm), &tm,
                          TCA_ACT_BPF_PAD))
                goto nla_put_failure;
index e3f64f2d620655c2532709ef5cf7b0496f42b0b6..35a5270f289d69c2674f40f94e57556e78d650b2 100644 (file)
@@ -160,10 +160,7 @@ static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a,
        if (nla_put(skb, TCA_CONNMARK_PARMS, sizeof(opt), &opt))
                goto nla_put_failure;
 
-       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);
+       tcf_tm_dump(&t, &ci->tcf_tm);
        if (nla_put_64bit(skb, TCA_CONNMARK_TM, sizeof(t), &t,
                          TCA_CONNMARK_PAD))
                goto nla_put_failure;
index 7725eafbe58143f0fddd04d94c9994db46c32601..dcd9ababd35162120162a6358e4e8c2c6d68d3ae 100644 (file)
@@ -546,10 +546,8 @@ static int tcf_csum_dump(struct sk_buff *skb,
 
        if (nla_put(skb, TCA_CSUM_PARMS, sizeof(opt), &opt))
                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);
+
+       tcf_tm_dump(&t, &p->tcf_tm);
        if (nla_put_64bit(skb, TCA_CSUM_TM, sizeof(t), &t, TCA_CSUM_PAD))
                goto nla_put_failure;
 
index c9d59f38a3f89b07369b60017a8f25d69edb9fbe..4c6e0085054aedbfbd180c952ae1caebfdf1f1af 100644 (file)
@@ -188,10 +188,7 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
                        goto nla_put_failure;
        }
 #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);
+       tcf_tm_dump(&t, &gact->tcf_tm);
        if (nla_put_64bit(skb, TCA_GACT_TM, sizeof(t), &t, TCA_GACT_PAD))
                goto nla_put_failure;
        return skb->len;
index 649157624f463a7c04a024e33519fe5cfe99c00d..02f5a8ba95d7a3bacc98d31a531bc8e2c64c36e5 100644 (file)
@@ -553,9 +553,7 @@ static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind,
        if (nla_put(skb, TCA_IFE_PARMS, sizeof(opt), &opt))
                goto nla_put_failure;
 
-       t.install = jiffies_to_clock_t(jiffies - ife->tcf_tm.install);
-       t.lastuse = jiffies_to_clock_t(jiffies - ife->tcf_tm.lastuse);
-       t.expires = jiffies_to_clock_t(ife->tcf_tm.expires);
+       tcf_tm_dump(&t, &ife->tcf_tm);
        if (nla_put_64bit(skb, TCA_IFE_TM, sizeof(t), &t, TCA_IFE_PAD))
                goto nla_put_failure;
 
index 47525ee201a97cb91d92d64a60e1becb3f8d1821..3fcde44b8f4decd2399873307993ac841391901a 100644 (file)
@@ -277,12 +277,11 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
            nla_put(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c) ||
            nla_put_string(skb, TCA_IPT_TABLE, ipt->tcfi_tname))
                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);
+
+       tcf_tm_dump(&tm, &ipt->tcf_tm);
        if (nla_put_64bit(skb, TCA_IPT_TM, sizeof(tm), &tm, TCA_IPT_PAD))
                goto nla_put_failure;
+
        kfree(t);
        return skb->len;
 
index 1b06093f8ef8e4c7e2cb4195477ec8fb9da6c960..787751a7981af7f2432e0e553a1992847bbc97af 100644 (file)
@@ -218,10 +218,8 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind, i
 
        if (nla_put(skb, TCA_MIRRED_PARMS, sizeof(opt), &opt))
                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);
+
+       tcf_tm_dump(&t, &m->tcf_tm);
        if (nla_put_64bit(skb, TCA_MIRRED_TM, sizeof(t), &t, TCA_MIRRED_PAD))
                goto nla_put_failure;
        return skb->len;
index 9fbf780a04c76756923f7b2d2d02a5a626288e4a..06ccb03f25da5a92c3c1ad8105fa55111eb92a8d 100644 (file)
@@ -264,10 +264,8 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
 
        if (nla_put(skb, TCA_NAT_PARMS, sizeof(opt), &opt))
                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);
+
+       tcf_tm_dump(&t, &p->tcf_tm);
        if (nla_put_64bit(skb, TCA_NAT_TM, sizeof(t), &t, TCA_NAT_PAD))
                goto nla_put_failure;
 
index fb89275bc5952a5a706a26270a2b08cc4d1f51b7..82d3c147902903efd28f315a65b5014e5a15fe66 100644 (file)
@@ -200,12 +200,11 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
 
        if (nla_put(skb, TCA_PEDIT_PARMS, s, opt))
                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);
+
+       tcf_tm_dump(&t, &p->tcf_tm);
        if (nla_put_64bit(skb, TCA_PEDIT_TM, sizeof(t), &t, TCA_PEDIT_PAD))
                goto nla_put_failure;
+
        kfree(opt);
        return skb->len;
 
index 81040f1cc3bb5a3d80885507661fca7dab7b76a5..be5fbb51cfeddad9e6215d4473d0c35b1df6fdf3 100644 (file)
@@ -158,10 +158,8 @@ static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
        if (nla_put(skb, TCA_DEF_PARMS, sizeof(opt), &opt) ||
            nla_put_string(skb, TCA_DEF_DATA, d->tcfd_defdata))
                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);
+
+       tcf_tm_dump(&t, &d->tcf_tm);
        if (nla_put_64bit(skb, TCA_DEF_TM, sizeof(t), &t, TCA_DEF_PAD))
                goto nla_put_failure;
        return skb->len;
index cf34f31f41061447ca11b680e586c2292e5ca6a7..7e2bc3c2b6da07fa6f14617363889363dcb711ad 100644 (file)
@@ -168,10 +168,8 @@ static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a,
            nla_put(skb, TCA_SKBEDIT_MARK, sizeof(d->mark),
                    &d->mark))
                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);
+
+       tcf_tm_dump(&t, &d->tcf_tm);
        if (nla_put_64bit(skb, TCA_SKBEDIT_TM, sizeof(t), &t, TCA_SKBEDIT_PAD))
                goto nla_put_failure;
        return skb->len;
index 978ec4c89684808b1b7c641d7e18883455f2b379..f0a08a11f54f0127ff345df7c5d36421f5190a1e 100644 (file)
@@ -182,10 +182,7 @@ static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a,
             nla_put_be16(skb, TCA_VLAN_PUSH_VLAN_PROTOCOL, v->tcfv_push_proto)))
                goto nla_put_failure;
 
-       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);
+       tcf_tm_dump(&t, &v->tcf_tm);
        if (nla_put_64bit(skb, TCA_VLAN_TM, sizeof(t), &t, TCA_VLAN_PAD))
                goto nla_put_failure;
        return skb->len;