I claim an IPv6 address using ifconfig in a script. This address is then immediately used to listen on a TCP port.
When I write the script like this, it fails because the service is unable to listen:
ifconfig igb0 inet6 2001:db8::10/64 add
service my_service start #fails
However, it succeeds when I do it like this:
ifconfig igb0 inet6 2001:db8::10/64 add
sleep 1
service my_service start
I tried writing the output of ifconfig directly after running the add-operation. It appears that ifconfig reports the IP-address as being tentative, which apparently prevents a service from listening on it.
Naturally, waiting exactly one second and hoping that the address has become available is not a very good way to handle this. How can I wait for a tentative address to become available, or make ifconfig return later so that the address is all set up?