From: numa Date: Fri, 28 Aug 2009 12:10:34 +0000 (+0200) Subject: prvi hack setOperMode i createIfc da se uopce dobije trivijalni instantiation na... X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=bccabeea50f4f00473605d6e1aa69f6451690875;p=imunes.git prvi hack setOperMode i createIfc da se uopce dobije trivijalni instantiation na Linuxu; masovna zamjena exec vimage s exec echo vimage da se izbjegnu greske --- diff --git a/exec.tcl b/exec.tcl index 61bdd69..4dae018 100755 --- a/exec.tcl +++ b/exec.tcl @@ -109,9 +109,11 @@ proc setOperMode { mode } { # Verify that links to external interfaces are properly configured if { $mode == "exec" } { - set extifcs [nexec ifconfig -l] + # space-separated popis interfacea (BSD ifconfig -l) + set extifcs [nexec ./ifconfig-l] + # izbaci loopback interface iz popisa (BSD lo) set extifcs \ - [lreplace $extifcs [lsearch $extifcs lo0] [lsearch $extifcs lo0]] + [lreplace $extifcs [lsearch $extifcs lo] [lsearch $extifcs lo]] foreach node $node_list { if { [nodeType $node] == "rj45" } { set i [lsearch $extifcs [getNodeName $node]] @@ -226,8 +228,9 @@ proc statline {line} { # * name -- the name of the new interface #**** proc createIfc { eid type hook } { - catch { exec printf "mkpeer $type $hook $hook \n show .$hook" | vimage $eid ngctl -f - } nglist - return [lindex $nglist 1] + puts { catch { exec printf "mkpeer $type $hook $hook \n show .$hook" | vimage $eid ngctl -f - } nglist } +### return [lindex $nglist 1] + return false } @@ -252,15 +255,15 @@ proc l3node.instantiate { eid node } { global mac_byte4 mac_byte5 set node_id "$eid\.$node" - nexec vimage -c $node_id - nexec vimage $node_id hostname [getNodeName $node] - nexec vimage $node_id sysctl vfs.morphing_symlinks=1 + nexec echo vimage -c $node_id + nexec echo vimage $node_id hostname [getNodeName $node] + nexec echo vimage $node_id sysctl vfs.morphing_symlinks=1 foreach ifc [ifcList $node] { switch -exact [string range $ifc 0 2] { eth { set ifid [createIfc $eid eiface ether] - nexec vimage $eid vimage -i $node $ifid $ifc + nexec echo vimage $eid vimage -i $node $ifid $ifc set peer [peerByIfc $node $ifc] if { [nodeType $peer] == "rj45" } { @@ -274,17 +277,17 @@ proc l3node.instantiate { eid node } { incr mac_byte4 } } - nexec vimage $node_id ifconfig $ifc link $ether + nexec echo vimage $node_id ifconfig $ifc link $ether set ngnodemap($ifc@$node_id) $ifid } ser { set ifnum [string range $ifc 3 end] set ifid [createIfc $eid iface inet] - nexec vimage $eid ngctl mkpeer $ifid: cisco inet inet - nexec vimage $eid ngctl connect $ifid: $ifid:inet inet6 inet6 - nexec vimage $eid ngctl msg $ifid: broadcast - nexec vimage $eid ngctl name $ifid:inet hdlc$ifnum\@$node - nexec vimage $eid vimage -i $node $ifid $ifc + nexec echo vimage $eid ngctl mkpeer $ifid: cisco inet inet + nexec echo vimage $eid ngctl connect $ifid: $ifid:inet inet6 inet6 + nexec echo vimage $eid ngctl msg $ifid: broadcast + nexec echo vimage $eid ngctl name $ifid:inet hdlc$ifnum\@$node + nexec echo vimage $eid vimage -i $node $ifid $ifc set ngnodemap(hdlc$ifnum@$node_id) hdlc$ifnum\@$node } } @@ -295,19 +298,19 @@ proc l3node.instantiate { eid node } { set cpumax [lindex [lsearch -inline $cpuconf {max *}] 1] set cpuweight [lindex [lsearch -inline $cpuconf {weight *}] 1] if { $cpumin != "" } { - nexec vimage -m $node_id cpumin $cpumin + nexec echo vimage -m $node_id cpumin $cpumin } if { $cpumax != "" } { - nexec vimage -m $node_id cpumax $cpumax + nexec echo vimage -m $node_id cpumax $cpumax } if { $cpuweight != "" } { - nexec vimage -m $node_id cpuweight $cpuweight + nexec echo vimage -m $node_id cpuweight $cpuweight } - nexec vimage $node_id sysctl net.inet.icmp.bmcastecho=1 - nexec vimage $node_id sysctl net.inet.icmp.icmplim=0 - nexec vimage $node_id ifconfig lo0 inet localhost - nexec vimage $node_id route add 224.0.0.0/4 localhost + nexec echo vimage $node_id sysctl net.inet.icmp.bmcastecho=1 + nexec echo vimage $node_id sysctl net.inet.icmp.icmplim=0 + nexec echo vimage $node_id ifconfig lo0 inet localhost + nexec echo vimage $node_id route add 224.0.0.0/4 localhost } @@ -365,7 +368,7 @@ proc l3node.start { eid node } { nexec chmod 1777 $node_dir foreach ifc [ifcList $node] { set mtu [getIfcMTU $node $ifc] - nexec vimage $node_id ifconfig $ifc mtu $mtu + nexec echo vimage $node_id ifconfig $ifc mtu $mtu } set check [info exists viewcustomid] @@ -403,7 +406,7 @@ proc l3node.start { eid node } { close $setkeyFileId set errorstr "" - set error [catch "nexec vimage $node_id setkey -f \ + set error [catch "nexec echo vimage $node_id setkey -f \ $node_dir/setkey.conf" errorstr] if { $error == "1" } { setkeyError $node_id $errorstr @@ -428,7 +431,7 @@ proc l3node.start { eid node } { nexec close_conf_file } - catch "nexec vimage $node_id $bootcmd $node_dir/boot.conf >& $node_dir/out.log &" + catch "nexec echo vimage $node_id $bootcmd $node_dir/boot.conf >& $node_dir/out.log &" } #****f* exec.tcl/l3node.shutdown @@ -446,13 +449,13 @@ proc l3node.start { eid node } { #**** proc l3node.shutdown { eid node } { set node_id "$eid\.$node" - catch "nexec vimage $node_id kill -9 -1 2> /dev/null" + catch "nexec echo vimage $node_id kill -9 -1 2> /dev/null" foreach ifc [ifcList $node] { foreach ipv4 [getIfcIPv4addr $node $ifc] { - catch "nexec vimage $node_id ifconfig $ifc $ipv4 -alias" + catch "nexec echo vimage $node_id ifconfig $ifc $ipv4 -alias" } foreach ipv6 [getIfcIPv6addr $node $ifc] { - catch "nexec vimage $node_id ifconfig $ifc inet6 $ipv6 -alias" + catch "nexec echo vimage $node_id ifconfig $ifc inet6 $ipv6 -alias" } } } @@ -474,14 +477,14 @@ proc l3node.shutdown { eid node } { proc l3node.destroy { eid node } { set node_id $node foreach ifc [ifcList $node] { - catch { nexec vimage $eid ngctl msg $ifc@$node_id: shutdown } + catch { nexec echo vimage $eid ngctl msg $ifc@$node_id: shutdown } set ifnum [string range $ifc 3 end] set ifname [string range $ifc 0 2] if { $ifname == "ser" } { - catch { nexec vimage $eid ngctl msg hdlc$ifnum@$node_id: shutdown } + catch { nexec echo vimage $eid ngctl msg hdlc$ifnum@$node_id: shutdown } } } - catch {nexec vimage -d $node_id} + catch {nexec echo vimage -d $node_id} set node_dir "/tmp/$eid/$node" nexec rm -fr $node_dir } @@ -515,7 +518,7 @@ proc deployCfg {} { set t_start [clock seconds] - catch { nexec vimage -c $eid } + catch { nexec echo vimage -c $eid } catch { nexec rm -fr /tmp/$eid } catch { nexec mkdir /tmp/$eid } @@ -578,15 +581,15 @@ proc deployCfg {} { [lindex [[typemodel $lnode1].nghook $eid $lnode1 $ifname1] 1] set nghook2 \ [lindex [[typemodel $lnode2].nghook $eid $lnode2 $ifname2] 1] - nexec vimage $eid ngctl mkpeer $ngpeer1: pipe $nghook1 upper - nexec vimage $eid ngctl name $ngpeer1:$nghook1 $lname - nexec vimage $eid ngctl connect $lname: $ngpeer2: lower $nghook2 + nexec echo vimage $eid ngctl mkpeer $ngpeer1: pipe $nghook1 upper + nexec echo vimage $eid ngctl name $ngpeer1:$nghook1 $lname + nexec echo vimage $eid ngctl connect $lname: $ngpeer2: lower $nghook2 # Ethernet frame has a 14-byte header - this is a temp. hack!!! - nexec vimage $eid ngctl msg $lname: setcfg "{ header_offset=14 }" + nexec echo vimage $eid ngctl msg $lname: setcfg "{ header_offset=14 }" # Link parameters - nexec vimage $eid ngctl msg $lname: setcfg \ + nexec echo vimage $eid ngctl msg $lname: setcfg \ "{ bandwidth=$bandwidth delay=$delay \ upstream={ BER=$ber duplicate=$dup } \ downstream={ BER=$ber duplicate=$dup } }" @@ -646,7 +649,7 @@ proc vimageCleanup { eid } { global execMode set t_start [clock seconds] - if { [catch {nexec vimage $eid vimage -lr | fgrep -v " " | cut -d: -f 1} res] != 0 } { + if { [catch {nexec echo vimage $eid vimage -lr | fgrep -v " " | cut -d: -f 1} res] != 0 } { return } set vimages [join $res] @@ -679,7 +682,7 @@ Please don't try killing the process. set vrti 0 foreach vimage $vimages { # puts "vimage $vimage...\n" - while { [catch {nexec vimage $eid.$vimage netstat -an -f inet | fgrep "WAIT"} odg] == 0} { + while { [catch {nexec echo vimage $eid.$vimage netstat -an -f inet | fgrep "WAIT"} odg] == 0} { set vrti 1 # puts "vimage $vimage: \n$odg\n" after 2000 @@ -704,30 +707,30 @@ Please don't try killing the process. foreach vimage $vimages { set stattxt "Terminating processes in vimage $vimage" statline $stattxt - catch {nexec vimage $eid.$vimage kill -9 -1 2> /dev/null} + catch {nexec echo vimage $eid.$vimage kill -9 -1 2> /dev/null} } # Detach / destroy / reassign interfaces pipe, eiface, iface, bridge - set ngnodes [split [nexec vimage $eid ngctl l | tail -n +3] " + set ngnodes [split [nexec echo vimage $eid ngctl l | tail -n +3] " "] foreach ngline $ngnodes { set node [lindex [eval list $ngline] 1] statline "Shutting down netgraph node $node" - catch "nexec vimage $eid ngctl msg $node: shutdown" + catch "nexec echo vimage $eid ngctl msg $node: shutdown" } # Shut down all vimages foreach vimage $vimages { set stattxt "Shutting down vimage $vimage" statline $stattxt - catch {nexec vimage $eid.$vimage kill -9 -1 2> /dev/null} - while { [catch {nexec vimage -d $eid.$vimage}] } { + catch {nexec echo vimage $eid.$vimage kill -9 -1 2> /dev/null} + while { [catch {nexec echo vimage -d $eid.$vimage}] } { set stattxt $stattxt. statline $stattxt - catch {nexec vimage $eid.$vimage kill -9 -1 2> /dev/null} + catch {nexec echo vimage $eid.$vimage kill -9 -1 2> /dev/null} } } - catch { nexec vimage -d $eid } + catch { nexec echo vimage -d $eid } catch { nexec rm -f /usr/local/etc/quagga/Quagga.conf } nexec rm -fr "/tmp/$eid" statline "Cleanup completed in [expr [clock seconds] - $t_start] seconds." @@ -765,9 +768,9 @@ proc execSetIfcQDisc { eid node ifc qdisc } { DRR { set qdisc drr } } set ngnode "$lnode1-$lnode2" - if { [catch { nexec vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ $qdisc=1 } }" }] } { + if { [catch { nexec echo vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ $qdisc=1 } }" }] } { set ngnode "$lnode2-$lnode1" - nexec vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ $qdisc=1 } }" + nexec echo vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ $qdisc=1 } }" } } @@ -802,10 +805,10 @@ proc execSetIfcQDrop { eid node ifc qdrop } { drop-tail { set qdrop droptail } } set ngnode "$lnode1-$lnode2" - if { [catch { nexec vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ $qdrop=1 } }" }] } { + if { [catch { nexec echo vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ $qdrop=1 } }" }] } { # XXX dir should be reversed! set ngnode "$lnode2-$lnode1" - nexec vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ $qdrop=1 } }" + nexec echo vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ $qdrop=1 } }" } } @@ -838,9 +841,9 @@ proc execSetIfcQLen { eid node ifc qlen } { if { $qlen == 0 } { set qlen -1 } - if { [catch { nexec vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ queuelen=$qlen } }" }] } { + if { [catch { nexec echo vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ queuelen=$qlen } }" }] } { set ngnode "$lnode2-$lnode1" - nexec vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ queuelen=$qlen } }" + nexec echo vimage $eid ngctl msg $ngnode: setcfg "{ $dir={ queuelen=$qlen } }" } } @@ -880,7 +883,7 @@ proc execSetLinkParams { eid link } { set dup -1 } - nexec vimage $eid ngctl msg $lname: setcfg \ + nexec echo vimage $eid ngctl msg $lname: setcfg \ "{ bandwidth=$bandwidth delay=$delay \ upstream={ BER=$ber duplicate=$dup } \ downstream={ BER=$ber duplicate=$dup } }"