Skip to content

Commit 48d8ee1

Browse files
jhsmtdavem330
authored andcommitted
net sched actions: aggregate dumping of actions timeinfo
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 53eb440 commit 48d8ee1

File tree

13 files changed

+29
-48
lines changed

13 files changed

+29
-48
lines changed

include/net/act_api.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ static inline void tcf_lastuse_update(struct tcf_t *tm)
8080
tm->firstuse = now;
8181
}
8282

83+
static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm)
84+
{
85+
dtm->install = jiffies_to_clock_t(jiffies - stm->install);
86+
dtm->lastuse = jiffies_to_clock_t(jiffies - stm->lastuse);
87+
dtm->firstuse = jiffies_to_clock_t(jiffies - stm->firstuse);
88+
dtm->expires = jiffies_to_clock_t(stm->expires);
89+
}
90+
8391
struct tc_action {
8492
void *priv;
8593
const struct tc_action_ops *ops;

net/sched/act_bpf.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,7 @@ static int tcf_bpf_dump(struct sk_buff *skb, struct tc_action *act,
154154
if (ret)
155155
goto nla_put_failure;
156156

157-
tm.install = jiffies_to_clock_t(jiffies - prog->tcf_tm.install);
158-
tm.lastuse = jiffies_to_clock_t(jiffies - prog->tcf_tm.lastuse);
159-
tm.firstuse = jiffies_to_clock_t(jiffies - prog->tcf_tm.firstuse);
160-
tm.expires = jiffies_to_clock_t(prog->tcf_tm.expires);
161-
157+
tcf_tm_dump(&tm, &prog->tcf_tm);
162158
if (nla_put_64bit(skb, TCA_ACT_BPF_TM, sizeof(tm), &tm,
163159
TCA_ACT_BPF_PAD))
164160
goto nla_put_failure;

net/sched/act_connmark.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a,
160160
if (nla_put(skb, TCA_CONNMARK_PARMS, sizeof(opt), &opt))
161161
goto nla_put_failure;
162162

163-
t.install = jiffies_to_clock_t(jiffies - ci->tcf_tm.install);
164-
t.lastuse = jiffies_to_clock_t(jiffies - ci->tcf_tm.lastuse);
165-
t.expires = jiffies_to_clock_t(ci->tcf_tm.expires);
166-
t.firstuse = jiffies_to_clock_t(jiffies - ci->tcf_tm.firstuse);
163+
tcf_tm_dump(&t, &ci->tcf_tm);
167164
if (nla_put_64bit(skb, TCA_CONNMARK_TM, sizeof(t), &t,
168165
TCA_CONNMARK_PAD))
169166
goto nla_put_failure;

net/sched/act_csum.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,8 @@ static int tcf_csum_dump(struct sk_buff *skb,
546546

547547
if (nla_put(skb, TCA_CSUM_PARMS, sizeof(opt), &opt))
548548
goto nla_put_failure;
549-
t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
550-
t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
551-
t.firstuse = jiffies_to_clock_t(jiffies - p->tcf_tm.firstuse);
552-
t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
549+
550+
tcf_tm_dump(&t, &p->tcf_tm);
553551
if (nla_put_64bit(skb, TCA_CSUM_TM, sizeof(t), &t, TCA_CSUM_PAD))
554552
goto nla_put_failure;
555553

net/sched/act_gact.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,7 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
188188
goto nla_put_failure;
189189
}
190190
#endif
191-
t.install = jiffies_to_clock_t(jiffies - gact->tcf_tm.install);
192-
t.lastuse = jiffies_to_clock_t(jiffies - gact->tcf_tm.lastuse);
193-
t.firstuse = jiffies_to_clock_t(jiffies - gact->tcf_tm.firstuse);
194-
t.expires = jiffies_to_clock_t(gact->tcf_tm.expires);
191+
tcf_tm_dump(&t, &gact->tcf_tm);
195192
if (nla_put_64bit(skb, TCA_GACT_TM, sizeof(t), &t, TCA_GACT_PAD))
196193
goto nla_put_failure;
197194
return skb->len;

net/sched/act_ife.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,7 @@ static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind,
553553
if (nla_put(skb, TCA_IFE_PARMS, sizeof(opt), &opt))
554554
goto nla_put_failure;
555555

556-
t.install = jiffies_to_clock_t(jiffies - ife->tcf_tm.install);
557-
t.lastuse = jiffies_to_clock_t(jiffies - ife->tcf_tm.lastuse);
558-
t.expires = jiffies_to_clock_t(ife->tcf_tm.expires);
556+
tcf_tm_dump(&t, &ife->tcf_tm);
559557
if (nla_put_64bit(skb, TCA_IFE_TM, sizeof(t), &t, TCA_IFE_PAD))
560558
goto nla_put_failure;
561559

net/sched/act_ipt.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,11 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
277277
nla_put(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c) ||
278278
nla_put_string(skb, TCA_IPT_TABLE, ipt->tcfi_tname))
279279
goto nla_put_failure;
280-
tm.install = jiffies_to_clock_t(jiffies - ipt->tcf_tm.install);
281-
tm.lastuse = jiffies_to_clock_t(jiffies - ipt->tcf_tm.lastuse);
282-
tm.firstuse = jiffies_to_clock_t(jiffies - ipt->tcf_tm.firstuse);
283-
tm.expires = jiffies_to_clock_t(ipt->tcf_tm.expires);
280+
281+
tcf_tm_dump(&tm, &ipt->tcf_tm);
284282
if (nla_put_64bit(skb, TCA_IPT_TM, sizeof(tm), &tm, TCA_IPT_PAD))
285283
goto nla_put_failure;
284+
286285
kfree(t);
287286
return skb->len;
288287

net/sched/act_mirred.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,8 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind, i
218218

219219
if (nla_put(skb, TCA_MIRRED_PARMS, sizeof(opt), &opt))
220220
goto nla_put_failure;
221-
t.install = jiffies_to_clock_t(jiffies - m->tcf_tm.install);
222-
t.lastuse = jiffies_to_clock_t(jiffies - m->tcf_tm.lastuse);
223-
t.firstuse = jiffies_to_clock_t(jiffies - m->tcf_tm.firstuse);
224-
t.expires = jiffies_to_clock_t(m->tcf_tm.expires);
221+
222+
tcf_tm_dump(&t, &m->tcf_tm);
225223
if (nla_put_64bit(skb, TCA_MIRRED_TM, sizeof(t), &t, TCA_MIRRED_PAD))
226224
goto nla_put_failure;
227225
return skb->len;

net/sched/act_nat.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,8 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
264264

265265
if (nla_put(skb, TCA_NAT_PARMS, sizeof(opt), &opt))
266266
goto nla_put_failure;
267-
t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
268-
t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
269-
t.firstuse = jiffies_to_clock_t(jiffies - p->tcf_tm.firstuse);
270-
t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
267+
268+
tcf_tm_dump(&t, &p->tcf_tm);
271269
if (nla_put_64bit(skb, TCA_NAT_TM, sizeof(t), &t, TCA_NAT_PAD))
272270
goto nla_put_failure;
273271

net/sched/act_pedit.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,11 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
200200

201201
if (nla_put(skb, TCA_PEDIT_PARMS, s, opt))
202202
goto nla_put_failure;
203-
t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
204-
t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
205-
t.firstuse = jiffies_to_clock_t(jiffies - p->tcf_tm.firstuse);
206-
t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
203+
204+
tcf_tm_dump(&t, &p->tcf_tm);
207205
if (nla_put_64bit(skb, TCA_PEDIT_TM, sizeof(t), &t, TCA_PEDIT_PAD))
208206
goto nla_put_failure;
207+
209208
kfree(opt);
210209
return skb->len;
211210

0 commit comments

Comments
 (0)