diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-21 10:51:56 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-21 10:51:56 +0000 |
commit | 272e129f955dccd127298734ee73db6132737fe1 (patch) | |
tree | dcb7d3f32793967d4af90487bea01aff2833dedf /sys/net/rtable.c | |
parent | eec5bde50074f5ff1c8ef326bed30c6e1012d759 (diff) |
Pass the destination and mask to rtable_mpath_reprio() in order to not
use ``rt_node'' with ART.
Diffstat (limited to 'sys/net/rtable.c')
-rw-r--r-- | sys/net/rtable.c | 40 |
1 files changed, 32 insertions, 8 deletions
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 * |