From: Josip Rodin Date: Sun, 13 Sep 2009 16:01:20 +0000 (+0200) Subject: da bi se ispravno mogao pokrenuti router.quagga, trebalo je napraviti X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=1c807789abd46b3ddf7eb62cb50937f40b669393;p=imunes.git da bi se ispravno mogao pokrenuti router.quagga, trebalo je napraviti nekoliko stvari: * prebaciti vzctl start iz l3node.instantiate u l3node.start (gdje mu je zapravo logicno i mjesto) * povlaci prebacivanje ifcList parsinga u l3node.start jer vzctl ne zeli napraviti --netif_add bez pokrenutog VEa * podesiti ve_dir odmah nakon vzctl create tako da je dostupan za vrijeme .instantiate u modulima * prebaciti, prilagoditi i aktivirati /etc/quagga fiddling u quagga .instantiate proceduru * prebaciti vzctl exec sysctl -w iz quagga .instantiate u quagga .start proceduru, jer VE mora biti pokrenut * dodati vzctl set --capability fiddling u quagga .start a prije l3node.start tako da se zebra smije pokrenuti --- diff --git a/linux/exec.tcl b/linux/exec.tcl index 4d82463..65d03be 100755 --- a/linux/exec.tcl +++ b/linux/exec.tcl @@ -259,8 +259,6 @@ proc createIfc { eid type hook } { # * node -- node id #**** proc l3node.instantiate { eid node } { - upvar 0 ::cf::[set ::curcfg]::ngnodemap ngnodemap - global mac_byte4 mac_byte5 puts "\nl3node.INSTANTIATE $eid $node" @@ -274,6 +272,10 @@ proc l3node.instantiate { eid node } { # puts " nexec vimage -c $node_id " nexec vzctl create $ve_id --ostemplate imunes-openvz +# ovdje vec znamo u kojem je VE direktoriju + upvar 0 ::cf::[set ::curcfg]::[set node]::ve_dir ve_dir + set ve_dir "/var/lib/vz/private/$ve_id" + # Dodjela naseg kratkog node ida njegovom numerickom VE ID-u opcijom --name # Zbog supporta za vise paralelnih eksperimenata, VE name je # node_id tako da sadrzi i $node i prefiks $eid @@ -285,69 +287,6 @@ proc l3node.instantiate { eid node } { # feature FreeBSD-a only (expandanje @ u symlinkovima kao node id) # puts " nexec vimage $node_id sysctl vfs.morphing_symlinks=1 " - nexec vzctl start $node_id - -# s Linux/OpenVZ moramo pricekati da se izvrti init procedura, koja -# nam omoguci razne korisne stvari tipa proc filesystem itd - upvar 0 ::cf::[set ::curcfg]::[set node]::ve_dir ve_dir - set ve_dir "/var/lib/vz/private/$ve_id" - set ve_boot_done "$ve_dir/tmp/imunes-boot-done" - puts " waiting for VE $ve_id to actually start..." - while { ! [ file exists $ve_boot_done ] } { - after 100 - } - puts " detected VE $ve_id done" - file delete $ve_boot_done - - foreach ifc [ifcList $node] { - switch -exact [string range $ifc 0 2] { - eth { -# FreeBSD-specific: -# set ifid [createIfc $eid eiface ether] -# puts " nexec vimage $eid vimage -i $node $ifid $ifc " - -# na Linuxu ne moramo pokrenuti createIfc, samo postaviti ovaj standardni format -# koji ide u vzctl --netif_add - set ifid "e${node_id}_${ifc}" - - set peer [peerByIfc $node $ifc] - - puts " Interface $ifc at $node links to $peer" - - if { [nodeType $peer] == "rj45" } { - # TODO: RJ45 nodes zasad ne podrzavamo - set peerifc [getNodeName $peer] - #set ether [nexec ifconfig $peerifc | grep "HWaddr " | cut -c8-] - set ether [nexec ifconfig $peerifc | grep $peerifc | awk {{print $5}}] - puts " Za RJ45 interface -> MAC(eth0) = $ether" - } else { - # vzctl ne prima ako nije properly padded - set ether 40:00:aa:aa:[format %02x $mac_byte4]:[format %02x $mac_byte5] - set host_ether 40:00:aa:ff:[format %02x $mac_byte4]:[format %02x $mac_byte5] - incr mac_byte5 - if { $mac_byte5 >= 100 } { - set mac_byte5 0 - incr mac_byte4 - } - } -# puts " nexec vimage $node_id ifconfig $ifc link $ether " - nexec vzctl {set} $node_id --netif_add $ifc,$ether,$ifid,$host_ether - set ngnodemap($ifc@$node_id) $ifid - } - ser { -# TODO: serial interfaceove zasad ne podrzavamo -# 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 -# set ngnodemap(hdlc$ifnum@$node_id) hdlc$ifnum\@$node - } - } - } - # TODO: OpenVZ CPU tuning # set cpuconf [getNodeCPUConf $node] # set cpumin [lindex [lsearch -inline $cpuconf {min *}] 1] @@ -422,6 +361,77 @@ proc l3node.start { eid node } { puts "\nl3node.START $eid $node" upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id + upvar 0 ::cf::[set ::curcfg]::[set node]::ve_id ve_id + +# Linux/OpenVZ doista ima start i on treba biti ovdje +# tako da se izmedju instantiate i start mogu podesavati +# varijable koje zahtijevaju ugasen VE + nexec vzctl start $node_id + +# moramo pricekati da se izvrti init procedura, koja +# nam omoguci razne korisne stvari tipa proc filesystem itd + upvar 0 ::cf::[set ::curcfg]::[set node]::ve_dir ve_dir + set ve_boot_done "$ve_dir/tmp/imunes-boot-done" + puts " waiting for VE $ve_id to actually start..." + while { ! [ file exists $ve_boot_done ] } { + after 100 + } + puts " detected VE $ve_id done" + file delete $ve_boot_done + +# OpenVZ zahtijeva da VE bude started za --netif_add + + upvar 0 ::cf::[set ::curcfg]::ngnodemap ngnodemap + global mac_byte4 mac_byte5 + + foreach ifc [ifcList $node] { + switch -exact [string range $ifc 0 2] { + eth { +# FreeBSD-specific: +# set ifid [createIfc $eid eiface ether] +# puts " nexec vimage $eid vimage -i $node $ifid $ifc " + +# na Linuxu ne moramo pokrenuti createIfc, samo postaviti ovaj standardni format +# koji ide u vzctl --netif_add + set ifid "e${node_id}_${ifc}" + + set peer [peerByIfc $node $ifc] + + puts " Interface $ifc at $node links to $peer" + + if { [nodeType $peer] == "rj45" } { + # TODO: RJ45 nodes zasad ne podrzavamo + set peerifc [getNodeName $peer] + #set ether [nexec ifconfig $peerifc | grep "HWaddr " | cut -c8-] + set ether [nexec ifconfig $peerifc | grep $peerifc | awk {{print $5}}] + puts " Za RJ45 interface -> MAC(eth0) = $ether" + } else { + # vzctl ne prima ako nije properly padded + set ether 40:00:aa:aa:[format %02x $mac_byte4]:[format %02x $mac_byte5] + set host_ether 40:00:aa:ff:[format %02x $mac_byte4]:[format %02x $mac_byte5] + incr mac_byte5 + if { $mac_byte5 >= 100 } { + set mac_byte5 0 + incr mac_byte4 + } + } +# puts " nexec vimage $node_id ifconfig $ifc link $ether " + nexec vzctl {set} $node_id --netif_add $ifc,$ether,$ifid,$host_ether + set ngnodemap($ifc@$node_id) $ifid + } + ser { +# TODO: serial interfaceove zasad ne podrzavamo +# 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 +# set ngnodemap(hdlc$ifnum@$node_id) hdlc$ifnum\@$node + } + } + } # na FreeBSD-u vimagei imaju shared filesystem # set node_dir "/tmp/$eid/$node" @@ -429,8 +439,8 @@ proc l3node.start { eid node } { # nexec rm -fr $node_dir # nexec mkdir $node_dir # nexec chmod 1777 $node_dir + # na Linuxu VEovi imaju svaki svoj dir - upvar 0 ::cf::[set ::curcfg]::[set node]::ve_dir ve_dir set node_dir $ve_dir # TODO: konfiguriranje MTU-a zasad ne podrzavamo (kao ni ostale L2 parametre) @@ -841,16 +851,6 @@ proc deployCfg {} { # execSetIfcQLen $eid $node $ifc [getIfcQLen $node $ifc] # } # } -# } - -# # XXX move those to some quagga specific script -# # XXX race if starting two imunes instances simultaneously -# nexec rm -fr /var/run/quagga -# nexec rm -f /usr/local/etc/quagga/Quagga.conf -# puts { nexec ln -s /tmp/$eid/@ /var/run/quagga } -# puts { nexec ln -s /tmp/$eid/@/boot.conf /usr/local/etc/quagga/Quagga.conf } -# foreach file { bgpd ospfd ospf6d ripd ripngd vtysh zebra } { -# puts { nexec cp /dev/null /usr/local/etc/quagga/$file.conf } # } foreach node $node_list { diff --git a/linux/quagga.tcl b/linux/quagga.tcl index 51a2381..ecc5e1d 100755 --- a/linux/quagga.tcl +++ b/linux/quagga.tcl @@ -176,7 +176,7 @@ proc $MODULE.shellcmd { node } { # for a given node in imunes. # Procedure router.quagga.instantiate cretaes a new virtual node # with all the interfaces and CPU parameters as defined -# in imunes. It then enables the kernel tunables for IP forwarding. +# in imunes. # INPUTS # * eid - experiment id # * node_id - id of the node (type of the node is router @@ -185,11 +185,21 @@ proc $MODULE.shellcmd { node } { proc $MODULE.instantiate { eid node } { l3node.instantiate $eid $node - upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id - nexec vzctl exec $node_id sysctl -w net/ipv4/ip_forward=1 - nexec vzctl exec $node_id sysctl -w net/ipv6/conf/all/forwarding=1 - - puts " $eid $node ima aktivan IPv4 & IPv6 forwarding" +# FreeBSD-specific: +# # XXX race if starting two imunes instances simultaneously +# nexec rm -fr /var/run/quagga +# nexec rm -f /usr/local/etc/quagga/Quagga.conf +# nexec ln -s /tmp/$eid/@ /var/run/quagga +# nexec ln -s /tmp/$eid/@/boot.conf /usr/local/etc/quagga/Quagga.conf +# foreach file { bgpd ospfd ospf6d ripd ripngd vtysh zebra } { +# nexec cp /dev/null /usr/local/etc/quagga/$file.conf +# } + + upvar 0 ::cf::[set ::curcfg]::[set node]::ve_dir ve_dir + nexec ln -s /boot.conf $ve_dir/etc/quagga/Quagga.conf + foreach file { bgpd ospfd ospf6d ripd ripngd vtysh zebra } { + puts "maybe nexec cp /dev/null $ve_dir/etc/quagga/$file.conf" + } } @@ -201,14 +211,30 @@ proc $MODULE.instantiate { eid node } { # router.quagga.start $eid $node_id # FUNCTION # Starts a new router.quagga. The node can be started if it is instantiated. -# Simulates the booting proces of a router.quagga, by calling l3node.start -# procedure. +# A custom prerequisite (kernel capabilities setup) is run first. +# The booting process of a router.quagga is started by calling +# the l3node.start procedure. +# Afterwards it enables the kernel tunables for IP forwarding. # INPUTS # * eid - experiment id # * node_id - id of the node (type of the node is router.quagga) #**** proc $MODULE.start { eid node } { + +# OpenVZ catch: prije startanja bootcmda moramo upaliti capabilities + upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id + foreach capability { net_admin net_raw sys_admin } { + nexec vzctl set $node_id --capability $capability:on --save + } + l3node.start $eid $node + + upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id + nexec vzctl exec $node_id sysctl -w net/ipv4/ip_forward=1 + nexec vzctl exec $node_id sysctl -w net/ipv6/conf/all/forwarding=1 + + puts " $eid $node ima aktivan IPv4 & IPv6 forwarding" + }