]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/sched/act_mirred.c
Merge tag 'drm/tegra/for-5.6-rc1-fixes' of git://anongit.freedesktop.org/tegra/linux...
[linux.git] / net / sched / act_mirred.c
index 1e3eb3a975324a2630f1b66f08655ea6de8d331c..1ad300e6dbc0a0bfad2c278101e6f3446752ec2e 100644 (file)
@@ -219,8 +219,10 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
        bool use_reinsert;
        bool want_ingress;
        bool is_redirect;
+       bool expects_nh;
        int m_eaction;
        int mac_len;
+       bool at_nh;
 
        rec_level = __this_cpu_inc_return(mirred_rec_level);
        if (unlikely(rec_level > MIRRED_RECURSION_LIMIT)) {
@@ -261,19 +263,19 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
                        goto out;
        }
 
-       /* If action's target direction differs than filter's direction,
-        * and devices expect a mac header on xmit, then mac push/pull is
-        * needed.
-        */
        want_ingress = tcf_mirred_act_wants_ingress(m_eaction);
-       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);
+
+       expects_nh = want_ingress || !m_mac_header_xmit;
+       at_nh = skb->data == skb_network_header(skb);
+       if (at_nh != expects_nh) {
+               mac_len = skb_at_tc_ingress(skb) ? skb->mac_len :
+                         skb_network_header(skb) - skb_mac_header(skb);
+               if (expects_nh) {
+                       /* target device/action expect data at nh */
                        skb_pull_rcsum(skb2, mac_len);
                } else {
-                       /* caught at ingress, act egress: push mac */
-                       skb_push_rcsum(skb2, skb->mac_len);
+                       /* target device/action expect data at mac */
+                       skb_push_rcsum(skb2, mac_len);
                }
        }