[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: ping6 -I eth0 ::1 is not working in the busybox-1.13.4
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2009-05-24 0:44:50
Message-ID: 200905240244.50096.vda.linux () googlemail ! com
[Download RAW message or body]

On Friday 22 May 2009 12:11, Gayathri Manoj wrote:
> Hi all,
> 
> I have executed ping6 -I eth0 ::1 (ping6 in  busybox-1.13.4). But not giving
> the response. The same command working fine, if we are using ping6 in the
> busybox-1.4.2 version.
> 
> Error Message.
> -bash-3.2# ping6 -I eth0 ::1
> PING ::1 (::1): 56 data bytes
> ping6: sendto: Network is unreachable
> -bash-3.2#
> 
> I am  able to ping if the interface name is lo.
> 
> -bash-3.2# ping6 -I eth0 ::1
> PING ::1 (::1): 56 data bytes
> ping6: sendto: Network is unreachable
> -bash-3.2# ping6 -I lo ::1
> PING ::1 (::1): 56 data bytes
> 64 bytes from ::1: seq=0 ttl=64 time=0.396 ms
> 
> Please let me know is this one is a bug or a built in behavior?.

Assuming that ::1 is configured on lo, it looks like a sensible behavior:

# ip a
1: lo: <LOOPBACK,UP,10000> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: if: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:1d:7d:c2:ec:70 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.1/24 brd 192.168.0.255 scope global if
    inet 10.0.0.1/24 brd 10.0.0.255 scope global if

This is how it happens:

# strace ./busybox ping6 -I if ::1 -c1
...
write(1, "PING ::1 (::1): 56 data bytes\n", 30) = 30
socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6) = 3
getuid32()                              = 0
setuid32(0)                             = 0
setsockopt(3, SOL_SOCKET, SO_BINDTODEVICE, \
"if\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\3\0\0\0hz\357\377"..., 32) = 0 setsockopt(3, \
SOL_ICMPV6, 1, "\377\377\377\377\377\377\377\377\377\377\377\377\377\377"..., 32) = 0 \
setsockopt(3, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0 setsockopt(3, SOL_SOCKET, \
SO_RCVBUF, [7280], 4) = 0 setsockopt(3, SOL_RAW, 0x7 /* RAW_??? */, [2], 4) = 0
setsockopt(3, SOL_IPV6, IPV6_HOPLIMIT, [1], 4) = 0
rt_sigaction(SIGINT, {0x80662f2, [INT], SA_RESTORER|SA_RESTART, 0x8048683}, \
{SIG_DFL}, 8) = 0 clock_gettime(0x1 /* CLOCK_??? */, {65274, 913847889}) = 0
sendto(3, "\200\0\0\0\205I\0\0007$\2602\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 64, 0, \
{sa_family=AF_INET6, sin6_port=htons(0), inet_pton(AF_INET6, write(2, "ping6: sendto: \
Network is unreac"..., 38) = 38 _exit(1)                                = ?


> The following command is also working fine. ie by using ipv4 address in
> place of the interface name.
> -bash-3.2# ping6 -I 43.88.101.207 ::1
> PING ::1 (::1): 56 data bytes
> 64 bytes from ::1: seq=0 ttl=64 time=0.334 ms

Actually, it works because it ignores -I with wrong address family.
This code does it in ping.c:

      if (source_lsa && source_lsa->u.sa.sa_family != lsa->u.sa.sa_family)
              /* leaking it here... */
              source_lsa = NULL;

Otherwise, it will later try to bind IPv6 ICMP socket to IPv4 address,
and that doesn't work.
--
vda
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic