Revision c916f3ee
bin/mn | ||
---|---|---|
30 | 30 |
UserSwitch, OVSSwitch, OVSBridge, |
31 | 31 |
OVSLegacyKernelSwitch, IVSSwitch ) |
32 | 32 |
from mininet.nodelib import LinuxBridge |
33 |
from mininet.link import Link, TCLink |
|
33 |
from mininet.link import Link, TCLink, OVSLink
|
|
34 | 34 |
from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo |
35 | 35 |
from mininet.topolib import TreeTopo, TorusTopo |
36 | 36 |
from mininet.util import customConstructor, splitArgs |
... | ... | |
82 | 82 |
|
83 | 83 |
LINKDEF = 'default' |
84 | 84 |
LINKS = { 'default': Link, |
85 |
'tc': TCLink } |
|
85 |
'tc': TCLink, |
|
86 |
'ovs': OVSLink } |
|
86 | 87 |
|
87 | 88 |
|
88 | 89 |
# optional tests to run |
mininet/link.py | ||
---|---|---|
26 | 26 |
|
27 | 27 |
from mininet.log import info, error, debug |
28 | 28 |
from mininet.util import makeIntfPair, quietRun |
29 |
import mininet.node |
|
29 | 30 |
import re |
30 | 31 |
|
31 | 32 |
class Intf( object ): |
... | ... | |
453 | 454 |
def __str__( self ): |
454 | 455 |
return '%s<->%s' % ( self.intf1, self.intf2 ) |
455 | 456 |
|
457 |
|
|
458 |
class OVSIntf( Intf ): |
|
459 |
"Patch interface on an OVSSwitch" |
|
460 |
|
|
461 |
def ifconfig( self, cmd ): |
|
462 |
if cmd == 'up': |
|
463 |
"OVSIntf is always up" |
|
464 |
return |
|
465 |
else: |
|
466 |
raise Exception( 'OVSIntf cannot do ifconfig ' + cmd ) |
|
467 |
|
|
468 |
|
|
469 |
class OVSLink( Link ): |
|
470 |
"Link that makes patch links between OVSSwitches" |
|
471 |
|
|
472 |
def __init__( self, node1, node2, **kwargs ): |
|
473 |
"See Link.__init__() for options" |
|
474 |
self.isPatchLink = False |
|
475 |
if ( type( node1 ) is mininet.node.OVSSwitch and |
|
476 |
type( node2 ) is mininet.node.OVSSwitch ): |
|
477 |
self.isPatchLink = True |
|
478 |
kwargs.update( cls1=OVSIntf, cls2=OVSIntf ) |
|
479 |
Link.__init__( self, node1, node2, **kwargs ) |
|
480 |
|
|
481 |
def makeIntfPair( self, *args, **kwargs ): |
|
482 |
"Usually delegated to OVSSwitch" |
|
483 |
if self.isPatchLink: |
|
484 |
return None, None |
|
485 |
else: |
|
486 |
return Link.makeIntfPair( *args, **kwargs ) |
|
487 |
|
|
488 |
|
|
456 | 489 |
class TCLink( Link ): |
457 | 490 |
"Link with symmetric TC interfaces configured via opts" |
458 | 491 |
def __init__( self, node1, node2, port1=None, port2=None, |
mininet/node.py | ||
---|---|---|
58 | 58 |
from mininet.util import ( quietRun, errRun, errFail, moveIntf, isShellBuiltin, |
59 | 59 |
numCores, retry, mountCgroups ) |
60 | 60 |
from mininet.moduledeps import moduleDeps, pathCheck, OVS_KMOD, OF_KMOD, TUN |
61 |
from mininet.link import Link, Intf, TCIntf |
|
61 |
from mininet.link import Link, Intf, TCIntf, OVSIntf
|
|
62 | 62 |
from re import findall |
63 | 63 |
from distutils.version import StrictVersion |
64 | 64 |
|
... | ... | |
1145 | 1145 |
return True |
1146 | 1146 |
return self.failMode == 'standalone' |
1147 | 1147 |
|
1148 |
@staticmethod |
|
1149 |
def patchOpts( intf ): |
|
1150 |
"Return OVS patch port options (if any) for intf" |
|
1151 |
if type( intf ) is not OVSIntf: |
|
1152 |
# Ignore if it's not a patch link |
|
1153 |
return '' |
|
1154 |
intf1, intf2 = intf.link.intf1, intf.link.intf2 |
|
1155 |
peer = intf1 if intf1 != intf else intf2 |
|
1156 |
return ( '-- set Interface %s type=patch ' |
|
1157 |
'-- set Interface %s options:peer=%s ' % |
|
1158 |
( intf, intf, peer ) ) |
|
1159 |
|
|
1148 | 1160 |
def start( self, controllers ): |
1149 | 1161 |
"Start up a new OVS OpenFlow switch using ovs-vsctl" |
1150 | 1162 |
if self.inNamespace: |
... | ... | |
1157 | 1169 |
intfs = ' '.join( '-- add-port %s %s ' % ( self, intf ) + |
1158 | 1170 |
'-- set Interface %s ' % intf + |
1159 | 1171 |
'ofport_request=%s ' % self.ports[ intf ] |
1172 |
+ self.patchOpts( intf ) |
|
1160 | 1173 |
for intf in self.intfList() |
1161 | 1174 |
if self.ports[ intf ] and not intf.IP() ) |
1162 | 1175 |
clist = ' '.join( '%s:%s:%d' % ( c.protocol, c.IP(), c.port ) |
Also available in: Unified diff