Page MenuHomeFreeBSD

D29116.id85362.diff
No OneTemporary

D29116.id85362.diff

Index: sys/net/route.h
===================================================================
--- sys/net/route.h
+++ sys/net/route.h
@@ -429,7 +429,6 @@
void rt_updatemtu(struct ifnet *);
-void rt_flushifroutes_af(struct ifnet *, int);
void rt_flushifroutes(struct ifnet *ifp);
/* XXX MRT NEW VERSIONS THAT USE FIBs
@@ -442,6 +441,7 @@
void rib_free_info(struct rt_addrinfo *info);
/* New API */
+void rib_flush_routes_family(int family);
struct nhop_object *rib_lookup(uint32_t fibnum, const struct sockaddr *dst,
uint32_t flags, uint32_t flowid);
#endif
Index: sys/net/route.c
===================================================================
--- sys/net/route.c
+++ sys/net/route.c
@@ -493,21 +493,6 @@
return (1);
}
-/*
- * 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...
- */
-void
-rt_flushifroutes_af(struct ifnet *ifp, int af)
-{
- KASSERT((af >= 1 && af <= AF_MAX), ("%s: af %d not >= 1 and <= %d",
- __func__, af, AF_MAX));
-
- rib_foreach_table_walk_del(af, rt_ifdelroute, ifp);
-}
-
void
rt_flushifroutes(struct ifnet *ifp)
{
Index: sys/net/route/route_ctl.c
===================================================================
--- sys/net/route/route_ctl.c
+++ sys/net/route/route_ctl.c
@@ -1328,6 +1328,42 @@
NET_EPOCH_EXIT(et);
}
+static int
+rt_delete_unconditional(struct radix_node *rn, void *arg)
+{
+ struct rtentry *rt = RNTORT(rn);
+ struct rib_head *rnh = (struct rib_head *)arg;
+
+ rn = rnh->rnh_deladdr(rt_key(rt), rt_mask(rt), &rnh->head);
+ if (RNTORT(rn) == rt)
+ rtfree(rt);
+
+ return (0);
+}
+
+/*
+ * Removes all routes from the routing table without executing notifications.
+ * rtentres will be removed after the end of a current epoch.
+ */
+static void
+rib_flush_routes(struct rib_head *rnh)
+{
+ RIB_WLOCK(rnh);
+ rnh->rnh_walktree(&rnh->head, rt_delete_unconditional, rnh);
+ RIB_WUNLOCK(rnh);
+}
+
+void
+rib_flush_routes_family(int family)
+{
+ struct rib_head *rnh;
+
+ for (uint32_t fibnum = 0; fibnum < rt_numfibs; fibnum++) {
+ if ((rnh = rt_tables_get_rnh(fibnum, family)) != NULL)
+ rib_flush_routes(rnh);
+ }
+}
+
static void
rib_notify(struct rib_head *rnh, enum rib_subscription_type type,
struct rib_cmd_info *rc)
Index: sys/netinet/ip_input.c
===================================================================
--- sys/netinet/ip_input.c
+++ sys/netinet/ip_input.c
@@ -379,7 +379,6 @@
static void
ip_destroy(void *unused __unused)
{
- struct ifnet *ifp;
int error;
#ifdef RSS
@@ -405,10 +404,7 @@
in_ifscrub_all();
/* Make sure the IPv4 routes are gone as well. */
- IFNET_RLOCK();
- CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link)
- rt_flushifroutes_af(ifp, AF_INET);
- IFNET_RUNLOCK();
+ rib_flush_routes_family(AF_INET);
/* Destroy IP reassembly queue. */
ipreass_destroy();
Index: sys/netinet6/ip6_input.c
===================================================================
--- sys/netinet6/ip6_input.c
+++ sys/netinet6/ip6_input.c
@@ -386,11 +386,12 @@
/* IF_ADDR_UNLOCK(ifp); */
in6_ifdetach_destroy(ifp);
mld_domifdetach(ifp);
- /* Make sure any routes are gone as well. */
- rt_flushifroutes_af(ifp, AF_INET6);
}
IFNET_RUNLOCK();
+ /* Make sure any routes are gone as well. */
+ rib_flush_routes_family(AF_INET6);
+
frag6_destroy();
nd6_destroy();
in6_ifattach_destroy();

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 21, 12:37 AM (6 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31875071
Default Alt Text
D29116.id85362.diff (3 KB)

Event Timeline