diff options
author | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2016-01-15 13:47:11 +0000 |
---|---|---|
committer | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2016-01-15 13:47:11 +0000 |
commit | b7d076ed19f75e61a8552542b7f6f374ac0f1ba8 (patch) | |
tree | a69737d72465aba284ac84c466e48215c15c8aea /sys/net/radix_mpath.c | |
parent | ac3490fdef8c0f0a6d5afebe3019b72d99f6b8dd (diff) | |
download | src-b7d076ed19f75e61a8552542b7f6f374ac0f1ba8.tar.gz src-b7d076ed19f75e61a8552542b7f6f374ac0f1ba8.zip |
Clean up original route path selection logic a bit.
NULL pointer dereference claimed by Coverity was possible
if one (or several) next-hops for had their weights set to 0.
CID: 1348482
Notes
Notes:
svn path=/head/; revision=294089
Diffstat (limited to 'sys/net/radix_mpath.c')
-rw-r--r-- | sys/net/radix_mpath.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/net/radix_mpath.c b/sys/net/radix_mpath.c index 56574002a972..5f40745f4904 100644 --- a/sys/net/radix_mpath.c +++ b/sys/net/radix_mpath.c @@ -201,19 +201,20 @@ static struct rtentry * rt_mpath_selectrte(struct rtentry *rte, uint32_t hash) { struct radix_node *rn0, *rn; - u_int32_t n; + uint32_t total_weight; struct rtentry *rt; int64_t weight; /* beyond here, we use rn as the master copy */ rn0 = rn = (struct radix_node *)rte; - n = rn_mpath_count(rn0); + rt = rte; /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */ + total_weight = rn_mpath_count(rn0); hash += hashjitter; - hash %= n; - for (weight = abs((int32_t)hash), rt = rte; - weight >= rt->rt_weight && rn; + hash %= total_weight; + for (weight = abs((int32_t)hash); + rt != NULL && weight >= rt->rt_weight; weight -= rt->rt_weight) { /* stay within the multipath routes */ |