From a0bc10028976611dc9aa8e1df757a6ebb96103bd Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Wed, 26 Feb 2014 06:13:18 -0800 Subject: [PATCH 1/3] Enable batch shutdown for OVS. --- mininet/net.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mininet/net.py b/mininet/net.py index 2b3ce04..08dc61f 100755 --- a/mininet/net.py +++ b/mininet/net.py @@ -408,9 +408,10 @@ class Mininet( object ): info( '*** Stopping %i terms\n' % len( self.terms ) ) self.stopXterms() info( '*** Stopping %i switches\n' % len( self.switches ) ) - swclass = type( self.switches[ 0 ] ) - if False and self.switches and hasattr( swclass, 'batchShutdown' ): - swclass.batchShutdown( self.switches ) + if self.switches: + swclass = type( self.switches[ 0 ] ) + if hasattr( swclass, 'batchShutdown' ): + swclass.batchShutdown( self.switches ) for switch in self.switches: info( switch.name + ' ' ) switch.stop() From 2e19ceb0aacd4afa5e547a1f6251c019ce6ad8c1 Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Wed, 26 Feb 2014 06:13:53 -0800 Subject: [PATCH 2/3] Use a single ovs-vsctl command for speed/atomicity --- mininet/node.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/mininet/node.py b/mininet/node.py index 51f01c1..ec9e7b7 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -1044,33 +1044,38 @@ class OVSSwitch( Switch ): self.cmd( 'ifconfig lo up' ) # Annoyingly, --if-exists option seems not to work self.cmd( 'ovs-vsctl del-br', self ) - self.cmd( 'ovs-vsctl add-br', self ) - if self.datapath == 'user': - self.cmd( 'ovs-vsctl set bridge', self,'datapath_type=netdev' ) int( self.dpid, 16 ) # DPID must be a hex string - self.cmd( 'ovs-vsctl -- set Bridge', self, - 'other_config:datapath-id=' + self.dpid ) - self.cmd( 'ovs-vsctl set-fail-mode', self, self.failMode ) - for intf in self.intfList(): - if not intf.IP(): - self.attach( intf ) - # Add controllers - clist = ' '.join( [ 'tcp:%s:%d' % ( c.IP(), c.port ) - for c in controllers ] ) + # Interfaces and controllers + intfs = ' '.join( '-- add-port %s %s ' % ( self, intf ) + for intf in self.intfList() if not intf.IP() ) + clist = ' '.join( 'tcp:%s:%d' % ( c.IP(), c.port ) + for c in controllers ) if self.listenPort: clist += ' ptcp:%s' % self.listenPort + # Construct big ovs-vsctl command + cmd = ( 'ovs-vsctl add-br %s ' % self + + '-- set Bridge %s ' % self + + 'other_config:datapath-id=%s ' % self.dpid + + '-- set-fail-mode %s %s ' % ( self, self.failMode ) + + intfs + + '-- set-controller %s %s ' % (self, clist ) ) if not self.inband: - self.cmd( 'ovs-vsctl set bridge', self, - 'other-config:disable-in-band=true' ) - self.cmd( 'ovs-vsctl set-controller', self, clist ) + cmd += ( '-- set bridge %s ' + 'other-config:disable-in-band=true ' % self ) + if self.datapath == 'user': + cmd += '-- set bridge %s datapath_type=netdev ' % self # Reconnect quickly to controllers (1s vs. 15s max_backoff) for uuid in self.controllerUUIDs(): if uuid.count( '-' ) != 4: # Doesn't look like a UUID continue uuid = uuid.strip() - self.cmd( 'ovs-vsctl set Controller', uuid, - 'max_backoff=1000' ) + cmd += '-- set Controller %smax_backoff=1000 ' % uuid + # Do it!! + self.cmd( cmd ) + for intf in self.intfList(): + self.TCReapply( intf ) + def stop( self ): "Terminate OVS switch." From d82900d3a81c313315c26af9f6d5095bc850ef1e Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Thu, 6 Mar 2014 17:52:41 -0800 Subject: [PATCH 3/3] Don't look through all interfaces if you don't need to. --- mininet/util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mininet/util.py b/mininet/util.py index 9948000..b03e945 100644 --- a/mininet/util.py +++ b/mininet/util.py @@ -188,8 +188,7 @@ def moveIntfNoRetry( intf, dstNode, srcNode=None, printError=False ): srcNode.cmd( cmd ) else: quietRun( cmd ) - links = dstNode.cmd( 'ip link show' ) - if not ( ' %s:' % intf ) in links: + if ( ' %s:' % intf ) not in dstNode.cmd( 'ip link show', intf ): if printError: error( '*** Error: moveIntf: ' + intf + ' not successfully moved to ' + dstNode.name + '\n' )