[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: broken IPv6 code (attached exampled app)



itojun@iijlab.net wrote:
> option 1: getaddrinfo returns ::, then 0.0.0.0
> option 2: getaddrinfo returns 0.0.0.0, then ::
> option 3: getaddrinfo returns :: only
> option 4: getaddrinfo returns 0.0.0.0 only
>         (RFC2553 does not say we must return both!)
> 
> option a: kernel forbids bind(0.0.0.0) after bind(::), but
>         bind(::) after bind(0.0.0.0) is okay
> option b: kernel forbids bind(::) after bind(0.0.0.0)
>         bind(0.0.0.0) after bind(::) is okay
> option c: only one of them is allowed
> option d: kernel works okay with any order
> 
> 1 + a -> only bind(::) will success
> 1 + b -> both okay
> 1 + c -> only bind(::) will success
> 1 + d -> both okay
> 2 + a -> both okay
> 2 + b -> only bind(0.0.0.0) will success
> 2 + c -> only bind(0.0.0.0) will success
> 2 + d -> both okay
> 3 + * -> only bind(::) will success
> 4 + * -> only bind(0.0.0.0) will success

> for userland programmer:
> 
> what you may want to do is to ignore bind(2) failures, and die only
> when you have no listening sockets.  this is the best thing you can
> do when you have no assumption on the kernel.  you may not be able to
> receive all inbound traffic to the port, but if there's no standard,
> what we can do?
That's what I am doing now, but I am just ignoring this specific case: IPv4 bind
causing error 98 ("Address already in use"). Should it be ignored for other
cases too ? Is there any system that does (a) or (b) ? At the moment, my
handling seems to be OK for Linux (seems to do 1 + c according to YOSHIFUJI
Hideaki) and KAME, which seems to do 1 + d. Are there other combinations
implemented ?

best greets,
Rene



Reply to: