Restore user-space switch option
Switches and controller in root namespace only, for now.
This commit is contained in:
+7
-2
@@ -16,7 +16,7 @@ except ImportError:
|
|||||||
from mininet.logging_mod import lg, set_loglevel, LEVELS
|
from mininet.logging_mod import lg, set_loglevel, LEVELS
|
||||||
from mininet.net import Mininet, init
|
from mininet.net import Mininet, init
|
||||||
from mininet.node import KernelSwitch, Host, Controller, ControllerParams, NOX
|
from mininet.node import KernelSwitch, Host, Controller, ControllerParams, NOX
|
||||||
from mininet.node import RemoteController
|
from mininet.node import RemoteController, UserSwitch
|
||||||
from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
|
from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
|
||||||
|
|
||||||
# built in topologies, created only when run
|
# built in topologies, created only when run
|
||||||
@@ -38,7 +38,8 @@ if USE_RIPCORD:
|
|||||||
TOPOS.update(TOPOS_RIPCORD)
|
TOPOS.update(TOPOS_RIPCORD)
|
||||||
|
|
||||||
SWITCH_DEF = 'kernel'
|
SWITCH_DEF = 'kernel'
|
||||||
SWITCHES = {'kernel' : KernelSwitch}
|
SWITCHES = {'kernel' : KernelSwitch,
|
||||||
|
'user' : UserSwitch}
|
||||||
|
|
||||||
HOST_DEF = 'process'
|
HOST_DEF = 'process'
|
||||||
HOSTS = {'process' : Host}
|
HOSTS = {'process' : Host}
|
||||||
@@ -115,6 +116,8 @@ class MininetRunner(object):
|
|||||||
opts.add_option('--port', type = 'string', default = 6633,
|
opts.add_option('--port', type = 'string', default = 6633,
|
||||||
help = '[port integer for a listening remote'
|
help = '[port integer for a listening remote'
|
||||||
' controller]')
|
' controller]')
|
||||||
|
opts.add_option('--in_namespace', action = 'store_true',
|
||||||
|
default = False, help = 'sw and ctrl in namespace?')
|
||||||
self.options = opts.parse_args()[0]
|
self.options = opts.parse_args()[0]
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
@@ -147,10 +150,12 @@ class MininetRunner(object):
|
|||||||
port = self.options.port)
|
port = self.options.port)
|
||||||
|
|
||||||
controller_params = ControllerParams(0x0a000000, 8) # 10.0.0.0/8
|
controller_params = ControllerParams(0x0a000000, 8) # 10.0.0.0/8
|
||||||
|
in_namespace = self.options.in_namespace
|
||||||
xterms = self.options.xterms
|
xterms = self.options.xterms
|
||||||
mac = self.options.mac
|
mac = self.options.mac
|
||||||
arp = self.options.arp
|
arp = self.options.arp
|
||||||
mn = Mininet(topo, switch, host, controller, controller_params,
|
mn = Mininet(topo, switch, host, controller, controller_params,
|
||||||
|
in_namespace = in_namespace,
|
||||||
xterms = xterms, auto_set_macs = mac,
|
xterms = xterms, auto_set_macs = mac,
|
||||||
auto_static_arp = arp)
|
auto_static_arp = arp)
|
||||||
|
|
||||||
|
|||||||
+4
-11
@@ -92,7 +92,7 @@ class Mininet(object):
|
|||||||
@param now build now?
|
@param now build now?
|
||||||
@param xterms if build now, spawn xterms?
|
@param xterms if build now, spawn xterms?
|
||||||
@param cleanup if build now, cleanup before creating?
|
@param cleanup if build now, cleanup before creating?
|
||||||
@param in_namespace spawn switches and hosts in their own namespace?
|
@param in_namespace spawn switches and controller in net namespaces?
|
||||||
@param auto_set_macs set MAC addrs to DPIDs?
|
@param auto_set_macs set MAC addrs to DPIDs?
|
||||||
@param auto_static_arp set all-pairs static MAC addrs?
|
@param auto_static_arp set all-pairs static MAC addrs?
|
||||||
'''
|
'''
|
||||||
@@ -112,8 +112,6 @@ class Mininet(object):
|
|||||||
|
|
||||||
self.terms = [] # list of spawned xterm processes
|
self.terms = [] # list of spawned xterm processes
|
||||||
|
|
||||||
self.kernel = True #temporary!
|
|
||||||
|
|
||||||
if build:
|
if build:
|
||||||
self.build()
|
self.build()
|
||||||
|
|
||||||
@@ -178,7 +176,7 @@ class Mininet(object):
|
|||||||
|
|
||||||
@param controller Controller class
|
@param controller Controller class
|
||||||
'''
|
'''
|
||||||
controller = self.controller('c0', not self.kernel)
|
controller = self.controller('c0', self.in_namespace)
|
||||||
if controller: # allow controller-less setups
|
if controller: # allow controller-less setups
|
||||||
self.controllers['c0'] = controller
|
self.controllers['c0'] = controller
|
||||||
|
|
||||||
@@ -271,11 +269,6 @@ class Mininet(object):
|
|||||||
if self.cleanup:
|
if self.cleanup:
|
||||||
pass # cleanup
|
pass # cleanup
|
||||||
# validate topo?
|
# validate topo?
|
||||||
kernel = self.kernel
|
|
||||||
if kernel:
|
|
||||||
lg.info('*** Using kernel datapath\n')
|
|
||||||
else:
|
|
||||||
lg.info('*** Using user datapath\n')
|
|
||||||
lg.info('*** Adding controller\n')
|
lg.info('*** Adding controller\n')
|
||||||
self._add_controller(self.controller)
|
self._add_controller(self.controller)
|
||||||
lg.info('*** Creating network\n')
|
lg.info('*** Creating network\n')
|
||||||
@@ -287,13 +280,13 @@ class Mininet(object):
|
|||||||
for switch in sorted(self.topo.switches()):
|
for switch in sorted(self.topo.switches()):
|
||||||
self._add_switch(switch)
|
self._add_switch(switch)
|
||||||
lg.info('0x%x ' % switch)
|
lg.info('0x%x ' % switch)
|
||||||
lg.info('\n*** Adding edges: ')
|
lg.info('\n*** Adding edges:\n')
|
||||||
for src, dst in sorted(self.topo.edges()):
|
for src, dst in sorted(self.topo.edges()):
|
||||||
self._add_link(src, dst)
|
self._add_link(src, dst)
|
||||||
lg.info('(0x%x, 0x%x) ' % (src, dst))
|
lg.info('(0x%x, 0x%x) ' % (src, dst))
|
||||||
lg.info('\n')
|
lg.info('\n')
|
||||||
|
|
||||||
if not kernel:
|
if self.in_namespace:
|
||||||
lg.info('*** Configuring control network\n')
|
lg.info('*** Configuring control network\n')
|
||||||
self._configureControlNetwork()
|
self._configureControlNetwork()
|
||||||
|
|
||||||
|
|||||||
+11
-7
@@ -259,13 +259,17 @@ class Switch(Node):
|
|||||||
return True, ''
|
return True, ''
|
||||||
|
|
||||||
class UserSwitch(Switch):
|
class UserSwitch(Switch):
|
||||||
|
'''User-space switch.
|
||||||
|
|
||||||
|
Currently only works in the root namespace.
|
||||||
|
'''
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
'''Init.
|
'''Init.
|
||||||
|
|
||||||
@param name
|
@param name
|
||||||
'''
|
'''
|
||||||
Node.__init__(self, name, inNamespace = True)
|
Node.__init__(self, name, inNamespace = False)
|
||||||
|
|
||||||
def start(self, controllers):
|
def start(self, controllers):
|
||||||
'''Start OpenFlow reference user datapath.
|
'''Start OpenFlow reference user datapath.
|
||||||
@@ -274,17 +278,17 @@ class UserSwitch(Switch):
|
|||||||
|
|
||||||
@param controllers dict of controller names to objects
|
@param controllers dict of controller names to objects
|
||||||
'''
|
'''
|
||||||
if 'c0' not in controller:
|
if 'c0' not in controllers:
|
||||||
raise Exception('User datapath start() requires controller c0')
|
raise Exception('User datapath start() requires controller c0')
|
||||||
controller = controllers['c0']
|
controller = controllers['c0']
|
||||||
ofdlog = '/tmp/' + self.name + '-ofd.log'
|
ofdlog = '/tmp/' + self.name + '-ofd.log'
|
||||||
ofplog = '/tmp/' + self.name + '-ofp.log'
|
ofplog = '/tmp/' + self.name + '-ofp.log'
|
||||||
self.cmd('ifconfig lo up')
|
self.cmd('ifconfig lo up')
|
||||||
intfs = self.intfs[1:] # 0 is mgmt interface
|
intfs = self.intfs
|
||||||
self.cmdPrint('ofdatapath -i ' + ','.join(intfs) +
|
self.cmdPrint('ofdatapath -i ' + ','.join(intfs) + ' punix:/tmp/' +
|
||||||
' ptcp: 1> ' + ofdlog + ' 2> ' + ofdlog + ' &')
|
self.name + ' 1> ' + ofdlog + ' 2> ' + ofdlog + ' &')
|
||||||
self.cmdPrint('ofprotocol tcp:' + controller.IP() +
|
self.cmdPrint('ofprotocol unix:/tmp/' + self.name + ' tcp:' +
|
||||||
' tcp:localhost --fail=closed 1> ' + ofplog + ' 2>' +
|
controller.IP() + ' --fail=closed 1> ' + ofplog + ' 2>' +
|
||||||
ofplog + ' &')
|
ofplog + ' &')
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user