0

I have some problem to understand an issue which concerns fallback mechanism in network communication.

Setup : Embedded device (mips) with uclibc and busybox

I am a client with ipv6 adress. I need to contact a service on xxx.com. When I test the hostname of my service with nslookup. I got two result, an ipv4 and an ipv6 address. So I got two ways to contact my server.

In my understanding, I got this result thanks to the dns mechanism which read my resolv.conf file and contact dns server by socket to get ip which are associated with the hostname requested

test : I run ping6 -I eth0 myservice.com

I watch this command thanks to strace. The result is :

execve("/bin/ping6", ["ping6", "-I", "eth0", "myservice"], [/* 7 vars */]) = 0
...
open("/etc/resolv.conf", O_RDONLY)
...
socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("192.168.20.20")}, 28) = 0
   -> **192.168.20.20** is my dns server ip fill in resolv.conf
...
send(3, "myservice.."..., 33, 0) = 33
poll([{fd=3, events=POLLIN}], 1, 5000)  = 1 ([{fd=3, revents=POLLIN}])
recv(3, "myservice.."..., 512, MSG_DONTWAIT) = 285
...
sendto(3, "\200\0\0\0iD\0\0\335\2130\7\0\0\0\0\0\0\0\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, "**Y:Y:Y:Y:Y:Y:Y:Y**", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=2}, 28) = -1 ENETUNREACH (Network is unreachable)
write(2, "ping6: sendto: Network is unreac"..., 38) = 38
exit_group(1)    

For some reason, I cannot contact the server myservice by ipv6 Y:Y:Y:Y:Y:Y:Y:Y. In my opinion, there are a fallback mechanism which allow me to contact my server by ipv4 when ipv6 way failed. Unfortunately, as you can see, after the ipv6 try, I cannot see any tries on ipv4 way.

Question : Is it normal to get this current behavior about this ? Where must be implement this mechanism of fallback ? Inside my busybox on ping code side. Inside uclibc thanks to the dns mechanism ? Somewhere else ?

Thanks, Arthur.

ArthurLambert
  • 749
  • 1
  • 7
  • 30

1 Answers1

2

That's probably because you're using ping6, which will only do IPv6 (and ping only does IPv4).

The implementation of the fallback mechanism will be up to you. You already understand how to retrieve multiple addresses from a name lookup, so now all that's left is to try each of those until you manage to connect.

Kristof Provost
  • 26,018
  • 2
  • 26
  • 28
  • You might also want to check your v6 network setup. Clearly something is wrong (do you have a default route on v6?). – Kristof Provost Nov 08 '13 at 11:53
  • So let's me summarize. First your are telling me that my way to test the fallback feature is wrong because ping6 will only try to connect to my server by using IPv6. Then you are telling me that all service have to implement the fallback mechanism by itself. So it is not a Uclibc missing feature. I have to do it by myself. But why not implement this mechanism directly in dns resolv feature instead of implement it on each services ? – ArthurLambert Nov 12 '13 at 09:59
  • Correct. There's not much to it: all you have to do is re-try the connection with the next result from the DNS lookup. This is not implemented in the C library because it's up to you to decide what to do if you fail to connect to the first address returned by DNS. – Kristof Provost Nov 12 '13 at 10:12