summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2015-11-06 17:55:55 +0000
committermpi <mpi@openbsd.org>2015-11-06 17:55:55 +0000
commit15765f575b183b8cad390832e9456828cbb4b72e (patch)
tree4fee685779192bccaece1b3b8e9fee6e0dc2773e
parentUse a SLIST instead of a LIST for MPATH route entries with ART. (diff)
downloadwireguard-openbsd-15765f575b183b8cad390832e9456828cbb4b72e.tar.xz
wireguard-openbsd-15765f575b183b8cad390832e9456828cbb4b72e.zip
Rename rt_mpath_next() into rtable_mpath_next() and provide an
implementation for ART based on the singly-linked list of route entries.
-rw-r--r--sys/net/if.c6
-rw-r--r--sys/net/pf.c4
-rw-r--r--sys/net/radix_mpath.c10
-rw-r--r--sys/net/route.h4
-rw-r--r--sys/net/rtable.c20
-rw-r--r--sys/net/rtable.h3
6 files changed, 26 insertions, 21 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index a93599f930f..a37709f1d1c 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.402 2015/11/03 12:25:37 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.403 2015/11/06 17:55:55 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -2356,7 +2356,7 @@ if_group_egress_build(void)
if_put(ifp);
}
#ifndef SMALL_KERNEL
- rt = rt_mpath_next(rt);
+ rt = rtable_mpath_next(rt);
#else
rt = NULL;
#endif
@@ -2377,7 +2377,7 @@ if_group_egress_build(void)
if_put(ifp);
}
#ifndef SMALL_KERNEL
- rt = rt_mpath_next(rt);
+ rt = rtable_mpath_next(rt);
#else
rt = NULL;
#endif
diff --git a/sys/net/pf.c b/sys/net/pf.c
index a3ba046611c..a5fa24024df 100644
--- a/sys/net/pf.c
+++ b/sys/net/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.948 2015/10/27 10:52:17 mpi Exp $ */
+/* $OpenBSD: pf.c,v 1.949 2015/11/06 17:55:55 mpi Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -5405,7 +5405,7 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif,
if (kif->pfik_ifp == ifp)
ret = 1;
#ifndef SMALL_KERNEL
- rt = rt_mpath_next(rt);
+ rt = rtable_mpath_next(rt);
#else
rt = NULL;
#endif
diff --git a/sys/net/radix_mpath.c b/sys/net/radix_mpath.c
index 5bebeb6e3e8..a62ded647da 100644
--- a/sys/net/radix_mpath.c
+++ b/sys/net/radix_mpath.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radix_mpath.c,v 1.34 2015/10/08 08:41:58 mpi Exp $ */
+/* $OpenBSD: radix_mpath.c,v 1.35 2015/11/06 17:55:55 mpi Exp $ */
/* $KAME: radix_mpath.c,v 1.13 2002/10/28 21:05:59 itojun Exp $ */
/*
@@ -96,14 +96,6 @@ rn_mpath_next(struct radix_node *rn, int mode)
return next;
}
-struct rtentry *
-rt_mpath_next(struct rtentry *rt)
-{
- struct radix_node *rn = (struct radix_node *)rt;
-
- return ((struct rtentry *)rn_mpath_next(rn, RMP_MODE_ACTIVE));
-}
-
/*
* return first route matching prio or the node just before.
*/
diff --git a/sys/net/route.h b/sys/net/route.h
index 3bfb4945132..accaba02bed 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.h,v 1.119 2015/11/06 17:44:45 mpi Exp $ */
+/* $OpenBSD: route.h,v 1.120 2015/11/06 17:55:55 mpi Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@@ -401,8 +401,6 @@ void rt_if_track(struct ifnet *);
int rt_if_linkstate_change(struct rtentry *, void *, u_int);
#endif
int rtdeletemsg(struct rtentry *, u_int);
-
-struct rtentry *rt_mpath_next(struct rtentry *);
#endif /* _KERNEL */
#endif /* _NET_ROUTE_H_ */
diff --git a/sys/net/rtable.c b/sys/net/rtable.c
index 2a8dc0bbeff..150588304cb 100644
--- a/sys/net/rtable.c
+++ b/sys/net/rtable.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtable.c,v 1.21 2015/11/06 17:44:45 mpi Exp $ */
+/* $OpenBSD: rtable.c,v 1.22 2015/11/06 17:55:55 mpi Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -429,7 +429,7 @@ rtable_mpath_select(struct rtentry *rt, uint32_t hash)
int npaths, threshold;
npaths = 1;
- while ((mrt = rt_mpath_next(mrt)) != NULL)
+ while ((mrt = rtable_mpath_next(mrt)) != NULL)
npaths++;
threshold = (0xffff / npaths) + 1;
@@ -437,7 +437,7 @@ rtable_mpath_select(struct rtentry *rt, uint32_t hash)
mrt = rt;
while (hash > threshold && mrt != NULL) {
/* stay within the multipath routes */
- mrt = rt_mpath_next(mrt);
+ mrt = rtable_mpath_next(mrt);
hash -= threshold;
}
@@ -458,6 +458,14 @@ rtable_mpath_reprio(struct rtentry *rt, uint8_t newprio)
rn_mpath_reprio(rn, newprio);
}
+
+struct rtentry *
+rtable_mpath_next(struct rtentry *rt)
+{
+ struct radix_node *rn = (struct radix_node *)rt;
+
+ return ((struct rtentry *)rn_mpath_next(rn, RMP_MODE_ACTIVE));
+}
#endif /* SMALL_KERNEL */
#else /* ART */
@@ -887,6 +895,12 @@ rtable_mpath_reprio(struct rtentry *rt, uint8_t prio)
SLIST_INSERT_HEAD(&an->an_rtlist, rt, rt_next);
}
}
+
+struct rtentry *
+rtable_mpath_next(struct rtentry *rt)
+{
+ return (SLIST_NEXT(rt, rt_next));
+}
#endif /* SMALL_KERNEL */
/*
diff --git a/sys/net/rtable.h b/sys/net/rtable.h
index 2bccba64459..0b32a2e31c0 100644
--- a/sys/net/rtable.h
+++ b/sys/net/rtable.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtable.h,v 1.9 2015/11/02 14:40:09 mpi Exp $ */
+/* $OpenBSD: rtable.h,v 1.10 2015/11/06 17:55:55 mpi Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -69,4 +69,5 @@ struct rtentry *rtable_mpath_match(unsigned int, struct rtentry *,
struct sockaddr *, uint8_t);
struct rtentry *rtable_mpath_select(struct rtentry *, uint32_t);
void rtable_mpath_reprio(struct rtentry *, uint8_t);
+struct rtentry *rtable_mpath_next(struct rtentry *);
#endif /* _NET_RTABLE_H_ */