summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2005-09-29 20:57:07 +0000
committerRobert Watson <rwatson@FreeBSD.org>2005-09-29 20:57:07 +0000
commit06a775e5aa7d2daf1d189f12b9488aac308c9fd1 (patch)
tree69b0acdcc91e38a436abdcc4ac3565cb6108e3e3
parent61d52c96a36b1e6603f6ce427b520a9c465ed8cf (diff)
Notes
-rw-r--r--sys/net/if.c7
-rw-r--r--sys/netinet/in.c20
-rw-r--r--sys/netinet/in.h1
3 files changed, 20 insertions, 8 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 9c2121a35e28..11922780ee4e 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -600,6 +600,9 @@ if_purgeaddrs(struct ifnet *ifp)
/*
* Detach an interface, removing it from the
* list of "active" interfaces and freeing the struct ifnet.
+ *
+ * XXXRW: There are some significant questions about event ordering, and
+ * how to prevent things from starting to use the interface during detach.
*/
void
if_detach(struct ifnet *ifp)
@@ -637,6 +640,10 @@ if_detach(struct ifnet *ifp)
if_purgeaddrs(ifp);
+#ifdef INET
+ in_ifdetach(ifp);
+#endif
+
#ifdef INET6
/*
* Remove all IPv6 kernel structs related to ifp. This should be done
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index c5d148a1fe07..2eb5e94fce74 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -459,14 +459,6 @@ in_control(so, cmd, data, ifp, td)
* a routing process they will come back.
*/
in_ifadown(&ia->ia_ifa, 1);
- /*
- * XXX horrible hack to detect that we are being called
- * from if_detach()
- */
- if (ifaddr_byindex(ifp->if_index) == NULL) {
- in_pcbpurgeif0(&ripcbinfo, ifp);
- in_pcbpurgeif0(&udbinfo, ifp);
- }
EVENTHANDLER_INVOKE(ifaddr_event, ifp);
error = 0;
break;
@@ -1046,3 +1038,15 @@ in_delmulti(inm)
igmp_leavegroup(&my_inm);
IN_MULTI_UNLOCK();
}
+
+/*
+ * On interface removal, clean up IPv4 data structures hung off of the ifnet.
+ */
+void
+in_ifdetach(ifp)
+ struct ifnet *ifp;
+{
+
+ in_pcbpurgeif0(&ripcbinfo, ifp);
+ in_pcbpurgeif0(&udbinfo, ifp);
+}
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index 45c269ca89ae..7322c3044973 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -571,6 +571,7 @@ int in_localaddr(struct in_addr);
int in_localip(struct in_addr);
char *inet_ntoa(struct in_addr); /* in libkern */
char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
+void in_ifdetach(struct ifnet *);
#define in_hosteq(s, t) ((s).s_addr == (t).s_addr)
#define in_nullhost(x) ((x).s_addr == INADDR_ANY)