[SRU][F:linux-bluefield][PATCH V2 6/9] net/sched: act_mirred: refactor the handle of xmit

Bodong Wang bodong at nvidia.com
Wed Sep 1 17:14:17 UTC 2021


From: wenxu <wenxu at ucloud.cn>

BugLink: https://bugs.launchpad.net/bugs/1940872

This one is prepare for the next patch.

Signed-off-by: wenxu <wenxu at ucloud.cn>
Signed-off-by: Jakub Kicinski <kuba at kernel.org>
(cherry picked from fa6d639930ee5cd3f932cc314f3407f07a06582d)
Signed-off-by: Bodong Wang <bodong at nvidia.com>
---
 include/net/sch_generic.h |  5 -----
 net/sched/act_mirred.c    | 21 +++++++++++++++------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 75e0781..77ab4e8 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -1319,9 +1319,4 @@ void mini_qdisc_pair_init(struct mini_Qdisc_pair *miniqp, struct Qdisc *qdisc,
 void mini_qdisc_pair_block_init(struct mini_Qdisc_pair *miniqp,
 				struct tcf_block *block);
 
-static inline int skb_tc_reinsert(struct sk_buff *skb, struct tcf_result *res)
-{
-	return res->ingress ? netif_receive_skb(skb) : dev_queue_xmit(skb);
-}
-
 #endif
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 6556003..b73bfef 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -205,6 +205,18 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
 	return err;
 }
 
+static int tcf_mirred_forward(bool want_ingress, struct sk_buff *skb)
+{
+	int err;
+
+	if (!want_ingress)
+		err = dev_queue_xmit(skb);
+	else
+		err = netif_receive_skb(skb);
+
+	return err;
+}
+
 static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
 			  struct tcf_result *res)
 {
@@ -289,18 +301,15 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
 			if (want_ingress)
 				nf_reset_ct(skb);
 			res->ingress = want_ingress;
-			if (skb_tc_reinsert(skb, res))
+			err = tcf_mirred_forward(res->ingress, skb);
+			if (err)
 				tcf_action_inc_overlimit_qstats(&m->common);
 			__this_cpu_dec(mirred_rec_level);
 			return TC_ACT_CONSUMED;
 		}
 	}
 
-	if (!want_ingress)
-		err = dev_queue_xmit(skb2);
-	else
-		err = netif_receive_skb(skb2);
-
+	err = tcf_mirred_forward(want_ingress, skb2);
 	if (err) {
 out:
 		tcf_action_inc_overlimit_qstats(&m->common);
-- 
1.8.3.1




More information about the kernel-team mailing list