radix_mpath.c (260379) | radix_mpath.c (262763) |
---|---|
1/* $KAME: radix_mpath.c,v 1.17 2004/11/08 10:29:39 itojun Exp $ */ 2 3/* 4 * Copyright (C) 2001 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 20 unchanged lines hidden (view full) --- 29 * SUCH DAMAGE. 30 * THE AUTHORS DO NOT GUARANTEE THAT THIS SOFTWARE DOES NOT INFRINGE 31 * ANY OTHERS' INTELLECTUAL PROPERTIES. IN NO EVENT SHALL THE AUTHORS 32 * BE LIABLE FOR ANY INFRINGEMENT OF ANY OTHERS' INTELLECTUAL 33 * PROPERTIES. 34 */ 35 36#include <sys/cdefs.h> | 1/* $KAME: radix_mpath.c,v 1.17 2004/11/08 10:29:39 itojun Exp $ */ 2 3/* 4 * Copyright (C) 2001 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 20 unchanged lines hidden (view full) --- 29 * SUCH DAMAGE. 30 * THE AUTHORS DO NOT GUARANTEE THAT THIS SOFTWARE DOES NOT INFRINGE 31 * ANY OTHERS' INTELLECTUAL PROPERTIES. IN NO EVENT SHALL THE AUTHORS 32 * BE LIABLE FOR ANY INFRINGEMENT OF ANY OTHERS' INTELLECTUAL 33 * PROPERTIES. 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/sys/net/radix_mpath.c 260379 2014-01-06 22:36:20Z melifaro $"); | 37__FBSDID("$FreeBSD: head/sys/net/radix_mpath.c 262763 2014-03-05 01:17:47Z glebius $"); |
38 39#include "opt_inet.h" 40#include "opt_inet6.h" 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/malloc.h> 45#include <sys/socket.h> --- 34 unchanged lines hidden (view full) --- 80uint32_t 81rn_mpath_count(struct radix_node *rn) 82{ 83 uint32_t i = 0; 84 struct rtentry *rt; 85 86 while (rn != NULL) { 87 rt = (struct rtentry *)rn; | 38 39#include "opt_inet.h" 40#include "opt_inet6.h" 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/malloc.h> 45#include <sys/socket.h> --- 34 unchanged lines hidden (view full) --- 80uint32_t 81rn_mpath_count(struct radix_node *rn) 82{ 83 uint32_t i = 0; 84 struct rtentry *rt; 85 86 while (rn != NULL) { 87 rt = (struct rtentry *)rn; |
88 i += rt->rt_rmx.rmx_weight; | 88 i += rt->rt_weight; |
89 rn = rn_mpath_next(rn); 90 } 91 return (i); 92} 93 94struct rtentry * 95rt_mpath_matchgate(struct rtentry *rt, struct sockaddr *gate) 96{ --- 128 unchanged lines hidden (view full) --- 225 /* beyond here, we use rn as the master copy */ 226 rn0 = rn = (struct radix_node *)ro->ro_rt; 227 n = rn_mpath_count(rn0); 228 229 /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */ 230 hash += hashjitter; 231 hash %= n; 232 for (weight = abs((int32_t)hash), rt = ro->ro_rt; | 89 rn = rn_mpath_next(rn); 90 } 91 return (i); 92} 93 94struct rtentry * 95rt_mpath_matchgate(struct rtentry *rt, struct sockaddr *gate) 96{ --- 128 unchanged lines hidden (view full) --- 225 /* beyond here, we use rn as the master copy */ 226 rn0 = rn = (struct radix_node *)ro->ro_rt; 227 n = rn_mpath_count(rn0); 228 229 /* gw selection by Modulo-N Hash (RFC2991) XXX need improvement? */ 230 hash += hashjitter; 231 hash %= n; 232 for (weight = abs((int32_t)hash), rt = ro->ro_rt; |
233 weight >= rt->rt_rmx.rmx_weight && rn; 234 weight -= rt->rt_rmx.rmx_weight) { | 233 weight >= rt->rt_weight && rn; 234 weight -= rt->rt_weight) { |
235 236 /* stay within the multipath routes */ 237 if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask) 238 break; 239 rn = rn->rn_dupedkey; 240 rt = (struct rtentry *)rn; 241 } 242 /* XXX try filling rt_gwroute and avoid unreachable gw */ --- 52 unchanged lines hidden --- | 235 236 /* stay within the multipath routes */ 237 if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask) 238 break; 239 rn = rn->rn_dupedkey; 240 rt = (struct rtentry *)rn; 241 } 242 /* XXX try filling rt_gwroute and avoid unreachable gw */ --- 52 unchanged lines hidden --- |