ping: set not only IP_TTL, but also IP_MULTICAST_TTL
authorDenys Vlasenko <dvlasenk@redhat.com>
Mon, 29 Nov 2010 11:07:12 +0000 (12:07 +0100)
committerDenys Vlasenko <dvlasenk@redhat.com>
Mon, 29 Nov 2010 11:07:12 +0000 (12:07 +0100)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
networking/ping.c

index 8571d179b067bd1daaef3ec48ab12edafda238cc..7f74c26fa5c355e8a4bfb42f7582005f79a52cd6 100644 (file)
@@ -675,9 +675,11 @@ static void ping4(len_and_sockaddr *lsa)
        sockopt = (datalen * 2) + 7 * 1024; /* giving it a bit of extra room */
        setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, &sockopt, sizeof(sockopt));
 
-       if (opt_ttl != 0)
-               //setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_TTL, &opt_ttl, sizeof(opt_ttl));
+       if (opt_ttl != 0) {
                setsockopt(pingsock, IPPROTO_IP, IP_TTL, &opt_ttl, sizeof(opt_ttl));
+               /* above doesnt affect packets sent to bcast IP, so... */
+               setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_TTL, &opt_ttl, sizeof(opt_ttl));
+       }
 
        signal(SIGINT, print_stats_and_exit);