Changeset 21424


Ignore:
Timestamp:
2010-05-11T03:27:26+02:00 (7 years ago)
Author:
craigc
Message:

[packages] multiwan: updated load balancer algorithm

Location:
packages/net/multiwan
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • packages/net/multiwan/Makefile

    r21416 r21424  
    99 
    1010PKG_NAME:=multiwan 
    11 PKG_VERSION:=1.0.7 
    12 PKG_RELEASE:=2 
     11PKG_VERSION:=1.0.8 
     12PKG_RELEASE:=1 
    1313 
    1414include $(INCLUDE_DIR)/package.mk 
  • packages/net/multiwan/files/usr/bin/multiwan

    r21416 r21424  
    639639local last_probability 
    640640local total_weight 
     641local total_wans 
    641642local i 
     643local x 
     644local y 
    642645 
    643646echo "## Refreshing Load Balancer ##" 
     
    659662 
    660663total_weight=0 
     664total_wans=0 
    661665last_probability=0 
     666x=0 
     667y=0  
    662668 
    663669iptables -F MultiWanLoadBalancer -t mangle 
     
    673679        if [ "$gateway" != "x" -a "$ifname" != "x" -a "$failchk" != "x" -a "$weight" != "disable" ]; then 
    674680                total_weight=$(expr $total_weight + $weight) 
     681                total_wans=$i 
    675682        fi 
    676683done 
     
    688695if [ "$gateway" != "x" -a "$ifname" != "x" -a "$failchk" != "x" -a "$weight" != "disable" ]; then 
    689696nexthop="$nexthop nexthop via $gateway dev $ifname weight $weight" 
    690 rand_probability=$(expr $(expr $weight \* 100) / $total_weight + $last_probability) 
    691 last_probability=$rand_probability 
     697y=$last_probability 
     698last_probability=$(expr $x / $(expr $wancount - $i + 1)) 
     699rand_probability=$(expr $(expr $(expr $weight \* 100) / $total_weight) + $last_probability + $y) 
     700x=$rand_probability 
    692701 
    693702        if [ $rand_probability -lt 10 ]; then 
    694703                rand_probability="0.0${rand_probability}" 
    695         elif [ $rand_probability -lt 100 -a $i != $wancount ]; then 
     704        elif [ $rand_probability -lt 100 -a $i != $total_wans ]; then 
    696705                rand_probability="0.${rand_probability}" 
    697706        else 
Note: See TracChangeset for help on using the changeset viewer.