ping: always initialize ->sin6_scope_id and ->sin6_flowinfo
Cong Wang [Sun, 2 Jun 2013 22:43:52 +0000 (22:43 +0000)]
[net-next commit c26d6b46da3ee86fa8a864347331e5513ca84c2b]

If we don't need scope id, we should initialize it to zero.
Same for ->sin6_flowinfo.

Bug 1412141
Change-Id: I74764edf3d0567f5ae094b2e83484cdfe05f6098
Cc: Lorenzo Colitti <lorenzo@google.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
Acked-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 14e41a18688ec8d52ea3163f7898455b52365854)
Reviewed-on: http://git-master/r/336270
Reviewed-by: Mrutyunjay Sawant <msawant@nvidia.com>
Tested-by: Mrutyunjay Sawant <msawant@nvidia.com>
Reviewed-on: http://git-master/r/337765
Reviewed-by: Om Prakash Singh <omp@nvidia.com>
Tested-by: Om Prakash Singh <omp@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>

net/ipv4/ping.c

index 229cb2c..3d6cf7f 100644 (file)
@@ -898,13 +898,13 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                sin6->sin6_port = 0;
                sin6->sin6_addr = ip6->saddr;
 
+               sin6->sin6_flowinfo = 0;
                if (np->sndflow)
                        sin6->sin6_flowinfo =
                                *(__be32 *)ip6 & IPV6_FLOWINFO_MASK;
 
-               if (__ipv6_addr_needs_scope_id(
-                   ipv6_addr_type(&sin6->sin6_addr)))
-                       sin6->sin6_scope_id = IP6CB(skb)->iif;
+               sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr,
+                                                         IP6CB(skb)->iif);
 
                if (inet6_sk(sk)->rxopt.all)
                        pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);