tech-net archive

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

Re: ifconfig not waiting for DAD completion



Hi

On 27/11/2015 00:29, Anthony Mallet wrote:
> When my wm(4) interface goes from down to up, it first enters a 'detached'
> state for 1s or so, then the carrier is detected and the interface goes to the
> ipv6 'tentative' state.

I believe this behaviour is true for all interfaces, it's not specific
to wm(4).

The best way of fixing this is to reduce this window to zero because
it's a small lie - kernel is telling userland the link is down when it's
really up.
I don't know how to start doing that though .... I suspect each driver
would need to be touched somewhere.

> The detached state is long enough for ifconfig -w in /etc/rc.d/network to not
> wait at all for DAD (the interface is still 'detached' when ifconfig -w runs).
> 
> This then leads to unexpected delays (~30s) in e.g. /etc/rc.d/mountall with an
> NFS filesystem. (The machine is in ip6mode=host).
> 
> I tried the following quick patch to ifconfig(8) so that ifconfig -w waits for
> DAD completion only once DAD has started. Does this look like the proper fix?
> 
> Index: sbin/ifconfig/af_inet6.c
> ===================================================================
> RCS file: /cvsroot/src/sbin/ifconfig/af_inet6.c,v
> retrieving revision 1.33
> diff -u -r1.33 af_inet6.c
> --- sbin/ifconfig/af_inet6.c  12 May 2015 14:05:29 -0000      1.33
> +++ sbin/ifconfig/af_inet6.c  27 Nov 2015 00:05:46 -0000
> @@ -489,7 +489,7 @@
>         ifr.ifr_addr = *(struct sockaddr_in6 *)ifa->ifa_addr;
>         if (prog_ioctl(s, SIOCGIFAFLAG_IN6, &ifr) == -1)
>                 err(EXIT_FAILURE, "SIOCGIFAFLAG_IN6");
> -       return ifr.ifr_ifru.ifru_flags6 & IN6_IFF_TENTATIVE ? true : false;
> +       return ifr.ifr_ifru.ifru_flags6 & (IN6_IFF_TENTATIVE|IN6_IFF_DETACHED) ? true : false;
>  }
>  
>  static void

Any fix like this would also be needed in af_inet.c as IPv4 has similar
flags.
But if we do this then I think that ifconfig.c:wait_dad_exec() needs to
test the interface flags for IFF_UP as well.

Not that it helps because when you add an address, the interface is
brought up right away.

I avoided detached originally because I didn't want to wait for a
configured interface without an attached cable because that would just
timeout needlessly. But is that actually desireable behaviour?
This also affects wireless interfaces, so it's not entirely optimal either.

Roy


Home | Main Index | Thread Index | Old Index