net: fib: move metrics parsing to a helper
[firefly-linux-kernel-4.4.55.git] / net / ipv4 / ip_output.c
index 6bf89a6312bc1c71da41ad0a1ebdbf819504367d..0138fada0951b17b175be0b215c248fc7224dc5a 100644 (file)
@@ -1542,6 +1542,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
        struct net *net = sock_net(sk);
        struct sk_buff *nskb;
        int err;
+       int oif;
 
        if (__ip_options_echo(&replyopts.opt.opt, skb, sopt))
                return;
@@ -1559,7 +1560,11 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
                        daddr = replyopts.opt.opt.faddr;
        }
 
-       flowi4_init_output(&fl4, arg->bound_dev_if,
+       oif = arg->bound_dev_if;
+       if (!oif && netif_index_is_vrf(net, skb->skb_iif))
+               oif = skb->skb_iif;
+
+       flowi4_init_output(&fl4, oif,
                           IP4_REPLY_MARK(net, skb->mark),
                           RT_TOS(arg->tos),
                           RT_SCOPE_UNIVERSE, ip_hdr(skb)->protocol,