net: sched: don't expose action qstats to skb_tc_reinsert()
authorVlad Buslov <vladbu@mellanox.com>
Wed, 30 Oct 2019 14:09:03 +0000 (16:09 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 31 Oct 2019 01:07:50 +0000 (18:07 -0700)
Previous commit introduced helper function for updating qstats and
refactored set of actions to use the helpers, instead of modifying qstats
directly. However, one of the affected action exposes its qstats to
skb_tc_reinsert(), which then modifies it.

Refactor skb_tc_reinsert() to return integer error code and don't increment
overlimit qstats in case of error, and use the returned error code in
tcf_mirred_act() to manually increment the overlimit counter with new
helper function.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sch_generic.h
net/sched/act_mirred.c

index 637548d54b3ee9bdb0edd10a1667e81a40a6ef74..a8b0a9a4c686541d175ea5b543c0ec3c9d7c9e79 100644 (file)
@@ -1286,17 +1286,9 @@ void mini_qdisc_pair_swap(struct mini_Qdisc_pair *miniqp,
 void mini_qdisc_pair_init(struct mini_Qdisc_pair *miniqp, struct Qdisc *qdisc,
                          struct mini_Qdisc __rcu **p_miniq);
 
-static inline void skb_tc_reinsert(struct sk_buff *skb, struct tcf_result *res)
+static inline int skb_tc_reinsert(struct sk_buff *skb, struct tcf_result *res)
 {
-       struct gnet_stats_queue *stats = res->qstats;
-       int ret;
-
-       if (res->ingress)
-               ret = netif_receive_skb(skb);
-       else
-               ret = dev_queue_xmit(skb);
-       if (ret && stats)
-               qstats_overlimit_inc(res->qstats);
+       return res->ingress ? netif_receive_skb(skb) : dev_queue_xmit(skb);
 }
 
 #endif
index 49a378a5b4fa56ee182fb2a78676ac1229763e4d..ae1129aaf3c0ec7439e602ddc7175f02df436594 100644 (file)
@@ -289,8 +289,8 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
                /* let's the caller reinsert the packet, if possible */
                if (use_reinsert) {
                        res->ingress = want_ingress;
-                       res->qstats = this_cpu_ptr(m->common.cpu_qstats);
-                       skb_tc_reinsert(skb, res);
+                       if (skb_tc_reinsert(skb, res))
+                               tcf_action_inc_overlimit_qstats(&m->common);
                        __this_cpu_dec(mirred_rec_level);
                        return TC_ACT_CONSUMED;
                }