diff options
-rw-r--r-- | sys/net/if.c | 27 | ||||
-rw-r--r-- | sys/net/route.c | 18 | ||||
-rw-r--r-- | sys/net/route.h | 5 | ||||
-rw-r--r-- | sys/net/rtsock.c | 8 | ||||
-rw-r--r-- | sys/netinet/if_ether.c | 4 | ||||
-rw-r--r-- | sys/netinet/ip_carp.c | 11 | ||||
-rw-r--r-- | sys/netinet6/nd6_rtr.c | 4 |
7 files changed, 43 insertions, 34 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 7cd521cdb80..4b97d064b0c 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.145 2006/03/20 10:03:49 henning Exp $ */ +/* $OpenBSD: if.c,v 1.146 2006/03/22 14:37:44 henning Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1761,7 +1761,6 @@ if_group_egress_build(void) #ifdef INET6 struct sockaddr_in6 sa_in6; #endif - struct radix_node_head *rnh; struct radix_node *rn; struct rtentry *rt; @@ -1775,42 +1774,34 @@ if_group_egress_build(void) if_delgroup(ifgm->ifgm_ifp, IFG_EGRESS); } - if ((rnh = rt_tables[AF_INET]) == NULL) - return (-1); - bzero(&sa_in, sizeof(sa_in)); sa_in.sin_len = sizeof(sa_in); sa_in.sin_family = AF_INET; - if ((rn = rnh->rnh_lookup(&sa_in, &sa_in, rnh))) { + if ((rn = rt_lookup(sintosa(&sa_in), sintosa(&sa_in), 0)) != NULL) { do { rt = (struct rtentry *)rn; if (rt->rt_ifp) if_addgroup(rt->rt_ifp, IFG_EGRESS); #ifndef SMALL_KERNEL - if (rn_mpath_capable(rnh)) - rn = rn_mpath_next(rn); - else + rn = rn_mpath_next(rn); +#else + rn = NULL; #endif - rn = NULL; } while (rn != NULL); } #ifdef INET6 - if ((rnh = rt_tables[AF_INET6]) == NULL) - return (-1); - bcopy(&sa6_any, &sa_in6, sizeof(sa_in6)); - if ((rn = rnh->rnh_lookup(&sa_in6, &sa_in6, rnh))) { + if ((rn = rt_lookup(sin6tosa(&sa_in6), sin6tosa(&sa_in6), 0)) != NULL) { do { rt = (struct rtentry *)rn; if (rt->rt_ifp) if_addgroup(rt->rt_ifp, IFG_EGRESS); #ifndef SMALL_KERNEL - if (rn_mpath_capable(rnh)) - rn = rn_mpath_next(rn); - else + rn = rn_mpath_next(rn); +#else + rn = NULL; #endif - rn = NULL; } while (rn != NULL); } #endif diff --git a/sys/net/route.c b/sys/net/route.c index cdfb19120aa..b785a803e4e 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.69 2006/03/20 10:03:49 henning Exp $ */ +/* $OpenBSD: route.c,v 1.70 2006/03/22 14:37:44 henning Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -1122,6 +1122,22 @@ rt_timer_add(struct rtentry *rt, void (*func)(struct rtentry *, return (0); } +struct radix_node_head * +rt_gettable(sa_family_t af, int id) +{ + /* ignore id for now */ + return (rt_tables[af]); +} + +struct radix_node * +rt_lookup(struct sockaddr *dst, struct sockaddr *mask, int tableid) +{ + struct radix_node_head *rnh; + + rnh = rt_gettable(dst->sa_family, tableid); + + return (rnh->rnh_lookup(dst, mask, rnh)); +} /* ARGSUSED */ void rt_timer_timer(void *arg) diff --git a/sys/net/route.h b/sys/net/route.h index 0c4724e3dd3..c8c1e887fe0 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.36 2006/03/20 10:03:49 henning Exp $ */ +/* $OpenBSD: route.h,v 1.37 2006/03/22 14:37:44 henning Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -304,7 +304,6 @@ void rtlabel_unref(u_int16_t); extern struct route_cb route_cb; extern struct rtstat rtstat; -extern struct radix_node_head *rt_tables[]; extern const struct sockaddr_rtin rt_defmask4; struct socket; @@ -353,5 +352,7 @@ int rtrequest(int, struct sockaddr *, int rtrequest1(int, struct rt_addrinfo *, struct rtentry **); void rt_if_remove(struct ifnet *); +struct radix_node_head *rt_gettable(sa_family_t, int); +struct radix_node *rt_lookup(struct sockaddr *, struct sockaddr *, int); #endif /* _KERNEL */ #endif /* _NET_ROUTE_H_ */ diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 1286e9be466..4fb25752f71 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.53 2006/02/23 14:15:53 claudio Exp $ */ +/* $OpenBSD: rtsock.c,v 1.54 2006/03/22 14:37:44 henning Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -263,11 +263,11 @@ route_output(struct mbuf *m, ...) case RTM_GET: case RTM_CHANGE: case RTM_LOCK: - if ((rnh = rt_tables[dst->sa_family]) == 0) { + if ((rnh = rt_gettable(dst->sa_family, 0)) == NULL) { error = EAFNOSUPPORT; goto flush; } - rn = rnh->rnh_lookup(dst, netmask, rnh); + rn = rt_lookup(dst, netmask, 0); if (rn == NULL || (rn->rn_flags & RNF_ROOT) != 0) { error = ESRCH; goto flush; @@ -907,7 +907,7 @@ sysctl_rtable(int *name, u_int namelen, void *where, size_t *given, void *new, case NET_RT_DUMP: case NET_RT_FLAGS: for (i = 1; i <= AF_MAX; i++) - if ((rnh = rt_tables[i]) && (af == 0 || af == i) && + if ((rnh = rt_gettable(i, 0)) && (af == 0 || af == i) && (error = (*rnh->rnh_walktree)(rnh, sysctl_dumpentry, &w))) break; diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 74b5a5b5825..8036fd2d0a1 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.62 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: if_ether.c,v 1.63 2006/03/22 14:37:44 henning Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -1077,7 +1077,7 @@ int db_show_arptab() { struct radix_node_head *rnh; - rnh = rt_tables[AF_INET]; + rnh = rt_gettable(AF_INET, 0); db_printf("Route tree for AF_INET\n"); if (rnh == NULL) { db_printf(" (not initialized)\n"); diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index fe448304f4c..57752a846bf 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.119 2006/01/28 23:47:20 mpf Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.120 2006/03/22 14:37:44 henning Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -341,8 +341,7 @@ carp_setroute(struct carp_softc *sc, int cmd) int count = 0; struct sockaddr sa; struct rtentry *rt; - struct radix_node_head *rnh = - rt_tables[ifa->ifa_addr->sa_family]; + struct radix_node_head *rnh; struct radix_node *rn; int hr_otherif, nr_ourif; @@ -367,6 +366,8 @@ carp_setroute(struct carp_softc *sc, int cmd) RTF_HOST, NULL); /* Check for our address on another interface */ + /* XXX cries for proper API */ + rnh = rt_gettable(ifa->ifa_addr->sa_family, 0); rn = rnh->rnh_matchaddr(ifa->ifa_addr, rnh); rt = (struct rtentry *)rn; hr_otherif = (rt && rt->rt_ifp != &sc->sc_if && @@ -376,8 +377,8 @@ carp_setroute(struct carp_softc *sc, int cmd) bcopy(ifa->ifa_addr, &sa, sizeof(sa)); satosin(&sa)->sin_addr.s_addr = satosin(ifa->ifa_netmask )->sin_addr.s_addr & satosin(&sa)->sin_addr.s_addr; - rn = rnh->rnh_lookup(&sa, ifa->ifa_netmask, rnh); - rt = (struct rtentry *)rn; + rt = (struct rtentry *)rt_lookup(&sa, + ifa->ifa_netmask, 0); nr_ourif = (rt && rt->rt_ifp == &sc->sc_if); switch (cmd) { diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 2e210988ddc..04553d07d5e 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_rtr.c,v 1.36 2006/03/05 21:48:57 miod Exp $ */ +/* $OpenBSD: nd6_rtr.c,v 1.37 2006/03/22 14:37:45 henning Exp $ */ /* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */ /* @@ -1785,7 +1785,7 @@ rt6_flush(gateway, ifp) struct in6_addr *gateway; struct ifnet *ifp; { - struct radix_node_head *rnh = rt_tables[AF_INET6]; + struct radix_node_head *rnh = rt_gettable(AF_INET6, 0); int s = splsoftnet(); /* We'll care only link-local addresses */ |