Skip to content

Commit

Permalink
datapaths: Fix port generation regression
Browse files Browse the repository at this point in the history
55a1301 made a number of improvements to port generation for the software
switch, but also totally broke it.  With any luck, this fixes things.

Thanks to Guangvy for the bug report.
  • Loading branch information
MurphyMc committed Oct 11, 2013
1 parent 6341378 commit 998ccbe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pox/datapaths/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ def __init__ (self, dpid, name=None, ports=4, miss_send_len=128,
if name is None: name = dpid_to_str(dpid)
self.name = name

self.dpid = dpid

if isinstance(ports, int):
ports = [self.generate_port(i, dpid) for i in range(1, ports+1)]
ports = [self.generate_port(i) for i in range(1, ports+1)]

self.dpid = dpid
self.max_buffers = max_buffers
self.max_entries = max_entries
self.miss_send_len = miss_send_len
Expand Down Expand Up @@ -177,7 +178,7 @@ def _gen_port_name (self, port_no):
return "%s.%s"%(dpid_to_str(self.dpid, True).replace('-','')[:12], port_no)

def _gen_ethaddr (self, port_no):
return EthAddr("02%06x%06x" % (self.dpid % 0x00FFff, port_no % 0xffFF))
return EthAddr("02%06x%04x" % (self.dpid % 0x00FFff, port_no % 0xffFF))

def generate_port (self, port_no, name = None, ethaddr = None):
dpid = self.dpid
Expand All @@ -186,8 +187,7 @@ def generate_port (self, port_no, name = None, ethaddr = None):
if ethaddr is None:
p.hw_addr = self._gen_ethaddr(p.port_no)
else:
p.hw_addr = EthAddr(eth)
p.hw_addr = EthAddr(eth)
p.hw_addr = EthAddr(ethaddr)
if name is None:
p.name = self._gen_port_name(p.port_no)
else:
Expand Down

0 comments on commit 998ccbe

Please sign in to comment.