Compare commits

...

2 Commits

Author SHA1 Message Date
Bob Lantz c5f68226b8 use isinstance( intf, OVSIntf ) 2015-01-07 00:18:42 -08:00
Bob Lantz c916f3ee1b Add OVSLink/--link ovs, which uses OVS patch links when possible 2015-01-07 00:18:42 -08:00
3 changed files with 50 additions and 3 deletions
+3 -2
View File
@@ -30,7 +30,7 @@ from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
UserSwitch, OVSSwitch, OVSBridge,
OVSLegacyKernelSwitch, IVSSwitch )
from mininet.nodelib import LinuxBridge
from mininet.link import Link, TCLink
from mininet.link import Link, TCLink, OVSLink
from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
from mininet.topolib import TreeTopo, TorusTopo
from mininet.util import customConstructor, splitArgs
@@ -82,7 +82,8 @@ CONTROLLERS = { 'ref': Controller,
LINKDEF = 'default'
LINKS = { 'default': Link,
'tc': TCLink }
'tc': TCLink,
'ovs': OVSLink }
# optional tests to run
+33
View File
@@ -26,6 +26,7 @@ Link: basic link class for creating veth pairs
from mininet.log import info, error, debug
from mininet.util import makeIntfPair, quietRun
import mininet.node
import re
class Intf( object ):
@@ -453,6 +454,38 @@ class Link( object ):
def __str__( self ):
return '%s<->%s' % ( self.intf1, self.intf2 )
class OVSIntf( Intf ):
"Patch interface on an OVSSwitch"
def ifconfig( self, cmd ):
if cmd == 'up':
"OVSIntf is always up"
return
else:
raise Exception( 'OVSIntf cannot do ifconfig ' + cmd )
class OVSLink( Link ):
"Link that makes patch links between OVSSwitches"
def __init__( self, node1, node2, **kwargs ):
"See Link.__init__() for options"
self.isPatchLink = False
if ( type( node1 ) is mininet.node.OVSSwitch and
type( node2 ) is mininet.node.OVSSwitch ):
self.isPatchLink = True
kwargs.update( cls1=OVSIntf, cls2=OVSIntf )
Link.__init__( self, node1, node2, **kwargs )
def makeIntfPair( self, *args, **kwargs ):
"Usually delegated to OVSSwitch"
if self.isPatchLink:
return None, None
else:
return Link.makeIntfPair( *args, **kwargs )
class TCLink( Link ):
"Link with symmetric TC interfaces configured via opts"
def __init__( self, node1, node2, port1=None, port2=None,
+14 -1
View File
@@ -58,7 +58,7 @@ from mininet.log import info, error, warn, debug
from mininet.util import ( quietRun, errRun, errFail, moveIntf, isShellBuiltin,
numCores, retry, mountCgroups )
from mininet.moduledeps import moduleDeps, pathCheck, OVS_KMOD, OF_KMOD, TUN
from mininet.link import Link, Intf, TCIntf
from mininet.link import Link, Intf, TCIntf, OVSIntf
from re import findall
from distutils.version import StrictVersion
@@ -1145,6 +1145,18 @@ class OVSSwitch( Switch ):
return True
return self.failMode == 'standalone'
@staticmethod
def patchOpts( intf ):
"Return OVS patch port options (if any) for intf"
if not isinstance( intf, OVSIntf ):
# Ignore if it's not a patch link
return ''
intf1, intf2 = intf.link.intf1, intf.link.intf2
peer = intf1 if intf1 != intf else intf2
return ( '-- set Interface %s type=patch '
'-- set Interface %s options:peer=%s ' %
( intf, intf, peer ) )
def start( self, controllers ):
"Start up a new OVS OpenFlow switch using ovs-vsctl"
if self.inNamespace:
@@ -1157,6 +1169,7 @@ class OVSSwitch( Switch ):
intfs = ' '.join( '-- add-port %s %s ' % ( self, intf ) +
'-- set Interface %s ' % intf +
'ofport_request=%s ' % self.ports[ intf ]
+ self.patchOpts( intf )
for intf in self.intfList()
if self.ports[ intf ] and not intf.IP() )
clist = ' '.join( '%s:%s:%d' % ( c.protocol, c.IP(), c.port )