diff options
| author | dyoung <dyoung@NetBSD.org> | 2011-03-31 19:40:51 +0000 |
|---|---|---|
| committer | dyoung <dyoung@NetBSD.org> | 2011-03-31 19:40:51 +0000 |
| commit | fa9c652eb0c8af1615070dd33cb2f4dd35d04d8a (patch) | |
| tree | 75f8482fa3d94dbf9ad2eb5d4da3d0fcf9b1fc87 /sys | |
| parent | c1b7bacbb7b9e671a76cb9376bf0dbd177c9f946 (diff) | |
Hide the radix-trie implementation of the forwarding table so that we
will have an easier time replacing it with something different, even if
it is a second radix-trie implementation.
sys/net/route.c and sys/net/rtsock.c no longer operate directly on
radix_nodes or radix_node_heads.
Hopefully this will reduce the temptation to implement multipath or
source-based routing using grotty hacks to the grotty old radix-trie
code, too. :-)
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/conf/files | 3 | ||||
| -rw-r--r-- | sys/net/route.c | 83 | ||||
| -rw-r--r-- | sys/net/route.h | 27 | ||||
| -rw-r--r-- | sys/net/rtbl.c | 230 | ||||
| -rw-r--r-- | sys/net/rtsock.c | 29 | ||||
| -rw-r--r-- | sys/netatalk/at_proto.c | 6 | ||||
| -rw-r--r-- | sys/netinet/in_proto.c | 6 | ||||
| -rw-r--r-- | sys/netinet6/in6_proto.c | 6 | ||||
| -rw-r--r-- | sys/netiso/iso_proto.c | 8 | ||||
| -rw-r--r-- | sys/netmpls/mpls_proto.c | 6 | ||||
| -rw-r--r-- | sys/nfs/nfs_export.c | 6 | ||||
| -rw-r--r-- | sys/rump/librump/rumpnet/Makefile.rumpnet | 3 | ||||
| -rw-r--r-- | sys/rump/librump/rumpnet/opt/opt_route.h | 3 | ||||
| -rw-r--r-- | sys/rump/net/lib/libnet/Makefile | 4 | ||||
| -rw-r--r-- | sys/rump/net/lib/libsockin/sockin.c | 6 | ||||
| -rw-r--r-- | sys/sys/domain.h | 6 |
16 files changed, 307 insertions, 125 deletions
diff --git a/sys/conf/files b/sys/conf/files index 2b1291b5bda..5663a5f86b6 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.1005 2011/03/20 17:54:02 tsutsui Exp $ +# $NetBSD: files,v 1.1006 2011/03/31 19:40:51 dyoung Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 version 20100430 @@ -1654,6 +1654,7 @@ file net/radix.c file net/raw_cb.c file net/raw_usrreq.c file net/route.c +file net/rtbl.c file net/rtsock.c file net/slcompress.c sl | ppp | strip | (irip & irip_vj) file net/zlib.c (ppp & ppp_deflate) | ipsec | opencrypto | vnd_compression diff --git a/sys/net/route.c b/sys/net/route.c index 30161a92a05..9789fe0d2ae 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.124 2011/02/01 01:39:20 matt Exp $ */ +/* $NetBSD: route.c,v 1.125 2011/03/31 19:40:52 dyoung Exp $ */ /*- * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -93,9 +93,10 @@ #include "opt_route.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.124 2011/02/01 01:39:20 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.125 2011/03/31 19:40:52 dyoung Exp $"); #include <sys/param.h> +#include <sys/kmem.h> #include <sys/sysctl.h> #include <sys/systm.h> #include <sys/callout.h> @@ -125,7 +126,6 @@ __KERNEL_RCSID(0, "$NetBSD: route.c,v 1.124 2011/02/01 01:39:20 matt Exp $"); #endif /* RTFLUSH_DEBUG */ struct rtstat rtstat; -struct radix_node_head *rt_tables[AF_MAX+1]; int rttrash; /* routes not in table but not freed */ @@ -252,16 +252,6 @@ rt_set_ifa(struct rtentry *rt, struct ifaddr *ifa) rt_set_ifa1(rt, ifa); } -void -rtable_init(void **table) -{ - struct domain *dom; - DOMAIN_FOREACH(dom) - if (dom->dom_rtattach) - dom->dom_rtattach(&table[dom->dom_family], - dom->dom_rtoffset); -} - static int route_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie, void *arg0, void *arg1, void *arg2, void *arg3) @@ -295,7 +285,7 @@ rt_init(void) NULL, IPL_SOFTNET); rn_init(); /* initialize all zeroes, all ones, mask table */ - rtable_init((void **)rt_tables); + rtbl_init(); route_listener = kauth_listen_scope(KAUTH_SCOPE_NETWORK, route_listener_cb, NULL); @@ -338,16 +328,14 @@ rtcache(struct route *ro) struct rtentry * rtalloc1(const struct sockaddr *dst, int report) { - struct radix_node_head *rnh = rt_tables[dst->sa_family]; + rtbl_t *rtbl = rt_gettable(dst->sa_family); struct rtentry *rt; - struct radix_node *rn; struct rtentry *newrt = NULL; struct rt_addrinfo info; int s = splsoftnet(), err = 0, msgtype = RTM_MISS; - if (rnh && (rn = rnh->rnh_matchaddr(dst, rnh)) && - ((rn->rn_flags & RNF_ROOT) == 0)) { - newrt = rt = (struct rtentry *)rn; + if (rtbl != NULL && (rt = rt_matchaddr(rtbl, dst)) != NULL) { + newrt = rt; if (report && (rt->rt_flags & RTF_CLONING)) { err = rtrequest(RTM_RESOLVE, dst, NULL, NULL, 0, &newrt); @@ -395,8 +383,7 @@ rtfree(struct rtentry *rt) panic("rtfree"); rt->rt_refcnt--; if (rt->rt_refcnt <= 0 && (rt->rt_flags & RTF_UP) == 0) { - if (rt->rt_nodes->rn_flags & (RNF_ACTIVE | RNF_ROOT)) - panic ("rtfree 2"); + rt_assert_inactive(rt); rttrash--; if (rt->rt_refcnt < 0) { printf("rtfree: %p not freed (neg refs)\n", rt); @@ -697,10 +684,9 @@ int rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) { int s = splsoftnet(); - int error = 0; + int error = 0, rc; struct rtentry *rt, *crt; - struct radix_node *rn; - struct radix_node_head *rnh; + rtbl_t *rtbl; struct ifaddr *ifa, *ifa2; struct sockaddr_storage maskeddst; const struct sockaddr *dst = info->rti_info[RTAX_DST]; @@ -709,7 +695,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) int flags = info->rti_flags; #define senderr(x) { error = x ; goto bad; } - if ((rnh = rt_tables[dst->sa_family]) == NULL) + if ((rtbl = rt_gettable(dst->sa_family)) == NULL) senderr(ESRCH); if (flags & RTF_HOST) netmask = NULL; @@ -720,18 +706,14 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) netmask); dst = (struct sockaddr *)&maskeddst; } - if ((rn = rnh->rnh_lookup(dst, netmask, rnh)) == NULL) + if ((rt = rt_lookup(rtbl, dst, netmask)) == NULL) senderr(ESRCH); - rt = (struct rtentry *)rn; if ((rt->rt_flags & RTF_CLONING) != 0) { /* clean up any cloned children */ rtflushclone(dst->sa_family, rt); } - if ((rn = rnh->rnh_deladdr(dst, netmask, rnh)) == NULL) + if ((rt = rt_deladdr(rtbl, dst, netmask)) == NULL) senderr(ESRCH); - if (rn->rn_flags & (RNF_ACTIVE | RNF_ROOT)) - panic ("rtrequest delete"); - rt = (struct rtentry *)rn; if (rt->rt_gwroute) { RTFREE(rt->rt_gwroute); rt->rt_gwroute = NULL; @@ -817,21 +799,19 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) rt->rt_parent->rt_refcnt++; } RT_DPRINTF("rt->_rt_key = %p\n", (void *)rt->_rt_key); - rn = rnh->rnh_addaddr(rt_getkey(rt), netmask, rnh, - rt->rt_nodes); + rc = rt_addaddr(rtbl, rt, netmask); RT_DPRINTF("rt->_rt_key = %p\n", (void *)rt->_rt_key); - if (rn == NULL && (crt = rtalloc1(rt_getkey(rt), 0)) != NULL) { + if (rc != 0 && (crt = rtalloc1(rt_getkey(rt), 0)) != NULL) { /* overwrite cloned route */ if ((crt->rt_flags & RTF_CLONED) != 0) { rtdeletemsg(crt); - rn = rnh->rnh_addaddr(rt_getkey(rt), - netmask, rnh, rt->rt_nodes); + rc = rt_addaddr(rtbl, rt, netmask); } RTFREE(crt); RT_DPRINTF("rt->_rt_key = %p\n", (void *)rt->_rt_key); } RT_DPRINTF("rt->_rt_key = %p\n", (void *)rt->_rt_key); - if (rn == NULL) { + if (rc != 0) { IFAFREE(ifa); if ((rt->rt_flags & RTF_CLONED) != 0 && rt->rt_parent) rtfree(rt->rt_parent); @@ -839,7 +819,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) rtfree(rt->rt_gwroute); rt_destroy(rt); pool_put(&rtentry_pool, rt); - senderr(EEXIST); + senderr(rc); } RT_DPRINTF("rt->_rt_key = %p\n", (void *)rt->_rt_key); if (ifa->ifa_rtrequest) @@ -861,11 +841,9 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) netmask); dst = (struct sockaddr *)&maskeddst; } - rn = rnh->rnh_lookup(dst, netmask, rnh); - if (rn == NULL || (rn->rn_flags & RNF_ROOT) != 0) + if ((rt = rt_lookup(rtbl, dst, netmask)) == NULL) senderr(ESRCH); if (ret_nrt != NULL) { - rt = (struct rtentry *)rn; *ret_nrt = rt; rt->rt_refcnt++; } @@ -1391,29 +1369,6 @@ rtcache_setdst(struct route *ro, const struct sockaddr *sa) return 0; } -static int -rt_walktree_visitor(struct radix_node *rn, void *v) -{ - struct rtwalk *rw = (struct rtwalk *)v; - - return (*rw->rw_f)((struct rtentry *)rn, rw->rw_v); -} - -int -rt_walktree(sa_family_t family, int (*f)(struct rtentry *, void *), void *v) -{ - struct radix_node_head *rnh = rt_tables[family]; - struct rtwalk rw; - - if (rnh == NULL) - return 0; - - rw.rw_f = f; - rw.rw_v = v; - - return rn_walktree(rnh, rt_walktree_visitor, &rw); -} - const struct sockaddr * rt_settag(struct rtentry *rt, const struct sockaddr *tag) { diff --git a/sys/net/route.h b/sys/net/route.h index 90bbe46bfcd..491acd1a286 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $NetBSD: route.h,v 1.78 2011/02/01 01:39:20 matt Exp $ */ +/* $NetBSD: route.h,v 1.79 2011/03/31 19:40:52 dyoung Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -309,8 +309,15 @@ struct rttimer_queue { }; +struct rtbl; +typedef struct rtbl rtbl_t; + #ifdef _KERNEL +struct rtbl { + struct radix_node_head t_rnh; +}; + struct rt_walkarg { int w_op; int w_arg; @@ -347,7 +354,6 @@ struct route_info { extern struct route_info route_info; extern struct rtstat rtstat; -extern struct radix_node_head *rt_tables[AF_MAX+1]; struct socket; struct dom_rtlist; @@ -375,7 +381,6 @@ void rt_timer_queue_destroy(struct rttimer_queue *, int); void rt_timer_remove_all(struct rtentry *, int); unsigned long rt_timer_count(struct rttimer_queue *); void rt_timer_timer(void *); -void rtable_init(void **); void rtcache(struct route *); void rtflushall(int); struct rtentry * @@ -425,8 +430,6 @@ out: return rt->_rt_key; } -struct rtentry *rtfindparent(struct radix_node_head *, struct route *); - struct rtentry *rtcache_init(struct route *); struct rtentry *rtcache_init_noclone(struct route *); void rtcache_copy(struct route *, const struct route *); @@ -502,9 +505,19 @@ RTFREE(struct rtentry *rt) rt->rt_refcnt--; } -int -rt_walktree(sa_family_t, int (*)(struct rtentry *, void *), void *); +int rt_walktree(sa_family_t, int (*)(struct rtentry *, void *), void *); void route_enqueue(struct mbuf *, int); +int rt_inithead(rtbl_t **, int); +struct rtentry *rt_matchaddr(rtbl_t *, const struct sockaddr *); +int rt_addaddr(rtbl_t *, struct rtentry *, const struct sockaddr *); +struct rtentry *rt_lookup(rtbl_t *, const struct sockaddr *, + const struct sockaddr *); +struct rtentry *rt_deladdr(rtbl_t *, const struct sockaddr *, + const struct sockaddr *); +void rtbl_init(void); +rtbl_t *rt_gettable(sa_family_t); +void rt_assert_inactive(const struct rtentry *); #endif /* _KERNEL */ + #endif /* !_NET_ROUTE_H_ */ diff --git a/sys/net/rtbl.c b/sys/net/rtbl.c new file mode 100644 index 00000000000..cc6907cbb72 --- /dev/null +++ b/sys/net/rtbl.c @@ -0,0 +1,230 @@ +/* $NetBSD: rtbl.c,v 1.1 2011/03/31 19:40:52 dyoung Exp $ */ + +/*- + * Copyright (c) 1998, 2008, 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Kevin M. Lahey of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 1980, 1986, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)route.c 8.3 (Berkeley) 1/9/95 + */ + +#ifdef _KERNEL +#include "opt_route.h" +#endif /* _KERNEL */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: rtbl.c,v 1.1 2011/03/31 19:40:52 dyoung Exp $"); + +#include <sys/param.h> +#include <sys/kmem.h> +#include <sys/sysctl.h> +#include <sys/systm.h> +#include <sys/callout.h> +#include <sys/proc.h> +#include <sys/mbuf.h> +#include <sys/socket.h> +#include <sys/socketvar.h> +#include <sys/domain.h> +#include <sys/protosw.h> +#include <sys/kernel.h> +#include <sys/ioctl.h> +#include <sys/pool.h> +#include <sys/kauth.h> + +#include <net/if.h> +#include <net/if_dl.h> +#include <net/route.h> +#include <net/raw_cb.h> + +static rtbl_t *rt_tables[AF_MAX+1]; + +int +rt_inithead(rtbl_t **tp, int off) +{ + rtbl_t *t; + if (*tp != NULL) + return 1; + if ((t = kmem_alloc(sizeof(*t), KM_SLEEP)) == NULL) + return 0; + *tp = t; + return rn_inithead0(&t->t_rnh, off); +} + +struct rtentry * +rt_matchaddr(rtbl_t *t, const struct sockaddr *dst) +{ + struct radix_node_head *rnh = &t->t_rnh; + struct radix_node *rn; + + rn = rnh->rnh_matchaddr(dst, rnh); + if (rn == NULL || (rn->rn_flags & RNF_ROOT) != 0) + return NULL; + return (struct rtentry *)rn; +} + +int +rt_addaddr(rtbl_t *t, struct rtentry *rt, const struct sockaddr *netmask) +{ + struct radix_node_head *rnh = &t->t_rnh; + struct radix_node *rn; + + rn = rnh->rnh_addaddr(rt_getkey(rt), netmask, rnh, rt->rt_nodes); + + return (rn == NULL) ? EEXIST : 0; +} + +struct rtentry * +rt_lookup(rtbl_t *t, const struct sockaddr *dst, const struct sockaddr *netmask) +{ + struct radix_node_head *rnh = &t->t_rnh; + struct radix_node *rn; + + rn = rnh->rnh_lookup(dst, netmask, rnh); + if (rn == NULL || (rn->rn_flags & RNF_ROOT) != 0) + return NULL; + return (struct rtentry *)rn; +} + +struct rtentry * +rt_deladdr(rtbl_t *t, const struct sockaddr *dst, + const struct sockaddr *netmask) +{ + struct radix_node_head *rnh = &t->t_rnh; + struct radix_node *rn; + + if ((rn = rnh->rnh_deladdr(dst, netmask, rnh)) == NULL) + return NULL; + if (rn->rn_flags & (RNF_ACTIVE | RNF_ROOT)) + panic("%s", __func__); + return (struct rtentry *)rn; +} + +static int +rt_walktree_visitor(struct radix_node *rn, void *v) +{ + struct rtwalk *rw = (struct rtwalk *)v; + + return (*rw->rw_f)((struct rtentry *)rn, rw->rw_v); +} + +int +rt_walktree(sa_family_t family, int (*f)(struct rtentry *, void *), void *v) +{ + rtbl_t *t = rt_tables[family]; + struct rtwalk rw; + + if (t == NULL) + return 0; + + rw.rw_f = f; + rw.rw_v = v; + + return rn_walktree(&t->t_rnh, rt_walktree_visitor, &rw); +} + +rtbl_t * +rt_gettable(sa_family_t af) +{ + if (af >= __arraycount(rt_tables)) + return NULL; + return rt_tables[af]; +} + +void +rtbl_init(void) +{ + struct domain *dom; + DOMAIN_FOREACH(dom) + if (dom->dom_rtattach) + dom->dom_rtattach(&rt_tables[dom->dom_family], + dom->dom_rtoffset); +} + +void +rt_assert_inactive(const struct rtentry *rt) +{ + if (rt->rt_nodes->rn_flags & (RNF_ACTIVE | RNF_ROOT)) + panic ("rtfree 2"); +} diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 0211205311b..bba4773c82e 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtsock.c,v 1.134 2011/02/10 07:42:18 kefren Exp $ */ +/* $NetBSD: rtsock.c,v 1.135 2011/03/31 19:40:52 dyoung Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.134 2011/02/10 07:42:18 kefren Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.135 2011/03/31 19:40:52 dyoung Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -231,19 +231,6 @@ COMPATNAME(route_usrreq)(struct socket *so, int req, struct mbuf *m, struct mbuf return error; } -static const struct sockaddr * -intern_netmask(const struct sockaddr *mask) -{ - struct radix_node *rn; - extern struct radix_node_head *mask_rnhead; - - if (mask != NULL && - (rn = rn_search(mask, mask_rnhead->rnh_treetop))) - mask = (const struct sockaddr *)rn->rn_key; - - return mask; -} - /*ARGSUSED*/ int COMPATNAME(route_output)(struct mbuf *m, ...) @@ -351,20 +338,12 @@ COMPATNAME(route_output)(struct mbuf *m, ...) if (error != 0) senderr(error); if (rtm->rtm_type != RTM_GET) {/* XXX: too grotty */ - struct radix_node *rn; - if (memcmp(info.rti_info[RTAX_DST], rt_getkey(rt), info.rti_info[RTAX_DST]->sa_len) != 0) senderr(ESRCH); - info.rti_info[RTAX_NETMASK] = intern_netmask( - info.rti_info[RTAX_NETMASK]); - for (rn = rt->rt_nodes; rn; rn = rn->rn_dupedkey) - if (info.rti_info[RTAX_NETMASK] == - (const struct sockaddr *)rn->rn_mask) - break; - if (rn == NULL) + if (info.rti_info[RTAX_NETMASK] == NULL && + rt_mask(rt) != NULL) senderr(ETOOMANYREFS); - rt = (struct rtentry *)rn; } switch (rtm->rtm_type) { diff --git a/sys/netatalk/at_proto.c b/sys/netatalk/at_proto.c index 71de37fbb7b..0910a345cfb 100644 --- a/sys/netatalk/at_proto.c +++ b/sys/netatalk/at_proto.c @@ -1,4 +1,4 @@ -/* $NetBSD: at_proto.c,v 1.16 2008/04/24 11:38:37 ad Exp $ */ +/* $NetBSD: at_proto.c,v 1.17 2011/03/31 19:40:52 dyoung Exp $ */ /* * Copyright (c) 1990,1991 Regents of The University of Michigan. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: at_proto.c,v 1.16 2008/04/24 11:38:37 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: at_proto.c,v 1.17 2011/03/31 19:40:52 dyoung Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -73,7 +73,7 @@ struct domain atalkdomain = { .dom_dispose = NULL, .dom_protosw = atalksw, .dom_protoswNPROTOSW = &atalksw[__arraycount(atalksw)], - .dom_rtattach = rn_inithead, + .dom_rtattach = rt_inithead, .dom_rtoffset = 32, .dom_maxrtkey = sizeof(struct sockaddr_at), .dom_ifattach = NULL, diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index c83fd8bdd10..5e528422963 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -1,4 +1,4 @@ -/* $NetBSD: in_proto.c,v 1.99 2009/09/16 15:23:05 pooka Exp $ */ +/* $NetBSD: in_proto.c,v 1.100 2011/03/31 19:40:52 dyoung Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.99 2009/09/16 15:23:05 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.100 2011/03/31 19:40:52 dyoung Exp $"); #include "opt_mrouting.h" #include "opt_eon.h" /* ISO CLNL over IP */ @@ -467,7 +467,7 @@ struct domain inetdomain = { .dom_externalize = NULL, .dom_dispose = NULL, .dom_protosw = inetsw, .dom_protoswNPROTOSW = &inetsw[__arraycount(inetsw)], - .dom_rtattach = rn_inithead, + .dom_rtattach = rt_inithead, .dom_rtoffset = 32, .dom_maxrtkey = sizeof(struct ip_pack4), #ifdef IPSELSRC diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index ec3c5b47771..56f860bcb5e 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -1,4 +1,4 @@ -/* $NetBSD: in6_proto.c,v 1.89 2010/08/24 00:07:00 jakllsch Exp $ */ +/* $NetBSD: in6_proto.c,v 1.90 2011/03/31 19:40:52 dyoung Exp $ */ /* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.89 2010/08/24 00:07:00 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.90 2011/03/31 19:40:52 dyoung Exp $"); #include "opt_gateway.h" #include "opt_inet.h" @@ -412,7 +412,7 @@ struct domain inet6domain = { .dom_init = NULL, .dom_externalize = NULL, .dom_dispose = NULL, .dom_protosw = (const struct protosw *)inet6sw, .dom_protoswNPROTOSW = (const struct protosw *)&inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])], - .dom_rtattach = rn_inithead, + .dom_rtattach = rt_inithead, .dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr) << 3, .dom_maxrtkey = sizeof(struct ip_pack6), .dom_ifattach = in6_domifattach, .dom_ifdetach = in6_domifdetach, diff --git a/sys/netiso/iso_proto.c b/sys/netiso/iso_proto.c index 9df0efb5a39..8bd7832505c 100644 --- a/sys/netiso/iso_proto.c +++ b/sys/netiso/iso_proto.c @@ -1,4 +1,4 @@ -/* $NetBSD: iso_proto.c,v 1.28 2008/04/24 11:38:38 ad Exp $ */ +/* $NetBSD: iso_proto.c,v 1.29 2011/03/31 19:40:53 dyoung Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -65,7 +65,7 @@ SOFTWARE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: iso_proto.c,v 1.28 2008/04/24 11:38:38 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: iso_proto.c,v 1.29 2011/03/31 19:40:53 dyoung Exp $"); #include <sys/param.h> @@ -261,8 +261,8 @@ struct domain isodomain = { .dom_dispose = NULL, .dom_protosw = isosw, .dom_protoswNPROTOSW = &isosw[sizeof(isosw) / sizeof(isosw[0])], - .dom_rtattach = rn_inithead, /* rtattach */ - .dom_rtoffset = 48, /* rtoffset */ + .dom_rtattach = rt_inithead, + .dom_rtoffset = 48, .dom_maxrtkey = sizeof(struct sockaddr_iso), /* maxkeylen */ .dom_ifattach = NULL, .dom_ifdetach = NULL, diff --git a/sys/netmpls/mpls_proto.c b/sys/netmpls/mpls_proto.c index a2d699946e8..a13f3fcf8d7 100644 --- a/sys/netmpls/mpls_proto.c +++ b/sys/netmpls/mpls_proto.c @@ -1,4 +1,4 @@ -/* $NetBSD: mpls_proto.c,v 1.1 2010/06/26 14:24:29 kefren Exp $ */ +/* $NetBSD: mpls_proto.c,v 1.2 2011/03/31 19:40:53 dyoung Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.1 2010/06/26 14:24:29 kefren Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.2 2011/03/31 19:40:53 dyoung Exp $"); #include "opt_inet.h" #include "opt_mbuftrace.h" @@ -102,7 +102,7 @@ struct domain mplsdomain = { .dom_dispose = NULL, .dom_protosw = mplssw, .dom_protoswNPROTOSW = &mplssw[__arraycount(mplssw)], - .dom_rtattach = rn_inithead, + .dom_rtattach = rt_inithead, .dom_rtoffset = offsetof(struct sockaddr_mpls, smpls_addr) << 3, .dom_maxrtkey = sizeof(union mpls_shim), .dom_ifattach = NULL, diff --git a/sys/nfs/nfs_export.c b/sys/nfs/nfs_export.c index cf7a1efbe2a..e496f82ee35 100644 --- a/sys/nfs/nfs_export.c +++ b/sys/nfs/nfs_export.c @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_export.c,v 1.49 2010/11/19 06:44:46 dholland Exp $ */ +/* $NetBSD: nfs_export.c,v 1.50 2011/03/31 19:40:53 dyoung Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.49 2010/11/19 06:44:46 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.50 2011/03/31 19:40:53 dyoung Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -561,7 +561,7 @@ hang_addrlist(struct mount *mp, struct netexport *nep, */ DOMAIN_FOREACH(dom) { if (dom->dom_family == i && dom->dom_rtattach) { - dom->dom_rtattach((void **)&nep->ne_rtable[i], + rn_inithead((void **)&nep->ne_rtable[i], dom->dom_rtoffset); break; } diff --git a/sys/rump/librump/rumpnet/Makefile.rumpnet b/sys/rump/librump/rumpnet/Makefile.rumpnet index 231d93a654d..9f0c0a3e435 100644 --- a/sys/rump/librump/rumpnet/Makefile.rumpnet +++ b/sys/rump/librump/rumpnet/Makefile.rumpnet @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rumpnet,v 1.11 2011/02/01 01:39:21 matt Exp $ +# $NetBSD: Makefile.rumpnet,v 1.12 2011/03/31 19:40:53 dyoung Exp $ # .include "${RUMPTOP}/Makefile.rump" @@ -20,6 +20,7 @@ SRCS+= sys_socket.c uipc_accf.c uipc_domain.c uipc_mbuf.c uipc_mbuf2.c \ # radix trie support SRCS+= radix.c +SRCS+= rtbl.c # compat (nothing for now) SRCS+= diff --git a/sys/rump/librump/rumpnet/opt/opt_route.h b/sys/rump/librump/rumpnet/opt/opt_route.h new file mode 100644 index 00000000000..1b2fe32586e --- /dev/null +++ b/sys/rump/librump/rumpnet/opt/opt_route.h @@ -0,0 +1,3 @@ +/* $NetBSD: opt_route.h,v 1.1 2011/03/31 19:40:53 dyoung Exp $ */ + +/* dummy */ diff --git a/sys/rump/net/lib/libnet/Makefile b/sys/rump/net/lib/libnet/Makefile index 73eff566531..731e4b0f48f 100644 --- a/sys/rump/net/lib/libnet/Makefile +++ b/sys/rump/net/lib/libnet/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.11 2011/02/01 01:39:21 matt Exp $ +# $NetBSD: Makefile,v 1.12 2011/03/31 19:40:54 dyoung Exp $ # .PATH: ${.CURDIR}/../../../../net ${.CURDIR}/../../../../compat/common @@ -6,7 +6,7 @@ LIB= rumpnet_net # iffy stuff -SRCS= if.c if_loop.c route.c rtsock.c rtsock_50.c raw_usrreq.c \ +SRCS= if.c if_loop.c route.c rtbl.c rtsock.c rtsock_50.c raw_usrreq.c \ raw_cb.c if_media.c link_proto.c net_stats.c if_ethersubr.c SRCS+= if_43.c uipc_syscalls_50.c SRCS+= component.c diff --git a/sys/rump/net/lib/libsockin/sockin.c b/sys/rump/net/lib/libsockin/sockin.c index 57a2db7a359..920820c11b7 100644 --- a/sys/rump/net/lib/libsockin/sockin.c +++ b/sys/rump/net/lib/libsockin/sockin.c @@ -1,4 +1,4 @@ -/* $NetBSD: sockin.c,v 1.25 2010/12/05 18:01:46 pooka Exp $ */ +/* $NetBSD: sockin.c,v 1.26 2011/03/31 19:40:54 dyoung Exp $ */ /* * Copyright (c) 2008, 2009 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.25 2010/12/05 18:01:46 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.26 2011/03/31 19:40:54 dyoung Exp $"); #include <sys/param.h> #include <sys/condvar.h> @@ -93,7 +93,7 @@ struct domain sockindomain = { .dom_dispose = NULL, .dom_protosw = sockinsw, .dom_protoswNPROTOSW = &sockinsw[__arraycount(sockinsw)], - .dom_rtattach = rn_inithead, + .dom_rtattach = rt_inithead, .dom_rtoffset = 32, .dom_maxrtkey = sizeof(struct sockaddr_in), .dom_ifattach = NULL, diff --git a/sys/sys/domain.h b/sys/sys/domain.h index 2fd2bd149d6..8313b4861e0 100644 --- a/sys/sys/domain.h +++ b/sys/sys/domain.h @@ -1,4 +1,4 @@ -/* $NetBSD: domain.h,v 1.29 2009/09/11 22:06:29 dyoung Exp $ */ +/* $NetBSD: domain.h,v 1.30 2011/03/31 19:40:54 dyoung Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -39,6 +39,7 @@ */ #include <sys/mbuf.h> #include <sys/socket.h> +#include <net/route.h> /* * Forward structure declarations for function prototypes [sic]. @@ -47,7 +48,6 @@ struct lwp; struct mbuf; struct ifnet; struct ifqueue; -struct route; struct sockaddr; LIST_HEAD(dom_rtlist, route); @@ -63,7 +63,7 @@ struct domain { (struct mbuf *); const struct protosw *dom_protosw, *dom_protoswNPROTOSW; int (*dom_rtattach) /* initialize routing table */ - (void **, int); + (rtbl_t **, int); int dom_rtoffset; /* an arg to rtattach, in bits */ int dom_maxrtkey; /* for routing layer */ void *(*dom_ifattach) /* attach af-dependent data on ifnet */ |
