jablonka.czprosek.czf

sedlo

Subversion Repositories:
[/] [trunk/] [sedlo] - Diff between revs 15 and 16

Show entire file Ignore whitespace

Rev 15 Rev 16
Line 3... Line 3...
# release date : 1/11/2006 # release date : 1/11/2006
# name : sedlo # name : sedlo
# description : dynamic side routing tables tool # description : dynamic side routing tables tool
# license : GPL # license : GPL
   
sl_version="0.0.4pre6" sl_version="0.0.4pre7"
   
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
   
sl_nmcnf="sedlo.conf" sl_nmcnf="sedlo.conf"
sl_sedlocnf="/etc/$sl_nmcnf" sl_sedlocnf="/etc/$sl_nmcnf"
sl_sedlocache="/var/cache/sedlo" sl_sedlocache="/var/cache/sedlo"
   
sl_rttab="/etc/iproute2/rt_tables" sl_rttab="/etc/iproute2/rt_tables"
sl_rtnmin=110 sl_rtnmin=110
sl_rtnmax=200 sl_rtnmax=200
  #all traffic that is handled as internal (CZF traffic)
sl_ipnodef="10.0.0.0/8" sl_ipnodef="10.0.0.0/8"
  #this will specify rupriority in rule table
  sl_priorules=10000
  #no default traffic will have rule at higher priority
  sl_prionodef=$(($sl_priorules - 1))
   
slm_unknown="Nezname parametry : " slm_unknown="Nezname parametry : "
   
sl_ipcmd=`which ip` sl_ipcmd=`which ip`
sl_trcmd=`which tr` sl_trcmd=`which tr`
Line 58... Line 63...
sl_merged=`echo $sl_rules $sl_ips | sort | uniq` sl_merged=`echo $sl_rules $sl_ips | sort | uniq`
   
echo $sl_merged echo $sl_merged
   
} # s_maru } # s_maru
   
###################################################################### ######################################################################
s_flru() #this will delete all rules at sl_prionodef an sl_priorules priorities
  s_flruall()
{ {
if [ $scm_info -gt 0 ]; then echo "Flushing all rules" ; fi if [ $scm_info -gt 0 ]; then echo "Flushing all rules" ; fi
   
sl_rules=`$sl_ipcmd ru ls | $sl_grepcmd -v "from all lookup" | $sl_grepcmd " 10." | $sl_trcmd '[:blank:]' '*'` sl_rules=`$sl_ipcmd ru ls | $sl_grepcmd "^"$sl_prionodef":" | $sl_trcmd '[:blank:]' '*'`
  for sl_rule in $sl_rules
  do
  sl_ipgws=`echo $sl_rule | $sl_awkcmd -F '*' '{print $2,$3,$4,$5,$6,$7}'`
  $sl_ipcmd ru del $sl_ipgws
  #this should make faster applying of new routing tables
  $sl_ipcmd ro flush cache
  done
   
  sl_rules=`$sl_ipcmd ru ls | $sl_grepcmd "^"$sl_priorules":" | $sl_trcmd '[:blank:]' '*'`
for sl_rule in $sl_rules for sl_rule in $sl_rules
do do
# sl_ipn=`echo $sl_rule | $sl_awkcmd -F '*' '{print $2}'`  
sl_ipgws=`echo $sl_rule | $sl_awkcmd -F '*' '{print $2,$3,$4,$5,$6,$7}'` sl_ipgws=`echo $sl_rule | $sl_awkcmd -F '*' '{print $2,$3,$4,$5,$6,$7}'`
$sl_ipcmd ru del $sl_ipgws $sl_ipcmd ru del $sl_ipgws
  #this should make faster applying of new routing tables
  $sl_ipcmd ro flush cache
done done
   
#this should make faster applying of new routing tables } # s_flruall
$sl_ipcmd ro flush cache  
  ######################################################################
  s_flru()
  {
  if [ $scm_info -gt 0 ]; then echo "Flushing all rules" ; fi
   
  sl_rules=`$sl_ipcmd ru ls | $sl_grepcmd ^$sl_priorules":" | $sl_trcmd '[:blank:]' '*'`
   
  for sl_rule in $sl_rules
  do
  sl_ipgws=`echo $sl_rule | $sl_awkcmd -F '*' '{print $2,$3,$4,$5,$6,$7}'`
  $sl_ipcmd ru del $sl_ipgws
  #this should make faster applying of new routing tables
  $sl_ipcmd ro flush cache
  done
   
} # s_flru } # s_flru
   
  ######################################################################
  s_checknodefru()
  {
  #checking if we have present nodef rule and if not we create it
  sl_nodefrule=`$sl_ipcmd ru ls | $sl_grepcmd "^"$sl_prionodef":" | $sl_trcmd '[:blank:]' '*'`
  #echo $sl_nodefrule
  if [ "$sl_nodefrule x" == " x" ]
  then
  if [ $scm_info -gt 0 ]; then echo "Creating rule for nodef route" ; fi
  $sl_ipcmd ru add from $sl_ipnodef to $sl_ipnodef lookup main prio $sl_prionodef
  echo "delam novou"
  fi
   
  }
   
###################################################################### ######################################################################
# here we get each ip and we create a rule to send this ip to a # here we get each ip and we create a rule to send this ip to a
# certain table # certain table
# this routine can be skipped when the number of ips and ip directions # this routine can be skipped when the number of ips and ip directions
# are still the same = old and new configs are the same # are still the same = old and new configs are the same
s_fillrules() s_fillrules()
{ {
   
  #this will check no default rule if exists and if not it will be created
  s_checknodefru
   
#flush old rules before filling new ones #flush old rules before filling new ones
#not so nice solution - it is planned to change just what's necessary #not so nice solution - it is planned to change just what's necessary
#by s_maru #by s_maru
s_flru s_flru
Line 104... Line 152...
for sl_ipgw in $sl_ipgws for sl_ipgw in $sl_ipgws
do do
sl_tbl=`$sl_ipcmd ro ls ta $sl_ipgw` sl_tbl=`$sl_ipcmd ro ls ta $sl_ipgw`
if [ "$sl_tbl x" != " x" ] && [ "$sl_ok" = "no" ] if [ "$sl_tbl x" != " x" ] && [ "$sl_ok" = "no" ]
then then
  #we have IP and GW
if [ $scm_info -gt 1 ]; then echo "Creating new rules to send $sl_ipn to table $sl_ipgw" ; fi if [ $scm_info -gt 1 ]; then echo "Creating new rules to send $sl_ipn to table $sl_ipgw" ; fi
$sl_ipcmd ru add from $sl_ipn lookup $sl_ipgw $sl_ipcmd ru add from $sl_ipn lookup $sl_ipgw prio $sl_priorules
   
  #this should make faster applying of new routing tables
  $sl_ipcmd ro flush cache
sl_ok="yes" sl_ok="yes"
else else
if [ "$sl_ok" = "no" ] if [ "$sl_ok" = "no" ]
then then
if [ $scm_info -gt 1 ]; then echo "For $sl_ipn table $sl_ipgw not used because it is empty" ; fi if [ $scm_info -gt 1 ]; then echo "For $sl_ipn table $sl_ipgw not used because it is empty" ; fi
else else
if [ $scm_info -gt 1 ]; then echo "For $sl_ipn table $sl_ipgw not used because it has lower priority" ; fi if [ $scm_info -gt 1 ]; then echo "For $sl_ipn table $sl_ipgw not used because it has lower priority" ; fi
fi fi
fi fi
done done
done done
   
$sl_ipcmd ru add from $sl_ipnodef to $sl_ipnodef lookup main  
   
#this should make faster applying of new routing tables  
$sl_ipcmd ro flush cache  
   
} # s_fillrules } # s_fillrules
   
###################################################################### ######################################################################
# here we look into the main routing table for path to our iGWs # here we look into the main routing table for path to our iGWs
Line 443... Line 491...
exit 0 exit 0
fi fi
   
if [ $scm_flru -eq 1 ] if [ $scm_flru -eq 1 ]
then then
s_flru s_flruall
exit 0 exit 0
fi fi
   
if [ $scm_nogetcfg -eq 0 ] if [ $scm_nogetcfg -eq 0 ]
then then
Line 470... Line 518...
#-force command line parameter was used #-force command line parameter was used
if [ $sl_difftbl -gt 0 ] || [ $sl_diffcfg -gt 0 ] || [ $sl_diffigw -gt 0 ] || [ $scm_force -gt 0 ] if [ $sl_difftbl -gt 0 ] || [ $sl_diffcfg -gt 0 ] || [ $sl_diffigw -gt 0 ] || [ $scm_force -gt 0 ]
then then
s_fillrules s_fillrules
fi fi
   
   
exit 0 exit 0
   

Powered by WebSVN 2.2.1