Why do we do if_init for AF_INET even if the interface is running?

Sam Leffler sam at errno.com
Tue Jun 13 04:53:05 UTC 2006


Xin LI wrote:
> Hi,
> 
> Is there any reason why we do if_init() for AF_INET regardless whether
> the interface is already in IF_DRV_RUNNING?  This seems to cause the
> interface to reinitialize its link level state, which causes the network
> to stop for a short while.
> 
> The proposed patch is inspired from NetBSD net/if_ethersubr.c,v 1.86
> which says:
> 
> "When setting an address on an interface, for address families which
> do not require changing the link-level address, only (*if_init)()
> if the interface is not already RUNNING."
> 
> I think we may want this as well.
> 
> Comments?
> 
> Cheers,
> 
> 
> ------------------------------------------------------------------------
> 
> Index: if_ethersubr.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v
> retrieving revision 1.215
> diff -u -r1.215 if_ethersubr.c
> --- if_ethersubr.c	3 Mar 2006 17:21:08 -0000	1.215
> +++ if_ethersubr.c	13 Jun 2006 01:55:31 -0000
> @@ -997,7 +997,8 @@
>  		switch (ifa->ifa_addr->sa_family) {
>  #ifdef INET
>  		case AF_INET:
> -			ifp->if_init(ifp->if_softc);	/* before arpwhohas */
> +			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
> +				ifp->if_init(ifp->if_softc);	/* before arpwhohas */
>  			arp_ifinit(ifp, ifa);
>  			break;
>  #endif
> @@ -1027,7 +1028,8 @@
>  			}
>  #endif
>  		default:
> -			ifp->if_init(ifp->if_softc);
> +			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
> +				ifp->if_init(ifp->if_softc);
>  			break;
>  		}
>  		break;

Try it; you'll find various drivers blow up in their multicast code
because they assume the init method is called.  I tried to get this same
change committed last year because it causes wireless drivers to blow
chunks.  I finally gave up and stuck a similar change in ieee80211_ioctl.

	Sam



More information about the freebsd-arch mailing list