Hello,
On Tue, 23 Jun 2015, Willem de Bruijn wrote:
> > It is using IP_RECVERR and may be relying only on
> > original address returned in msg_name from MSG_ERRQUEUE.
>
> It's not very important, in that even if ping does not use this
> msg_name, another tool very well might. But from ping.c in that
> srpm:
>
> res = recvmsg(icmp_sock, &msg, MSG_ERRQUEUE|MSG_DONTWAIT);
> ...
> e = NULL;
> for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg,
> cmsg)) {
> if (cmsg->cmsg_level == SOL_IP) {
> if (cmsg->cmsg_type == IP_RECVERR)
> e = (struct sock_extended_err
> *)CMSG_DATA(cmsg);
> }
> }
> ...
> } else if (e->ee_origin == SO_EE_ORIGIN_ICMP) {
> struct sockaddr_in *sin = (struct sockaddr_in*)(e+1);
> ...
It is used, it compares the embedded original address
from error message here (msg.msg_name = (void*)&target):
target.sin_addr.s_addr != whereto.sin_addr.s_addr
and it does not match because kernel failed to fill the
msg_name buffer. In fact, kernel returns msg_namelen=0 but
it is not checked here, so may be ping.c compares random memory.
> printf("From %s icmp_seq=%u ",
> pr_addr(sin->sin_addr.s_addr), ntohs(icmph.un.echo.sequence));
What you are referring here is the offender address (sin),
the sender of the ICMP error, it is just printed...
Regards
--
Julian Anastasov <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html