From f939eb5625f686baa041d6c197c536339e3277eb Mon Sep 17 00:00:00 2001
From: Bob Lantz <rlantz@cs.stanford.edu>
Date: Tue, 15 Dec 2009 22:38:17 -0800
Subject: [PATCH] Changes to mininet.py: - invoke ofdatapath with --fail=closed
 (no controller = no connectivity!) - stop hosts before switches before the
 controller 	- this seems slightly more sensible 	- it's the reverse of
 the startup order - fix retry() so it kind of works (it's actually helpful I
 think!)

---
 mininet.py | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/mininet.py b/mininet.py
index 60780bd0..f2cd1a69 100755
--- a/mininet.py
+++ b/mininet.py
@@ -277,7 +277,7 @@ def startUserDatapath( self, controller ):
       self.cmdPrint( 'ofdatapath -i ' + ','.join( intfs ) +
        ' ptcp: 1> ' + ofdlog + ' 2> '+ ofdlog + ' &' )
       self.cmdPrint( 'ofprotocol tcp:' + controller.IP() +
-         ' tcp:localhost 1> ' + ofplog + ' 2>' + ofplog + ' &' )
+         ' tcp:localhost --fail=closed 1> ' + ofplog + ' 2>' + ofplog + ' &' )
    def stopUserDatapath( self ):
       "Stop OpenFlow reference user datapath."
       self.cmd( "kill %ofdatapath" )
@@ -291,9 +291,10 @@ def startKernelDatapath( self, controller):
       quietRun( 'dpctl deldp ' + self.dp )
       self.cmdPrint( 'dpctl adddp ' + self.dp )
       self.cmdPrint( 'dpctl addif ' + self.dp + ' ' + ' '.join( self.intfs ) )
-      # Become protocol daemon
+      # Run protocol daemon
       self.cmdPrint( 'ofprotocol' +
-         ' ' + self.dp + ' tcp:127.0.0.1 1> ' + ofplog + ' 2>' + ofplog + ' &' )
+         ' ' + self.dp + ' tcp:127.0.0.1 ' + 
+         ' --fail=closed 1> ' + ofplog + ' 2>' + ofplog + ' &' )
       self.execed = False # XXX until I fix it
    def stopKernelDatapath( self ):
       "Terminate a switch using OpenFlow reference kernel datapath."
@@ -361,7 +362,9 @@ def retry( n, fn, *args):
       sleep( 1 )
       print "*** retrying..."; flush()
       tries += 1
-   if tries >= n: exit( 1 )
+   if tries >= n: 
+      print "*** giving up"
+      exit( 1 )
    
 def createLink( node1, node2 ):
    "Create a link node1-intf1 <---> node2-intf2."
@@ -526,17 +529,18 @@ def start( self ):
          switch.start( self.controllers[ 0 ] )
    def stop( self ):
       "Stop the controller(s), switches and hosts"
-      print "*** Stopping controller"
-      for controller in self.controllers:
-         controller.stop(); controller.terminate()
+      print "*** Stopping hosts"
+      for host in self.hosts: 
+         host.terminate()
       print "*** Stopping switches"
       for switch in self.switches:
          print switch.name, ; flush()
          switch.stop() ; switch.terminate()
       print
-      print "*** Stopping hosts"
-      for host in self.hosts: 
-         host.terminate()
+      print "*** Stopping controller"
+      for controller in self.controllers:
+         controller.stop(); controller.terminate()
+      print
       print "*** Test complete"
    def runTest( self, test ):
       "Run a given test, called as test( controllers, switches, hosts)"
-- 
GitLab