summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-12-21 10:51:56 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-12-21 10:51:56 +0000
commit272e129f955dccd127298734ee73db6132737fe1 (patch)
treedcb7d3f32793967d4af90487bea01aff2833dedf /sys/net
parenteec5bde50074f5ff1c8ef326bed30c6e1012d759 (diff)
Pass the destination and mask to rtable_mpath_reprio() in order to not
use ``rt_node'' with ART.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/route.c10
-rw-r--r--sys/net/rtable.c40
-rw-r--r--sys/net/rtable.h5
3 files changed, 42 insertions, 13 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 0530ffac748..bc92bd4d346 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.292 2015/12/11 08:58:23 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.293 2015/12/21 10:51:55 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -1771,7 +1771,9 @@ rt_if_linkstate_change(struct rtentry *rt, void *arg, u_int id)
if (!(rt->rt_flags & RTF_UP)) {
/* bring route up */
rt->rt_flags |= RTF_UP;
- rtable_mpath_reprio(rt, rt->rt_priority & RTP_MASK);
+ rtable_mpath_reprio(id, rt_key(rt),
+ rt_plen2mask(rt, &sa_mask),
+ rt->rt_priority & RTP_MASK, rt);
}
} else {
if (rt->rt_flags & RTF_UP) {
@@ -1786,7 +1788,9 @@ rt_if_linkstate_change(struct rtentry *rt, void *arg, u_int id)
}
/* take route down */
rt->rt_flags &= ~RTF_UP;
- rtable_mpath_reprio(rt, rt->rt_priority | RTP_DOWN);
+ rtable_mpath_reprio(id, rt_key(rt),
+ rt_plen2mask(rt, &sa_mask),
+ rt->rt_priority | RTP_DOWN, rt);
}
}
if_group_routechange(rt_key(rt), rt_plen2mask(rt, &sa_mask));
diff --git a/sys/net/rtable.c b/sys/net/rtable.c
index d23aed470ae..9faaeebc4c5 100644
--- a/sys/net/rtable.c
+++ b/sys/net/rtable.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtable.c,v 1.35 2015/12/16 13:19:14 mpi Exp $ */
+/* $OpenBSD: rtable.c,v 1.36 2015/12/21 10:51:55 mpi Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -482,12 +482,15 @@ rtable_mpath_capable(unsigned int rtableid, sa_family_t af)
return (mpath);
}
-void
-rtable_mpath_reprio(struct rtentry *rt, uint8_t newprio)
+int
+rtable_mpath_reprio(unsigned int rtableid, struct sockaddr *dst,
+ struct sockaddr *mask, uint8_t prio, struct rtentry *rt)
{
struct radix_node *rn = (struct radix_node *)rt;
- rn_mpath_reprio(rn, newprio);
+ rn_mpath_reprio(rn, prio);
+
+ return (0);
}
struct rtentry *
@@ -749,7 +752,7 @@ rtable_insert(unsigned int rtableid, struct sockaddr *dst,
#ifndef SMALL_KERNEL
/* Put newly inserted entry at the right place. */
- rtable_mpath_reprio(rt, rt->rt_priority);
+ rtable_mpath_reprio(rtableid, dst, mask, rt->rt_priority, rt);
#endif /* SMALL_KERNEL */
return (0);
@@ -871,12 +874,31 @@ rtable_mpath_capable(unsigned int rtableid, sa_family_t af)
return (1);
}
-void
-rtable_mpath_reprio(struct rtentry *rt, uint8_t prio)
+int
+rtable_mpath_reprio(unsigned int rtableid, struct sockaddr *dst,
+ struct sockaddr *mask, uint8_t prio, struct rtentry *rt)
{
- struct art_node *an = rt->rt_node;
+ struct art_root *ar;
+ struct art_node *an;
+ uint8_t *addr;
+ int plen;
struct rtentry *mrt, *prt = NULL;
+ ar = rtable_get(rtableid, dst->sa_family);
+ if (ar == NULL)
+ return (EAFNOSUPPORT);
+
+ addr = satoaddr(ar, dst);
+ plen = rtable_satoplen(dst->sa_family, mask);
+
+ an = art_lookup(ar, addr, plen);
+ /* Make sure we've got a perfect match. */
+ if (an == NULL || an->an_plen != plen ||
+ memcmp(an->an_dst, dst, dst->sa_len))
+ return (ESRCH);
+
+ KASSERT(an == rt->rt_node);
+
KERNEL_ASSERT_LOCKED();
SRPL_REMOVE_LOCKED(&rt_rc, &an->an_rtlist, rt, rtentry, rt_next);
@@ -911,6 +933,8 @@ rtable_mpath_reprio(struct rtentry *rt, uint8_t prio)
} else {
SRPL_INSERT_HEAD_LOCKED(&rt_rc, &an->an_rtlist, rt, rt_next);
}
+
+ return (0);
}
struct rtentry *
diff --git a/sys/net/rtable.h b/sys/net/rtable.h
index 0ae181f5559..2aa29b27184 100644
--- a/sys/net/rtable.h
+++ b/sys/net/rtable.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtable.h,v 1.13 2015/12/03 21:57:59 mpi Exp $ */
+/* $OpenBSD: rtable.h,v 1.14 2015/12/21 10:51:55 mpi Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -70,6 +70,7 @@ int rtable_walk(unsigned int, sa_family_t,
int rtable_mpath_capable(unsigned int, sa_family_t);
struct rtentry *rtable_mpath_match(unsigned int, struct rtentry *,
struct sockaddr *, uint8_t);
-void rtable_mpath_reprio(struct rtentry *, uint8_t);
+int rtable_mpath_reprio(unsigned int, struct sockaddr *,
+ struct sockaddr *, uint8_t, struct rtentry *);
struct rtentry *rtable_mpath_next(struct rtentry *);
#endif /* _NET_RTABLE_H_ */