From 1417fe72831b371ab30910c1ce5ba9bba38dd00d Mon Sep 17 00:00:00 2001
From: Bob Lantz <rlantz@cs.stanford.edu>
Date: Thu, 17 Dec 2009 16:29:55 -0800
Subject: [PATCH] Changed cleanup to do fast things first.

---
 cleanup | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/cleanup b/cleanup
index 87bf5576..25605b79 100755
--- a/cleanup
+++ b/cleanup
@@ -28,29 +28,33 @@ def cleanUpScreens():
          quietRun( 'screen -S ' + m.group( 1 ) + ' -X kill' )
  
 def cleanup():
-   print "*** Removing all links of the pattern foo-ethX"
-   links = sh( "ip link show | egrep -o '(\w+-eth\w+)'" ).split( '\n' )
-   for link in links: 
-      if link != '': sh( "ip link del " + link )
-
+   """Clean up junk which might be left over from old runs;
+      do fast stuff before slow dp and link removal!"""
+      
    print "*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes"
-   zombies = 'controller ofprotocol ofdatapath ping nox_core lt-nox_core'
+   zombies = 'controller ofprotocol ofdatapath ping nox_core lt-nox_core '
+   zombies += 'udpbwtest'
    # Note: real zombie processes can't actually be killed, since they 
    # are already (un)dead. Then again,
    # you can't connect to them either, so they're mostly harmless.
    sh( 'killall -9 ' + zombies + ' 2> /dev/null' )
 
-   print "*** Removing excess kernel datapaths"
-   dps = sh( "ps ax | egrep -o 'dp[0-9]+' | sed 's/dp/nl:/'" ).split( '\n')
-   for dp in dps: 
-      if dp != '': sh( 'dpctl deldp ' + dp )
-
    print "*** Removing junk from /tmp"
    sh( 'rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log' )
 
    print "*** Removing old screen sessions"
    cleanUpScreens()
 
+   print "*** Removing excess kernel datapaths"
+   dps = sh( "ps ax | egrep -o 'dp[0-9]+' | sed 's/dp/nl:/'" ).split( '\n')
+   for dp in dps: 
+      if dp != '': sh( 'dpctl deldp ' + dp )
+      
+   print "*** Removing all links of the pattern foo-ethX"
+   links = sh( "ip link show | egrep -o '(\w+-eth\w+)'" ).split( '\n' )
+   for link in links: 
+      if link != '': sh( "ip link del " + link )
+
    print "*** Cleanup complete."
 
 if __name__ == "__main__":
-- 
GitLab