ping -I br0 <ip of br0> doesn't work. Setup: brctl addbr br0 ifconfig br0 192.168.7.1 busybox ping -I br0 192.168.7.1 With ping from iputils this works like a charm. I've tested this against both 1.25.1 and 1.22.1 on MIPS and x86.
(In reply to Markus Gothe from comment #0) Can't reproduce: it works for me just fine on current git. Can you reproduce it with current git? If yes, please post the strace of the failing ping.
Created attachment 6821 [details] strace of ping Output of sudo strace -vvv -ff -o ping.log ./busybox ping -I br0 192.168.7.1
(In reply to Markus Gothe from comment #2) Ok, I was wrong: I tried it without -I br0. With -I br0, bbox ping fails for me too. And it's probably not a bug. Pinging (one of) your own IP does not go over any physical interface, it goes over loopback: kernel definitely doesn't send any packets over the network, it simply feeds TX packet back to RX code. Tried "ping -I lo" in your case and it works. Now, why iputils works? bbox code does setsockopt(0, SOL_SOCKET, SO_BINDTODEVICE, "br\0\0\0", 32) to instruct kernel to use a specific iface. iputils does: setsockopt(5, SOL_SOCKET, SO_BINDTODEVICE, [3175010], 4) See that 4? This is not a correct length for this setsockopt! (3175010 is a misdecoded string "br0\0"). This setsockop has no effect, kernel still will use whichever iface it wants. Proof: try "ping -I eth0": it will still "successcully" ping br0's IP!
(In reply to Denys Vlasenko from comment #3) I challenge you: markus@markus:~/development/branches/9.0.x/TINYAC$ ping -I br0 192.168.7.1 PING 192.168.7.1 (192.168.7.1) from 192.168.7.1 br0: 56(84) bytes of data. 64 bytes from 192.168.7.1: icmp_req=1 ttl=64 time=0.020 ms 64 bytes from 192.168.7.1: icmp_req=2 ttl=64 time=0.034 ms 64 bytes from 192.168.7.1: icmp_req=3 ttl=64 time=0.027 ms 64 bytes from 192.168.7.1: icmp_req=4 ttl=64 time=0.032 ms ^C --- 192.168.7.1 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 2997ms rtt min/avg/max/mdev = 0.020/0.028/0.034/0.006 ms markus@markus:~/development/branches/9.0.x/TINYAC$ ping -I eth0 192.168.7.1 PING 192.168.7.1 (192.168.7.1) from 192.168.7.1 eth0: 56(84) bytes of data. From 10.10.10.3 icmp_seq=1 Destination Host Unreachable From 10.10.10.3 icmp_seq=2 Destination Host Unreachable From 10.10.10.3 icmp_seq=3 Destination Host Unreachable ^C --- 192.168.7.1 ping statistics --- 5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4024ms An strace gives me this: setsockopt(4, SOL_SOCKET, SO_BINDTODEVICE, "eth0\0", 5) = 0
# ifconfig br0 1.1.1.1 # ip a ... 4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000 link/ether ba:2b:a0:03:d0:43 brd ff:ff:ff:ff:ff:ff inet 1.1.1.1/8 brd 1.255.255.255 scope global br0 valid_lft forever preferred_lft forever # busybox ping -I eth0 1.1.1.1 PING 1.1.1.1 (1.1.1.1): 56 data bytes ^C --- 1.1.1.1 ping statistics --- 5 packets transmitted, 0 packets received, 100% packet loss # ping -I eth0 1.1.1.1 PING 1.1.1.1 (1.1.1.1) from 10.34.1.104 eth0: 56(84) bytes of data. 64 bytes from 1.1.1.1: icmp_seq=1 ttl=64 time=0.062 ms 64 bytes from 1.1.1.1: icmp_seq=2 ttl=64 time=0.057 ms 64 bytes from 1.1.1.1: icmp_seq=3 ttl=64 time=0.058 ms ^C # ping -V ping utility, iputils-s20160308
Also, you can use tcpdump and see that ping packets do, in fact, use loopback interface, not br0 or eth0.