Skip to content

Commit

Permalink
Support out-of-order link addition
Browse files Browse the repository at this point in the history
Sort interface names before passing to dpctl for kernel switch, so that
links for multipath topologies can be added in any order.
  • Loading branch information
Brandon Heller committed Jan 7, 2010
1 parent 6d2cd77 commit d856c81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions mininet/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def _add_link(self, src, dst):
make_veth_pair(src_intf, dst_intf)
src_node.intfs.append(src_intf)
dst_node.intfs.append(dst_intf)
src_node.ports[src_port] = src_intf
dst_node.ports[dst_port] = dst_intf
#lg.info('\n')
#lg.info('added intf %s to src node %x\n' % (src_intf, src))
#lg.info('added intf %s to dst node %x\n' % (dst_intf, dst))
Expand Down
10 changes: 8 additions & 2 deletions mininet/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def __init__(self, name, inNamespace = True):
self.connection = {}
self.waiting = False
self.execed = False
self.ports = {} # dict of ints to interface strings
# replace with Port object, eventually

def fdToNode(self, f):
'''Insert docstring.
Expand Down Expand Up @@ -316,8 +318,12 @@ def start(self, controllers):
intf = 'of%i' % self.dp
mac_str = macColonHex(self.dpid)
self.cmd(['ifconfig', intf, 'hw', 'ether', mac_str])
self.cmdPrint('dpctl addif nl:' + str(self.dp) + ' ' +
' '.join(self.intfs))

if len(self.ports) != max(self.ports.keys()) + 1:
raise Exception('only contiguous, zero-indexed port ranges'
'supported: %s' % self.ports)
intfs = [self.ports[port] for port in self.ports.keys()]
self.cmdPrint('dpctl addif nl:' + str(self.dp) + ' ' + ' '.join(intfs))
# Run protocol daemon
self.cmdPrint('ofprotocol nl:' + str(self.dp) + ' tcp:' +
controllers['c0'].IP() + ':' +
Expand Down

0 comments on commit d856c81

Please sign in to comment.