diff options
author | 2012-09-19 12:35:07 +0000 | |
---|---|---|
committer | 2012-09-19 12:35:07 +0000 | |
commit | f3b9ef5adaf46eed6d18616c7ff5273cd069471c (patch) | |
tree | 431fc537e7ff2db6629b61b72c8bfde80690751f | |
parent | remove IS_RELAY and IS_MAILBOX macros. (diff) | |
download | wireguard-openbsd-f3b9ef5adaf46eed6d18616c7ff5273cd069471c.tar.xz wireguard-openbsd-f3b9ef5adaf46eed6d18616c7ff5273cd069471c.zip |
More radix internals pushdown; place rn_mpath_next, which accepts and
returns radix_node pointers, inside a new rt_mpath_next, which accepts
and returns rtentry pointers, and start using that instead.
ok claudio@
-rw-r--r-- | sys/net/if.c | 23 | ||||
-rw-r--r-- | sys/net/pf.c | 10 | ||||
-rw-r--r-- | sys/net/route.c | 14 | ||||
-rw-r--r-- | sys/net/route.h | 4 | ||||
-rw-r--r-- | sys/net/rtsock.c | 4 |
5 files changed, 31 insertions, 24 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index bc4522bf9ec..ff32a18ca74 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.242 2012/09/18 08:16:33 blambert Exp $ */ +/* $OpenBSD: if.c,v 1.243 2012/09/19 12:35:07 blambert Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -2065,7 +2065,6 @@ if_group_egress_build(void) #ifdef INET6 struct sockaddr_in6 sa_in6; #endif - struct radix_node *rn; struct rtentry *rt; TAILQ_FOREACH(ifg, &ifg_head, ifg_next) @@ -2081,32 +2080,32 @@ if_group_egress_build(void) bzero(&sa_in, sizeof(sa_in)); sa_in.sin_len = sizeof(sa_in); sa_in.sin_family = AF_INET; - if ((rn = rt_lookup(sintosa(&sa_in), sintosa(&sa_in), 0)) != NULL) { + rt = (struct rtentry *)rt_lookup(sintosa(&sa_in), sintosa(&sa_in), 0); + if (rt) { do { - rt = (struct rtentry *)rn; if (rt->rt_ifp) if_addgroup(rt->rt_ifp, IFG_EGRESS); #ifndef SMALL_KERNEL - rn = rn_mpath_next(rn, 0); + rt = rt_mpath_next(rt, 0); #else - rn = NULL; + rt = NULL; #endif - } while (rn != NULL); + } while (rt != NULL); } #ifdef INET6 bcopy(&sa6_any, &sa_in6, sizeof(sa_in6)); - if ((rn = rt_lookup(sin6tosa(&sa_in6), sin6tosa(&sa_in6), 0)) != NULL) { + rt = (struct rtentry *)rt_lookup(sin6tosa(&sa_in6), sin6tosa(&sa_in6), 0); + if (rt) { do { - rt = (struct rtentry *)rn; if (rt->rt_ifp) if_addgroup(rt->rt_ifp, IFG_EGRESS); #ifndef SMALL_KERNEL - rn = rn_mpath_next(rn, 0); + rt = rt_mpath_next(rt, 0); #else - rn = NULL; + rt = NULL; #endif - } while (rn != NULL); + } while (rt != NULL); } #endif diff --git a/sys/net/pf.c b/sys/net/pf.c index de049198099..58742d22ae5 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.811 2012/09/18 10:11:53 henning Exp $ */ +/* $OpenBSD: pf.c,v 1.812 2012/09/19 12:35:07 blambert Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -5710,7 +5710,6 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif, #else struct route ro; #endif - struct radix_node *rn; struct rtentry *rt; struct ifnet *ifp; @@ -5764,9 +5763,8 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif, /* Perform uRPF check if passed input interface */ ret = 0; - rn = (struct radix_node *)ro.ro_rt; + rt = ro.ro_rt; do { - rt = (struct rtentry *)rn; if (rt->rt_ifp->if_type == IFT_CARP) ifp = rt->rt_ifp->if_carpdev; else @@ -5774,8 +5772,8 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif, if (kif->pfik_ifp == ifp) ret = 1; - rn = rn_mpath_next(rn, 0); - } while (check_mpath == 1 && rn != NULL && ret == 0); + rt = rt_mpath_next(rt, 0); + } while (check_mpath == 1 && rt != NULL && ret == 0); } else ret = 0; out: diff --git a/sys/net/route.c b/sys/net/route.c index 4533c371216..5ff8ca33e36 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.138 2012/09/18 08:16:33 blambert Exp $ */ +/* $OpenBSD: route.c,v 1.139 2012/09/19 12:35:07 blambert Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -774,7 +774,7 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio, if (rn_mpath_capable(rnh)) { if ((rn = rnh->rnh_lookup(info->rti_info[RTAX_DST], info->rti_info[RTAX_NETMASK], rnh)) != NULL && - rn_mpath_next(rn, 0) == NULL) + rt_mpath_next((struct rtentry *)rn, 0) == NULL) ((struct rtentry *)rn)->rt_flags &= ~RTF_MPATH; } #endif @@ -972,7 +972,7 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio, (rn = rnh->rnh_lookup(info->rti_info[RTAX_DST], info->rti_info[RTAX_NETMASK], rnh)) != NULL && (rn = rn_mpath_prio(rn, prio)) != NULL) { - if (rn_mpath_next(rn, 0) == NULL) + if (rt_mpath_next((struct rtentry *)rn, 0) == NULL) ((struct rtentry *)rn)->rt_flags &= ~RTF_MPATH; else ((struct rtentry *)rn)->rt_flags |= RTF_MPATH; @@ -1548,4 +1548,12 @@ rt_if_linkstate_change(struct radix_node *rn, void *arg, u_int id) return (0); } + +struct rtentry * +rt_mpath_next(struct rtentry *rt, int all) +{ + struct radix_node *rn = (struct radix_node *)rt; + + return ((struct rtentry *)rn_mpath_next(rn, all)); +} #endif diff --git a/sys/net/route.h b/sys/net/route.h index de2ea27be6a..a85b495b829 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.76 2012/03/17 10:16:41 dlg Exp $ */ +/* $OpenBSD: route.h,v 1.77 2012/09/19 12:35:07 blambert Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -412,5 +412,7 @@ 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_mpath_next(struct rtentry *, int); #endif /* _KERNEL */ #endif /* _NET_ROUTE_H_ */ diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index fda5ae0cb05..2ecfc0f6874 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.120 2012/09/17 19:00:36 blambert Exp $ */ +/* $OpenBSD: rtsock.c,v 1.121 2012/09/19 12:35:07 blambert Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -644,7 +644,7 @@ route_output(struct mbuf *m, ...) } /* if multipath routes */ - if (rn_mpath_next(rn, 0)) { + if (rt_mpath_next(rt, 0)) { if (gate) rt = rt_mpath_matchgate(rt, gate, prio); else if (rtm->rtm_type != RTM_GET) |