diff options
author | Ermal <eri@pfsense.org> | 2010-04-30 14:32:25 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2010-04-30 14:32:25 +0000 |
commit | 5f53260a2da559c71a5de91dc5c6a332e664b24e (patch) | |
tree | ecc42481ed81b7349b47bdf5b45f3cfca3da08cc /etc | |
parent | 05f3ffa431cf622828d311dd9b9b8ea49f9d1006 (diff) | |
download | pfsense-5f53260a2da559c71a5de91dc5c6a332e664b24e.zip pfsense-5f53260a2da559c71a5de91dc5c6a332e664b24e.tar.gz |
Allow for each gateway a weight to be choosen if the gateway has to be used in Gateway groups. This will create that many entries in the route-to statement as the weight says.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/filter.inc | 14 | ||||
-rw-r--r-- | etc/inc/gwlb.inc | 19 |
2 files changed, 17 insertions, 16 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 51c88f9..f44482d 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -549,13 +549,14 @@ function filter_generate_gateways() { if (!is_ipaddr($gwip)) $gwip = get_interface_gateway($gateway['friendlyiface']); if (is_ipaddr($gwip) && !empty($int)) - $route = "route-to ( {$int} {$gwip} )\n"; + $route = "route-to ( {$int} {$gwip} )"; $rules .= "{$gwname} = \" {$route} \"\n"; } } - if(is_array($GatewayGroupsList)) { + if (is_array($GatewayGroupsList)) { foreach ($GatewayGroupsList as $gateway => $members) { + $route = ""; if (count($members) > 0) { $foundlb = 0; $routeto = ""; @@ -565,9 +566,10 @@ function filter_generate_gateways() { if (($int <> "") && is_ipaddr($gatewayip)) { if ($g['debug']) log_error("Setting up route with {$gatewayip} om $int"); - if ($idx > 1) - $routeto .= ", "; - $routeto .= "( {$int} {$gatewayip} ) "; + if ($member['weight'] > 1) { + $routeto .= str_repeat("( {$int} {$gatewayip} ) ", $member['weight']); + } else + $routeto .= "( {$int} {$gatewayip} ) "; $foundlb = 1; } else log_error("An error occurred while trying to find the interface got $gatewayip . The rule has not been added."); @@ -581,8 +583,8 @@ function filter_generate_gateways() { $route .= " sticky-address "; } } - $rules .= "{$gateway} = \" {$route} \"\n"; } + $rules .= "{$gateway} = \" {$route} \"\n"; } } diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc index 30640b3..4156afc 100644 --- a/etc/inc/gwlb.inc +++ b/etc/inc/gwlb.inc @@ -403,22 +403,21 @@ function return_gateway_groups_array() { /* we do not really foreach the tiers as we stop after the first tier */ foreach($tiers as $tiernr => $tier) { /* process all gateways in this tier */ - $member_count = count($tier); foreach($tier as $tiernr => $member) { /* determine interface gateway */ - foreach($gateways_arr as $name => $gateway) { - if($gateway['name'] == $member) { - $int = $gateway['interface']; - if(is_ipaddr($gateway['gateway'])) - $gatewayip = $gateway['gateway']; - else - $gatewayip = lookup_gateway_ip_by_name($gateway['gateway']); - break; - } + if (isset($gateways_arr[$member])) { + $gateway = $gateways_arr[$member]; + $int = $gateway['interface']; + $gatewayip = ""; + if(is_ipaddr($gateway['gateway'])) + $gatewayip = $gateway['gateway']; + else if ($int <> "") + $gatewayip = get_interface_gateway($gateway['friendlyiface']); } if (($int <> "") && is_ipaddr($gatewayip)) { $gateway_groups_array[$group['name']][$tiernr]['int'] = "$int"; $gateway_groups_array[$group['name']][$tiernr]['gwip'] = "$gatewayip"; + $gateway_groups_array[$group['name']][$tiernr]['weight'] = isset($gateway['weight']) ? $gateway['weight'] : 0; } } /* we should have the 1st available tier now, exit stage left */ |