From 4d475b063c3db123002a792569518ef9d8e5a2ef Mon Sep 17 00:00:00 2001 From: julian Date: Sun, 14 Sep 2008 08:19:48 +0000 Subject: Revert a part of the MRT commit that proved un-needed. rt_check() in its original form proved to be sufficient and rt_check_fib() can go away (as can its evil twin in_rt_check()). I believe this does NOT address the crashes people have been seeing in rt_check. MFC after: 1 week --- sys/net/if_atmsubr.c | 3 +-- sys/net/if_fwsubr.c | 2 +- sys/net/if_iso88025subr.c | 3 +-- sys/net/route.c | 13 +++---------- sys/net/route.h | 3 +-- sys/netinet/if_ether.c | 21 +++++++++++++++------ sys/netinet/in_rmx.c | 7 ------- sys/netinet/in_var.h | 1 - 8 files changed, 22 insertions(+), 31 deletions(-) diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index 1564737..9d1a7fa 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -158,8 +158,7 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, * check route */ if (rt0 != NULL) { - error = rt_check_fib(&rt, &rt0, - dst, rt0->rt_fibnum); + error = rt_check(&rt, &rt0, dst); if (error) goto bad; RT_UNLOCK(rt); diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c index 65b2aff..e001c29 100644 --- a/sys/net/if_fwsubr.c +++ b/sys/net/if_fwsubr.c @@ -103,7 +103,7 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, } if (rt0 != NULL) { - error = rt_check_fib(&rt, &rt0, dst, rt0->rt_fibnum); + error = rt_check(&rt, &rt0, dst); if (error) goto bad; RT_UNLOCK(rt); diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c index f56101e..dd50923 100644 --- a/sys/net/if_iso88025subr.c +++ b/sys/net/if_iso88025subr.c @@ -259,8 +259,7 @@ iso88025_output(ifp, m, dst, rt0) /* Calculate routing info length based on arp table entry */ /* XXX any better way to do this ? */ if (rt0 != NULL) { -/* XXX MRT *//* Guess only */ - error = rt_check_fib(&rt, &rt0, dst, rt0->rt_fibnum); + error = rt_check(&rt, &rt0, dst); if (error) goto bad; RT_UNLOCK(rt); diff --git a/sys/net/route.c b/sys/net/route.c index 53a207c..95c46ca 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1675,7 +1675,6 @@ rtinit(struct ifaddr *ifa, int cmd, int flags) * final destination if directly reachable); * *lrt0 points to the cached route to the final destination; * *lrt is not meaningful; - * fibnum is the index to the correct network fib for this packet * * === Operation === * If the route is marked down try to find a new route. If the route @@ -1692,19 +1691,14 @@ rtinit(struct ifaddr *ifa, int cmd, int flags) int rt_check(struct rtentry **lrt, struct rtentry **lrt0, struct sockaddr *dst) { - return (rt_check_fib(lrt, lrt0, dst, 0)); -} - -int -rt_check_fib(struct rtentry **lrt, struct rtentry **lrt0, struct sockaddr *dst, - u_int fibnum) -{ struct rtentry *rt; struct rtentry *rt0; + u_int fibnum; int error; KASSERT(*lrt0 != NULL, ("rt_check")); rt = rt0 = *lrt0; + fibnum = (*rt0)->rt_fibnum; /* NB: the locking here is tortuous... */ RT_LOCK(rt); @@ -1730,8 +1724,7 @@ rt_check_fib(struct rtentry **lrt, struct rtentry **lrt0, struct sockaddr *dst, rt0->rt_gwroute = NULL; lookup: RT_UNLOCK(rt0); -/* XXX MRT link level looked up in table 0 */ - rt = rtalloc1_fib(rt->rt_gateway, 1, 0UL, 0); + rt = rtalloc1_fib(rt->rt_gateway, 1, 0UL, fibnum); if (rt == rt0) { RT_REMREF(rt0); RT_UNLOCK(rt0); diff --git a/sys/net/route.h b/sys/net/route.h index 906bfb2..2c9afb2 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -357,6 +357,7 @@ int rt_setgate(struct rtentry *, struct sockaddr *, struct sockaddr *); int rtexpunge(struct rtentry *); void rtfree(struct rtentry *); +int rt_check(struct rtentry **, struct rtentry **, struct sockaddr *); /* XXX MRT COMPAT VERSIONS THAT SET UNIVERSE to 0 */ /* Thes are used by old code not yet converted to use multiple FIBS */ @@ -371,7 +372,6 @@ void rtredirect(struct sockaddr *, struct sockaddr *, int rtrequest(int, struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct rtentry **); int rtrequest1(int, struct rt_addrinfo *, struct rtentry **); -int rt_check(struct rtentry **, struct rtentry **, struct sockaddr *); /* defaults to "all" FIBs */ int rtinit_fib(struct ifaddr *, int, int); @@ -390,7 +390,6 @@ void rtredirect_fib(struct sockaddr *, struct sockaddr *, int rtrequest_fib(int, struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct rtentry **, u_int); int rtrequest1_fib(int, struct rt_addrinfo *, struct rtentry **, u_int); -int rt_check_fib(struct rtentry **, struct rtentry **, struct sockaddr *, u_int); #include typedef void (*rtevent_arp_update_fn)(void *, struct rtentry *, uint8_t *, struct sockaddr *); diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 3ae3136..5401967 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -364,7 +364,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m, struct rtentry *rt = NULL; struct sockaddr_dl *sdl; int error; - int fibnum = 0; + int fibnum = -1; if (m) { if (m->m_flags & M_BCAST) { @@ -385,7 +385,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m, /* Look for a cached arp (ll) entry. */ if (m == NULL) fibnum = rt0->rt_fibnum; - error = in_rt_check(&rt, &rt0, dst, fibnum); + error = rt_check(&rt, &rt0, dst); if (error) { m_freem(m); return error; @@ -394,14 +394,23 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m, if (la == NULL) RT_UNLOCK(rt); } + + /* + * If we had no mbuf and no route, then hope the caller + * has a fib in mind because we are running out of ideas. + * I think this should not happen in current code. + * (kmacy would know). + */ + if (fibnum == -1) + fibnum = curthread->td_proc->p_fibnum; /* last gasp */ + if (la == NULL) { /* * We enter this block if rt0 was NULL, - * or if rt found by in_rt_check() didn't have llinfo. - * We should get a cloned route from the local interface, - * so it should have an ll entry. + * or if rt found by rt_check() didn't have llinfo. + * we should get a cloned route, which since it should + * come from the local interface should have a ll entry. * It may be incomplete but that's ok. - * XXXMRT if we haven't found a fibnum is that OK? */ rt = arplookup(SIN(dst)->sin_addr.s_addr, 1, 0, fibnum); if (rt == NULL) { diff --git a/sys/netinet/in_rmx.c b/sys/netinet/in_rmx.c index d8a90d4..e79337b 100644 --- a/sys/netinet/in_rmx.c +++ b/sys/netinet/in_rmx.c @@ -465,13 +465,6 @@ in_rtalloc1(struct sockaddr *dst, int report, u_long ignflags, u_int fibnum) return (rtalloc1_fib(dst, report, ignflags, fibnum)); } -int -in_rt_check(struct rtentry **lrt, struct rtentry **lrt0, - struct sockaddr *dst, u_int fibnum) -{ - return (rt_check_fib(lrt, lrt0, dst, fibnum)); -} - void in_rtredirect(struct sockaddr *dst, struct sockaddr *gateway, diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h index 01ff7b3..4999e90 100644 --- a/sys/netinet/in_var.h +++ b/sys/netinet/in_var.h @@ -314,7 +314,6 @@ void in_rtredirect(struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct sockaddr *, u_int); int in_rtrequest(int, struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct rtentry **, u_int); -int in_rt_check(struct rtentry **, struct rtentry **, struct sockaddr *, u_int); #if 0 int in_rt_getifa(struct rt_addrinfo *, u_int fibnum); -- cgit v1.1