Finish alternative balancing

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-05-08 13:55:13 -07:00
parent 6639b3534e
commit 3b6f5b2d8a
2 changed files with 8 additions and 2 deletions

View File

@ -608,7 +608,8 @@ sub add_a_provider( $$ ) {
}
}
emit( qq(echo $load > \${VARDIR}/${physical}_load) ) if $load;
emit( "echo $load > \${VARDIR}/${physical}_load",
'echo ' . in_hex( $mark ) . '/' . in_hex( $globals{PROVIDER_MASK} ) . " > \${VARDIR}/${physical}_mark" ) if $load;
emit( '',
"cat <<EOF >> \${VARDIR}/undo_${table}_routing" );
@ -618,6 +619,7 @@ sub add_a_provider( $$ ) {
emit_unindented ' ;;';
emit_unindented ' *)';
emit_unindented " rm -f \${VARDIR}/${physical}_load" if $load;
emit_unindented " rm -f \${VARDIR}/${physical}_mark" if $load;
emit_unindented <<"CEOF", 1;
rm -f \${VARDIR}/${physical}.status
;;

View File

@ -594,6 +594,7 @@ distribute_load() {
local interface
local totalload
local load
local mark
local maxload
maxload=$1
@ -605,6 +606,8 @@ distribute_load() {
if interface_up $interface; then
load=$(cat ${VARDIR}/${interface}_load)
eval ${interface}_load=$load
mark=$(cat ${VARDIR}/${interface}_mark)
eval ${interface}_mark=$mark
totalload=$( bc <<EOF
scale=8
$totalload + $load
@ -617,6 +620,7 @@ EOF
for interface in $@; do
qt $g_tool -t mangle -F ~$interface
eval load=\$${interface}_load
eval mark=\$${interface}_mark
if [ -n "$load" ]; then
load=$(bc <<EOF
@ -629,7 +633,7 @@ scale=8
$totalload - $load
EOF
)
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $load
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $load -j MARK --set-mark $mark
fi
done
fi