Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Dec 1999 22:50:11 -0500 (EST)
From:      Andrew Gallatin <gallatin@cs.duke.edu>
To:        Jonathan Lemon <jlemon@americantv.com>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: The if_detach problem
Message-ID:  <14423.3759.258444.555708@grasshopper.cs.duke.edu>
In-Reply-To: <19991214160454.26093@right.PCS>
References:  <imp@village.org> <199912142145.VAA34161@hak.lan.Awfulhak.org> <19991214160454.26093@right.PCS>

next in thread | previous in thread | raw e-mail | index | archive | help

Jonathan Lemon writes:
 > > Is there a lot to be gained by removing interfaces ?
 > 
 > Loadable device drivers.  I ran into this last week or so when
 > unloading a driver I'm developing; if I don't do an 'ifconfig xxx delete'
 > before the kldunoad, I get a panic.

I have the following code in a loadable (IP-only, not ethernet) driver
of mine.  It doesn't crash on unload anymore.  However, I think
something like this should be standard & available for (un)loadable
drivers to call at unload time:

	s = splnet();
        /*
         * Close down routes etc.
	 * This needs to be at splnet
         */
	TAILQ_FOREACH(ifp, &ifnet, if_link){
		if(ifp == &sc->myri_if){
			ifp_valid = 1;
			break;
		}
	}
	if(ifp_valid){
		struct ifaddr *ia = 0;
		struct in_ifaddr *in_ia = 0;
		ifp = &sc->myri_if;

		TAILQ_FOREACH(ia, &ifp->if_addrhead, ifa_link){
			if (ia->ifa_addr->sa_family != AF_INET)
                                continue;
			in_ia = (struct in_ifaddr *)ia;
			in_ifscrub(ifp, in_ia);
			TAILQ_REMOVE(&in_ifaddrhead, in_ia, ia_link);
		}
		if_detach(&sc->myri_if);
	}
	splx(s);

Cheers,

Drew
------------------------------------------------------------------------------
Andrew Gallatin, Sr Systems Programmer	http://www.cs.duke.edu/~gallatin
Duke University				Email: gallatin@cs.duke.edu
Department of Computer Science		Phone: (919) 660-6590






To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14423.3759.258444.555708>