net: dev_pick_tx() fix

When dev_pick_tx() caches tx queue_index on a socket, we must check
socket dst_entry matches skb one, or risk a crash later, as reported by
Denys Fedorysychenko, if old packets are in flight during a route
change, involving devices with different number of queues.

Bug introduced by commit a4ee3ce3
(net: Use sk_tx_queue_mapping for connected sockets)

Reported-by: Denys Fedorysychenko <nuclearcat@nuclearcat.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Eric Dumazet and committed by David S. Miller 8728c544 4eaa0e3c

+6 -2
+6 -2
net/core/dev.c
··· 1989 1989 if (dev->real_num_tx_queues > 1) 1990 1990 queue_index = skb_tx_hash(dev, skb); 1991 1991 1992 - if (sk && sk->sk_dst_cache) 1993 - sk_tx_queue_set(sk, queue_index); 1992 + if (sk) { 1993 + struct dst_entry *dst = rcu_dereference(sk->sk_dst_cache); 1994 + 1995 + if (dst && skb_dst(skb) == dst) 1996 + sk_tx_queue_set(sk, queue_index); 1997 + } 1994 1998 } 1995 1999 } 1996 2000