[Cake] Fwd: [PATCH net-next 4/4] act_mirred: use ACT_REDIRECT when possible

Dave Taht dave.taht at gmail.com
Mon Jul 16 23:15:52 EDT 2018


oooh!

---------- Forwarded message ---------
From: Paolo Abeni <pabeni at redhat.com>
Date: Fri, Jul 13, 2018 at 2:56 AM
Subject: [PATCH net-next 4/4] act_mirred: use ACT_REDIRECT when possible
To: <netdev at vger.kernel.org>
Cc: Jamal Hadi Salim <jhs at mojatatu.com>, Cong Wang
<xiyou.wangcong at gmail.com>, Jiri Pirko <jiri at resnulli.us>, Alexei
Starovoitov <ast at kernel.org>, Daniel Borkmann <daniel at iogearbox.net>,
Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>


When mirred is invoked from the ingress path, and it wants to redirect
the processed packet, it can now use the ACT_REDIRECT action,
filling the tcf_result accordingly.

This avoids a skb_clone() in the TC S/W data path giving a ~10%
improvement in forwarding performances. Overall TC S/W performances
are now comparable to the kernel openswitch datapath.

Signed-off-by: Paolo Abeni <pabeni at redhat.com>
---
 net/sched/act_mirred.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index eeb335f03102..b19317426117 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -175,6 +175,7 @@ static int tcf_mirred(struct sk_buff *skb, const
struct tc_action *a,
        struct net_device *dev;
        struct sk_buff *skb2;
        int retval, err = 0;
+       bool want_ingress;
        int m_eaction;
        int mac_len;

@@ -185,6 +186,17 @@ static int tcf_mirred(struct sk_buff *skb, const
struct tc_action *a,
        m_eaction = READ_ONCE(m->tcfm_eaction);
        retval = READ_ONCE(m->tcf_action);
        dev = rcu_dereference_bh(m->tcfm_dev);
+       want_ingress = tcf_mirred_act_wants_ingress(m_eaction);
+       if (skb_at_tc_ingress(skb) && tcf_mirred_is_act_redirect(m_eaction)) {
+               skb->tc_redirected = 1;
+               skb->tc_from_ingress = 1;
+
+               /* the core redirect code will check dev and its status */
+               TCF_RESULT_SET_REDIRECT(res, dev, want_ingress);
+               res->qstats = this_cpu_ptr(m->common.cpu_qstats);
+               return TC_ACT_REDIRECT;
+       }
+
        if (unlikely(!dev)) {
                pr_notice_once("tc mirred: target device is gone\n");
                goto out;
@@ -204,8 +216,7 @@ static int tcf_mirred(struct sk_buff *skb, const
struct tc_action *a,
         * and devices expect a mac header on xmit, then mac push/pull is
         * needed.
         */
-       if (skb_at_tc_ingress(skb) != tcf_mirred_act_wants_ingress(m_eaction) &&
-           m_mac_header_xmit) {
+       if (skb_at_tc_ingress(skb) != want_ingress && m_mac_header_xmit) {
                if (!skb_at_tc_ingress(skb)) {
                        /* caught at egress, act ingress: pull mac */
                        mac_len = skb_network_header(skb) - skb_mac_header(skb);
--
2.17.1



-- 

Dave Täht
CEO, TekLibre, LLC
http://www.teklibre.com
Tel: 1-669-226-2619


More information about the Cake mailing list