summaryrefslogtreecommitdiffstats
path: root/sys/netatm
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2003-07-24 11:17:36 +0000
committerharti <harti@FreeBSD.org>2003-07-24 11:17:36 +0000
commitf0c745cd0fc26c1c0e59ccebf9b4908b0f06e02e (patch)
treef369f35b77af265c9ce3b0a9f2ed67614b159880 /sys/netatm
parentccd8ed8347367abfdb995ce404adf92247ad7e58 (diff)
downloadFreeBSD-src-f0c745cd0fc26c1c0e59ccebf9b4908b0f06e02e.zip
FreeBSD-src-f0c745cd0fc26c1c0e59ccebf9b4908b0f06e02e.tar.gz
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
Diffstat (limited to 'sys/netatm')
-rw-r--r--sys/netatm/atm_if.c100
1 files changed, 5 insertions, 95 deletions
diff --git a/sys/netatm/atm_if.c b/sys/netatm/atm_if.c
index 52e2362..c8f7065 100644
--- a/sys/netatm/atm_if.c
+++ b/sys/netatm/atm_if.c
@@ -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
- */
- 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...
+ * Free all interface routes and addresses,
+ * delete all remaining routes using this interface,
+ * then remove from the system interface list
*/
- 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
*
OpenPOWER on IntegriCloud