sched: add helper for updating statistics on all actions

Forgetting to disable preemption around tcf_action_stats_update()
seems to be a common mistake.  Add a helper function for updating
stats on all actions of a filter.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jakub Kicinski
2017-05-31 08:06:43 -07:00
committed by David S. Miller
parent c380e377a5
commit d897a638e9
4 changed files with 23 additions and 27 deletions

View File

@@ -157,6 +157,25 @@ static inline void tcf_exts_to_list(const struct tcf_exts *exts,
#endif
}
static inline void
tcf_exts_stats_update(const struct tcf_exts *exts,
u64 bytes, u64 packets, u64 lastuse)
{
#ifdef CONFIG_NET_CLS_ACT
int i;
preempt_disable();
for (i = 0; i < exts->nr_actions; i++) {
struct tc_action *a = exts->actions[i];
tcf_action_stats_update(a, bytes, packets, lastuse);
}
preempt_enable();
#endif
}
/**
* tcf_exts_exec - execute tc filter extensions
* @skb: socket buffer