From 946940f045090e841444b8c249cbd1e57c6b7f52 Mon Sep 17 00:00:00 2001 From: Bret Lambert Date: Wed, 19 Sep 2012 16:14:02 +0000 Subject: Make rt_lookup return a pointer to an rtentry struct instead of to a radix_node struct. The radix tree pushdown continues. ok claudio@ --- sys/net/if.c | 8 +++----- sys/net/route.c | 6 +++--- sys/net/route.h | 4 ++-- sys/net/rtsock.c | 6 +++--- sys/netinet/ip_carp.c | 4 ++-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index ff32a18ca74..c2132ab5c8b 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.243 2012/09/19 12:35:07 blambert Exp $ */ +/* $OpenBSD: if.c,v 1.244 2012/09/19 16:14:01 blambert Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -2080,8 +2080,7 @@ if_group_egress_build(void) bzero(&sa_in, sizeof(sa_in)); sa_in.sin_len = sizeof(sa_in); sa_in.sin_family = AF_INET; - rt = (struct rtentry *)rt_lookup(sintosa(&sa_in), sintosa(&sa_in), 0); - if (rt) { + if ((rt = rt_lookup(sintosa(&sa_in), sintosa(&sa_in), 0)) != NULL) { do { if (rt->rt_ifp) if_addgroup(rt->rt_ifp, IFG_EGRESS); @@ -2095,8 +2094,7 @@ if_group_egress_build(void) #ifdef INET6 bcopy(&sa6_any, &sa_in6, sizeof(sa_in6)); - rt = (struct rtentry *)rt_lookup(sin6tosa(&sa_in6), sin6tosa(&sa_in6), 0); - if (rt) { + if ((rt = rt_lookup(sin6tosa(&sa_in6), sin6tosa(&sa_in6), 0)) != NULL) { do { if (rt->rt_ifp) if_addgroup(rt->rt_ifp, IFG_EGRESS); diff --git a/sys/net/route.c b/sys/net/route.c index 5ff8ca33e36..cfe5b908d5b 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.139 2012/09/19 12:35:07 blambert Exp $ */ +/* $OpenBSD: route.c,v 1.140 2012/09/19 16:14:01 blambert Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -1319,7 +1319,7 @@ rt_gettable(sa_family_t af, u_int id) return (rt_tables[id] ? rt_tables[id][af2rtafidx[af]] : NULL); } -struct radix_node * +struct rtentry * rt_lookup(struct sockaddr *dst, struct sockaddr *mask, u_int tableid) { struct radix_node_head *rnh; @@ -1327,7 +1327,7 @@ rt_lookup(struct sockaddr *dst, struct sockaddr *mask, u_int tableid) if ((rnh = rt_gettable(dst->sa_family, tableid)) == NULL) return (NULL); - return (rnh->rnh_lookup(dst, mask, rnh)); + return ((struct rtentry *)rnh->rnh_lookup(dst, mask, rnh)); } /* ARGSUSED */ diff --git a/sys/net/route.h b/sys/net/route.h index a85b495b829..960362ebd67 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.77 2012/09/19 12:35:07 blambert Exp $ */ +/* $OpenBSD: route.h,v 1.78 2012/09/19 16:14:01 blambert Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -411,7 +411,7 @@ int rt_if_linkstate_change(struct radix_node *, void *, u_int); int rtdeletemsg(struct rtentry *, u_int); struct radix_node_head *rt_gettable(sa_family_t, u_int); -struct radix_node *rt_lookup(struct sockaddr *, struct sockaddr *, u_int); +struct rtentry *rt_lookup(struct sockaddr *, struct sockaddr *, u_int); struct rtentry *rt_mpath_next(struct rtentry *, int); #endif /* _KERNEL */ diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 2ecfc0f6874..dd324a8b28b 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.121 2012/09/19 12:35:07 blambert Exp $ */ +/* $OpenBSD: rtsock.c,v 1.122 2012/09/19 16:14:01 blambert Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -617,12 +617,12 @@ route_output(struct mbuf *m, ...) error = EAFNOSUPPORT; goto flush; } - rn = rt_lookup(dst, netmask, tableid); + rt = rt_lookup(dst, netmask, tableid); + rn = (struct radix_node *)rt; if (rn == NULL || (rn->rn_flags & RNF_ROOT) != 0) { error = ESRCH; goto flush; } - rt = (struct rtentry *)rn; #ifndef SMALL_KERNEL /* * for RTM_CHANGE/LOCK, if we got multipath routes, diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index ac2b058d036..c35645e9151 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.196 2012/09/19 15:31:23 henning Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.197 2012/09/19 16:14:01 blambert Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -445,7 +445,7 @@ 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; - rt = (struct rtentry *)rt_lookup(&sa, + rt = rt_lookup(&sa, ifa->ifa_netmask, sc->sc_if.if_rdomain); nr_ourif = (rt && rt->rt_ifp == &sc->sc_if); -- cgit v1.2.3