From e282b6e29f0ea13754a85ae67f44e1620ee06374 Mon Sep 17 00:00:00 2001 From: Brandon Heller <brandonh@stanford.edu> Date: Fri, 6 Aug 2010 10:34:17 -0700 Subject: [PATCH] Fix --mac breakage The OVS interface for this moved to ovs-openflowd. This functionality was never there for the user-space switch. Now it's in. --- mininet/node.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mininet/node.py b/mininet/node.py index 7609318c..05f1921e 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -433,11 +433,15 @@ def start( self, controllers ): ofdlog = '/tmp/' + self.name + '-ofd.log' ofplog = '/tmp/' + self.name + '-ofp.log' self.cmd( 'ifconfig lo up' ) + mac_str = '' + if self.defaultMAC: + # ofdatapath expects a string of hex digits with no colons. + mac_str = ' -d ' + ''.join( self.defaultMAC.split( ':' ) ) intfs = sorted( self.intfs.values() ) if self.inNamespace: intfs = intfs[ :-1 ] self.cmd( 'ofdatapath -i ' + ','.join( intfs ) + - ' punix:/tmp/' + self.name + + ' punix:/tmp/' + self.name + mac_str + ' 1> ' + ofdlog + ' 2> ' + ofdlog + ' &' ) self.cmd( 'ofprotocol unix:/tmp/' + self.name + ' tcp:%s:%d' % ( controller.IP(), controller.port ) + @@ -533,9 +537,12 @@ def start( self, controllers ): # then create a new one monitoring the given interfaces quietRun( 'ovs-dpctl del-dp ' + self.dp ) self.cmd( 'ovs-dpctl add-dp ' + self.dp ) + mac_str = '' if self.defaultMAC: - mac = self.defaultMAC - self.cmd( 'ifconfig', self.intf, 'hw', 'ether', mac ) + # ovs-openflowd expects a string of exactly 16 hex digits with no + # colons. + mac_str = ' --datapath-id=0000' + \ + ''.join( self.defaultMAC.split( ':' ) ) + ' ' ports = sorted( self.ports.values() ) if len( ports ) != ports[ -1 ] + 1: raise Exception( 'only contiguous, zero-indexed port ranges' @@ -546,7 +553,7 @@ def start( self, controllers ): controller = controllers[ 0 ] self.cmd( 'ovs-openflowd ' + self.dp + ' tcp:%s:%d' % ( controller.IP(), controller.port ) + - ' --fail=closed ' + self.opts + + ' --fail=closed ' + self.opts + mac_str + ' 1>' + ofplog + ' 2>' + ofplog + '&' ) self.execed = False -- GitLab