aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/icmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/icmp.c')
-rw-r--r--net/ipv6/icmp.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 8d7b113958b1..4f82830fc068 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -459,9 +459,20 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
* Source addr check
*/
- if (__ipv6_addr_needs_scope_id(addr_type))
+ if (__ipv6_addr_needs_scope_id(addr_type)) {
iif = skb->dev->ifindex;
- else {
+
+ /* for local packets, get the real device index */
+ if (iif == LOOPBACK_IFINDEX) {
+ dst = skb_dst(skb);
+ if (dst) {
+ struct rt6_info *rt;
+
+ rt = container_of(dst, struct rt6_info, dst);
+ iif = rt->rt6i_idev->dev->ifindex;
+ }
+ }
+ } else {
dst = skb_dst(skb);
iif = l3mdev_master_ifindex(dst ? dst->dev : skb->dev);
}