diff options
author | 2016-02-24 22:41:53 +0000 | |
---|---|---|
committer | 2016-02-24 22:41:53 +0000 | |
commit | d6737014d5622fa82fba140d2ced117df6ac3678 (patch) | |
tree | 30506539d880453729f0eae98af56c2d01b3bbad | |
parent | Fix the build with DRMDEBUG. Committing now instead of after unlock to (diff) | |
download | wireguard-openbsd-d6737014d5622fa82fba140d2ced117df6ac3678.tar.xz wireguard-openbsd-d6737014d5622fa82fba140d2ced117df6ac3678.zip |
Fix ECMP routing by passing the correct destination address to the
hash routine.
Bug reported and fix analysed by Jean-Daniel Dupas <jddupas AT xooloo DOT net>
ok deraadt@
-rw-r--r-- | sys/net/route.c | 5 | ||||
-rw-r--r-- | sys/net/route.h | 4 | ||||
-rw-r--r-- | sys/net/rtable.c | 6 |
3 files changed, 7 insertions, 8 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index bc92bd4d346..08859f1a4b3 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.293 2015/12/21 10:51:55 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.294 2016/02/24 22:41:53 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -283,9 +283,8 @@ struct rtentry *_rtalloc(struct sockaddr *, uint32_t *, int, unsigned int); } while (0) int -rt_hash(struct rtentry *rt, uint32_t *src) +rt_hash(struct rtentry *rt, struct sockaddr *dst, uint32_t *src) { - struct sockaddr *dst = rt_key(rt); uint32_t a, b, c; if (src == NULL || !rtisvalid(rt) || !ISSET(rt->rt_flags, RTF_MPATH)) diff --git a/sys/net/route.h b/sys/net/route.h index 3326564b9f7..7741cdfd07c 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.131 2016/01/18 15:38:52 mpi Exp $ */ +/* $OpenBSD: route.h,v 1.132 2016/02/24 22:41:53 mpi Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -378,7 +378,7 @@ unsigned long rt_timer_queue_count(struct rttimer_queue *); void rt_timer_timer(void *); int rtisvalid(struct rtentry *); -int rt_hash(struct rtentry *, uint32_t *); +int rt_hash(struct rtentry *, struct sockaddr *, uint32_t *); #ifdef SMALL_KERNEL #define rtalloc_mpath(dst, s, rid) rtalloc((dst), RT_RESOLVE, (rid)) #else diff --git a/sys/net/rtable.c b/sys/net/rtable.c index 81a94e518aa..630c5e241dd 100644 --- a/sys/net/rtable.c +++ b/sys/net/rtable.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtable.c,v 1.38 2016/01/18 18:27:12 mpi Exp $ */ +/* $OpenBSD: rtable.c,v 1.39 2016/02/24 22:41:53 mpi Exp $ */ /* * Copyright (c) 2014-2015 Martin Pieuchot @@ -367,7 +367,7 @@ rtable_match(unsigned int rtableid, struct sockaddr *dst, uint32_t *src) #ifndef SMALL_KERNEL /* Gateway selection by Hash-Threshold (RFC 2992) */ - if ((hash = rt_hash(rt, src)) != -1) { + if ((hash = rt_hash(rt, dst, src)) != -1) { struct rtentry *mrt = rt; int threshold, npaths = 1; @@ -617,7 +617,7 @@ rtable_match(unsigned int rtableid, struct sockaddr *dst, uint32_t *src) #ifndef SMALL_KERNEL /* Gateway selection by Hash-Threshold (RFC 2992) */ - if ((hash = rt_hash(rt, src)) != -1) { + if ((hash = rt_hash(rt, dst, src)) != -1) { struct rtentry *mrt; struct srpl_iter i; int threshold, npaths = 0; |