[SRU][Focal][PATCH v2 1/6] net: sched: extract qstats update code into functions
Yuxuan Luo
yuxuan.luo at canonical.com
Fri May 12 18:01:33 UTC 2023
From: Vlad Buslov <vladbu at mellanox.com>
Extract common code that increments cpu_qstats counters into standalone act
API functions. Change hardware offloaded actions that use percpu counter
allocation to use the new functions instead of accessing cpu_qstats
directly.
This commit doesn't change functionality.
Signed-off-by: Vlad Buslov <vladbu at mellanox.com>
Acked-by: Jiri Pirko <jiri at mellanox.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
(backported from commit 26b537a88ca5b7399c7ab0656e06dbd9da9513c1)
[yuxuan.luo: only backport act_mirred.c and three new wrapper functions
introduced in act_api.h.
]
CVE-2022-4269
Signed-off-by: Yuxuan Luo <yuxuan.luo at canonical.com>
---
include/net/act_api.h | 16 ++++++++++++++++
net/sched/act_mirred.c | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/net/act_api.h b/include/net/act_api.h
index 4dabe4730f00f..e2e30c1b97df0 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -186,6 +186,22 @@ int tcf_action_dump(struct sk_buff *skb, struct tc_action *actions[], int bind,
int ref);
int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
+static inline struct gnet_stats_queue *
+tcf_action_get_qstats(struct tc_action *a)
+{
+ return this_cpu_ptr(a->cpu_qstats);
+}
+
+static inline void tcf_action_inc_drop_qstats(struct tc_action *a)
+{
+ qstats_drop_inc(this_cpu_ptr(a->cpu_qstats));
+}
+
+static inline void tcf_action_inc_overlimit_qstats(struct tc_action *a)
+{
+ qstats_overlimit_inc(this_cpu_ptr(a->cpu_qstats));
+}
+
int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int);
int tcf_action_check_ctrlact(int action, struct tcf_proto *tp,
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index b87d2a1ee0b16..8f5746a1c4a6c 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -309,7 +309,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
if (err) {
out:
- qstats_overlimit_inc(this_cpu_ptr(m->common.cpu_qstats));
+ tcf_action_inc_overlimit_qstats(&m->common);
if (tcf_mirred_is_act_redirect(m_eaction))
retval = TC_ACT_SHOT;
}
--
2.34.1
More information about the kernel-team
mailing list