1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-27 16:39:08 +00:00

Now that we have if_detach() don't try to get rid of all the interface

stuff (routes, ...) by hand - simply use if_detach().

Submitted by:	Vincent Jardin <vjardin@wanadoo.fr>
MFC after:	2 week
This commit is contained in:
Hartmut Brandt 2003-07-24 11:17:36 +00:00
parent fe468ebbfb
commit fb4304eca0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=117967

View File

@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$");
* Local functions
*/
static int atm_physif_ioctl(int, caddr_t, caddr_t);
static int atm_netif_rtdel(struct radix_node *, void *);
static int atm_if_ioctl(struct ifnet *, u_long, caddr_t);
static int atm_ifparse(char *, char *, int, int *);
@ -830,12 +829,8 @@ atm_nif_detach(nip)
struct atm_nif *nip;
{
struct atm_ncm *ncp;
int s, i;
int s;
struct ifnet *ifp = &nip->nif_if;
struct ifaddr *ifa;
struct in_ifaddr *ia;
struct radix_node_head *rnh;
s = splimp();
@ -852,50 +847,11 @@ atm_nif_detach(nip)
bpfdetach(ifp);
/*
* Mark interface down
* Free all interface routes and addresses,
* delete all remaining routes using this interface,
* then remove from the system interface list
*/
if_down(ifp);
/*
* Free all interface routes and addresses
*/
while (1) {
IFP_TO_IA(ifp, ia);
if (ia == NULL)
break;
/* Delete interface route */
in_ifscrub(ifp, ia);
/* Remove interface address from queues */
ifa = &ia->ia_ifa;
TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
TAILQ_REMOVE(&in_ifaddrhead, ia, ia_link);
/* Free interface address */
IFAFREE(ifa);
}
/*
* Delete all remaining routes using this interface
* Unfortuneatly the only way to do this is to slog through
* the entire routing table looking for routes which point
* to this interface...oh well...
*/
for (i = 1; i <= AF_MAX; i++) {
if ((rnh = rt_tables[i]) == NULL)
continue;
RADIX_NODE_HEAD_LOCK(rnh);
(void) rnh->rnh_walktree(rnh, atm_netif_rtdel, ifp);
RADIX_NODE_HEAD_UNLOCK(rnh);
}
/*
* Remove from system interface list (ie. if_detach())
*/
IFNET_WLOCK();
TAILQ_REMOVE(&ifnet, ifp, if_link);
IFNET_WUNLOCK();
if_detach(ifp);
/*
* Remove from physical interface list
@ -905,52 +861,6 @@ atm_nif_detach(nip)
(void) splx(s);
}
/*
* Delete Routes for a Network Interface
*
* Called for each routing entry via the rnh->rnh_walktree() call above
* to delete all route entries referencing a detaching network interface.
*
* Arguments:
* rn pointer to node in the routing table
* arg argument passed to rnh->rnh_walktree() - detaching interface
*
* Returns:
* 0 successful
* errno failed - reason indicated
*
*/
static int
atm_netif_rtdel(rn, arg)
struct radix_node *rn;
void *arg;
{
struct rtentry *rt = (struct rtentry *)rn;
struct ifnet *ifp = arg;
int err;
if (rt->rt_ifp == ifp) {
/*
* Protect (sorta) against walktree recursion problems
* with cloned routes
*/
if ((rt->rt_flags & RTF_UP) == 0)
return (0);
err = rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway,
rt_mask(rt), rt->rt_flags,
(struct rtentry **) NULL);
if (err) {
log(LOG_WARNING, "atm_netif_rtdel: error %d\n", err);
}
}
return (0);
}
/*
* Set an ATM Network Interface address
*