diff options
author | Henric Jungheim <henric@cvs.openbsd.org> | 2003-08-27 00:33:35 +0000 |
---|---|---|
committer | Henric Jungheim <henric@cvs.openbsd.org> | 2003-08-27 00:33:35 +0000 |
commit | 89d4983750d29c71ec08fa03c2ae3504ffd8bd8c (patch) | |
tree | 482daff716aefc3417233f23eae3d89ec4900f1c | |
parent | 1c0b90edde1c586ef0ce4bbdab5739637795fd93 (diff) |
RNF_IGNORE can corrupt the radix tree when an interface is down, it
makes routing lookups slightly more expensive, and serves no useful
purpose.
ok itojun@ tedu@
-rw-r--r-- | sys/net/if.c | 56 | ||||
-rw-r--r-- | sys/net/radix.c | 10 | ||||
-rw-r--r-- | sys/net/radix.h | 3 | ||||
-rw-r--r-- | usr.bin/netstat/route.c | 8 |
4 files changed, 9 insertions, 68 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 8101114984c..ba44bcec1aa 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.69 2003/08/25 08:18:54 fgsch Exp $ */ +/* $OpenBSD: if.c,v 1.70 2003/08/27 00:33:34 henric Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -108,8 +108,6 @@ void if_attachsetup(struct ifnet *); void if_attachdomain1(struct ifnet *); int if_detach_rtdelete(struct radix_node *, void *); -int if_mark_ignore(struct radix_node *, void *); -int if_mark_unignore(struct radix_node *, void *); int ifqmaxlen = IFQ_MAXLEN; int netisr; @@ -372,34 +370,6 @@ if_detach_rtdelete(rn, vifp) return (0); } -int -if_mark_ignore(rn, vifp) - struct radix_node *rn; - void *vifp; -{ - struct ifnet *ifp = vifp; - struct rtentry *rt = (struct rtentry *)rn; - - if (rt->rt_ifp == ifp) - rn->rn_flags |= RNF_IGNORE; - - return (0); -} - -int -if_mark_unignore(rn, vifp) - struct radix_node *rn; - void *vifp; -{ - struct ifnet *ifp = vifp; - struct rtentry *rt = (struct rtentry *)rn; - - if (rt->rt_ifp == ifp) - rn->rn_flags &= ~RNF_IGNORE; - - return (0); -} - /* * Detach an interface from everything in the kernel. Also deallocate * private resources. @@ -765,8 +735,6 @@ void if_down(struct ifnet *ifp) { struct ifaddr *ifa; - struct radix_node_head *rnh; - int i; splassert(IPL_SOFTNET); @@ -777,16 +745,6 @@ if_down(struct ifnet *ifp) } IFQ_PURGE(&ifp->if_snd); rt_ifmsg(ifp); - - /* - * Find and mark as ignore all routes which are using this interface. - * XXX Factor out into a route.c function? - */ - for (i = 1; i <= AF_MAX; i++) { - rnh = rt_tables[i]; - if (rnh) - (*rnh->rnh_walktree)(rnh, if_mark_ignore, ifp); - } } /* @@ -800,8 +758,6 @@ if_up(struct ifnet *ifp) #ifdef notyet struct ifaddr *ifa; #endif - struct radix_node_head *rnh; - int i; splassert(IPL_SOFTNET); @@ -817,16 +773,6 @@ if_up(struct ifnet *ifp) #ifdef INET6 in6_if_up(ifp); #endif - - /* - * Find and unignore all routes which are using this interface. - * XXX Factor out into a route.c function? - */ - for (i = 1; i <= AF_MAX; i++) { - rnh = rt_tables[i]; - if (rnh) - (*rnh->rnh_walktree)(rnh, if_mark_unignore, ifp); - } } /* diff --git a/sys/net/radix.c b/sys/net/radix.c index 922916df22b..be37955d238 100644 --- a/sys/net/radix.c +++ b/sys/net/radix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radix.c,v 1.10 2003/06/02 23:28:12 millert Exp $ */ +/* $OpenBSD: radix.c,v 1.11 2003/08/27 00:33:34 henric Exp $ */ /* $NetBSD: radix.c,v 1.11 1996/03/16 23:55:36 christos Exp $ */ /* @@ -262,7 +262,7 @@ on1: */ if ((saved_t = t)->rn_mask == 0) t = t->rn_dupedkey; - for (; t && !(t->rn_flags & RNF_IGNORE); t = t->rn_dupedkey) + for (; t; t = t->rn_dupedkey) /* * Even if we don't match exactly as a host, * we may match if the leaf we wound up at is @@ -287,16 +287,14 @@ on1: */ do { if (m->rm_flags & RNF_NORMAL) { - if (rn_b <= m->rm_b && - !(m->rm_flags & RNF_IGNORE)) + if (rn_b <= m->rm_b) return (m->rm_leaf); } else { off = min(t->rn_off, matched_off); x = rn_search_m(v, t, m->rm_mask); while (x && x->rn_mask != m->rm_mask) x = x->rn_dupedkey; - if (x && !(x->rn_flags & RNF_IGNORE) && - rn_satsifies_leaf(v, x, off)) + if (x && rn_satsifies_leaf(v, x, off)) return x; } } while ((m = m->rm_mklist) != NULL); diff --git a/sys/net/radix.h b/sys/net/radix.h index 9c93be7f496..2802a583f50 100644 --- a/sys/net/radix.h +++ b/sys/net/radix.h @@ -1,4 +1,4 @@ -/* $OpenBSD: radix.h,v 1.9 2003/06/02 23:28:12 millert Exp $ */ +/* $OpenBSD: radix.h,v 1.10 2003/08/27 00:33:34 henric Exp $ */ /* $NetBSD: radix.h,v 1.8 1996/02/13 22:00:37 christos Exp $ */ /* @@ -48,7 +48,6 @@ struct radix_node { #define RNF_NORMAL 1 /* leaf contains normal route */ #define RNF_ROOT 2 /* leaf is root leaf for tree */ #define RNF_ACTIVE 4 /* This node is alive (for rtfree) */ -#define RNF_IGNORE 8 /* Ignore this entry (for if down) */ union { struct { /* leaf only data: */ caddr_t rn_Key; /* object of search */ diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index cecc34530eb..363f4033dda 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.55 2003/08/26 08:33:12 itojun Exp $ */ +/* $OpenBSD: route.c,v 1.56 2003/08/27 00:33:33 henric Exp $ */ /* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94"; #else -static char *rcsid = "$OpenBSD: route.c,v 1.55 2003/08/26 08:33:12 itojun Exp $"; +static char *rcsid = "$OpenBSD: route.c,v 1.56 2003/08/27 00:33:33 henric Exp $"; #endif #endif /* not lint */ @@ -325,9 +325,7 @@ p_rtflags(u_char flags) putchar('R'); if (flags & RNF_ACTIVE) putchar('A'); - if (flags & RNF_IGNORE) - putchar('I'); - if (flags & ~(RNF_NORMAL | RNF_ROOT | RNF_ACTIVE | RNF_IGNORE)) + if (flags & ~(RNF_NORMAL | RNF_ROOT | RNF_ACTIVE)) printf("/0x%02x", flags); putchar('>'); } |