if (!dev)
                return 0;
 
-       if (netif_is_vrf(dev))
+       if (netif_is_vrf(dev)) {
                ifindex = dev->ifindex;
-       else {
+       } else {
                vrf_ptr = rcu_dereference(dev->vrf_ptr);
                if (vrf_ptr)
                        ifindex = vrf_ptr->ifindex;
        return ifindex;
 }
 
+static inline int vrf_master_ifindex(const struct net_device *dev)
+{
+       int ifindex;
+
+       rcu_read_lock();
+       ifindex = vrf_master_ifindex_rcu(dev);
+       rcu_read_unlock();
+
+       return ifindex;
+}
+
 /* called with rcu_read_lock */
 static inline int vrf_dev_table_rcu(const struct net_device *dev)
 {
        return 0;
 }
 
+static inline int vrf_master_ifindex(const struct net_device *dev)
+{
+       return 0;
+}
+
 static inline int vrf_dev_table_rcu(const struct net_device *dev)
 {
        return 0;
 
        fl4.flowi4_mark = mark;
        fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos);
        fl4.flowi4_proto = IPPROTO_ICMP;
-       fl4.flowi4_oif = vrf_master_ifindex_rcu(skb->dev) ? : skb->dev->ifindex;
+       fl4.flowi4_oif = vrf_master_ifindex(skb->dev) ? : skb->dev->ifindex;
        security_skb_classify_flow(skb, flowi4_to_flowi(&fl4));
        rt = ip_route_output_key(net, &fl4);
        if (IS_ERR(rt))
        fl4->flowi4_proto = IPPROTO_ICMP;
        fl4->fl4_icmp_type = type;
        fl4->fl4_icmp_code = code;
-       fl4->flowi4_oif = vrf_master_ifindex_rcu(skb_in->dev) ? : skb_in->dev->ifindex;
+       fl4->flowi4_oif = vrf_master_ifindex(skb_in->dev) ? : skb_in->dev->ifindex;
 
        security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));
        rt = __ip_route_output_key(net, fl4);