return sizeof(struct arphdr) + (dev->addr_len + sizeof(u32)) * 2;
        }
 }
+
+static inline bool dev_is_mac_header_xmit(const struct net_device *dev)
+{
+       switch (dev->type) {
+       case ARPHRD_TUNNEL:
+       case ARPHRD_TUNNEL6:
+       case ARPHRD_SIT:
+       case ARPHRD_IPGRE:
+       case ARPHRD_VOID:
+       case ARPHRD_NONE:
+               return false;
+       default:
+               return true;
+       }
+}
+
 #endif /* _LINUX_IF_ARP_H */
 
 #include <linux/inet.h>
 #include <linux/netdevice.h>
 #include <linux/if_packet.h>
+#include <linux/if_arp.h>
 #include <linux/gfp.h>
 #include <net/ip.h>
 #include <net/protocol.h>
 static int __bpf_redirect(struct sk_buff *skb, struct net_device *dev,
                          u32 flags)
 {
-       switch (dev->type) {
-       case ARPHRD_TUNNEL:
-       case ARPHRD_TUNNEL6:
-       case ARPHRD_SIT:
-       case ARPHRD_IPGRE:
-       case ARPHRD_VOID:
-       case ARPHRD_NONE:
-               return __bpf_redirect_no_mac(skb, dev, flags);
-       default:
+       if (dev_is_mac_header_xmit(dev))
                return __bpf_redirect_common(skb, dev, flags);
-       }
+       else
+               return __bpf_redirect_no_mac(skb, dev, flags);
 }
 
 BPF_CALL_3(bpf_clone_redirect, struct sk_buff *, skb, u32, ifindex, u64, flags)
 
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/gfp.h>
+#include <linux/if_arp.h>
 #include <net/net_namespace.h>
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 static unsigned int mirred_net_id;
 static struct tc_action_ops act_mirred_ops;
 
-static bool dev_is_mac_header_xmit(const struct net_device *dev)
-{
-       switch (dev->type) {
-       case ARPHRD_TUNNEL:
-       case ARPHRD_TUNNEL6:
-       case ARPHRD_SIT:
-       case ARPHRD_IPGRE:
-       case ARPHRD_VOID:
-       case ARPHRD_NONE:
-               return false;
-       }
-       return true;
-}
-
 static int tcf_mirred_init(struct net *net, struct nlattr *nla,
                           struct nlattr *est, struct tc_action **a, int ovr,
                           int bind)