summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorShinpei Muraoka <shinpei.muraoka@gmail.com>2016-09-27 12:01:05 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-10-01 20:46:29 +0900
commit25a7eb51fe534ced19d9d0d76f4d8ea13418c305 (patch)
tree72c0b16f2a6886c0cf6fc6d2603ecf03ee584f72
parentd23c07054e6f33b392f49f6fceacbdb891be3d87 (diff)
stplib: Fix to store current OFPPort status
Currently, stplib compares the status of OFPPortStatus message with that of Datapath instance, but this comparison returns always "equal", so stplib fails to get the correct port status. This patch fixes to store the current port status and to compare the new status with the stored status. Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/stplib.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/ryu/lib/stplib.py b/ryu/lib/stplib.py
index ff28d9ec..97752f10 100644
--- a/ryu/lib/stplib.py
+++ b/ryu/lib/stplib.py
@@ -295,10 +295,10 @@ class Stp(app_manager.RyuApp):
elif reason is dp.ofproto.OFPPR_DELETE:
self.logger.info('[port=%d] Port delete.',
port.port_no, extra=dpid_str)
- bridge.port_delete(port.port_no)
+ bridge.port_delete(port)
else:
assert reason is dp.ofproto.OFPPR_MODIFY
- if bridge.dp.ports[port.port_no].state == port.state:
+ if bridge.ports_state[port.port_no] == port.state:
# Do nothing
self.logger.debug('[port=%d] Link status not changed.',
port.port_no, extra=dpid_str)
@@ -306,11 +306,11 @@ class Stp(app_manager.RyuApp):
if link_down_flg:
self.logger.info('[port=%d] Link down.',
port.port_no, extra=dpid_str)
- bridge.link_down(port.port_no)
+ bridge.link_down(port)
else:
self.logger.info('[port=%d] Link up.',
port.port_no, extra=dpid_str)
- bridge.link_up(port.port_no)
+ bridge.link_up(port)
@staticmethod
def compare_root_path(path_cost1, path_cost2, bridge_id1, bridge_id2,
@@ -415,6 +415,7 @@ class Bridge(object):
self.root_times = self.bridge_times
# Ports
self.ports = {}
+ self.ports_state = {}
self.ports_conf = config.get('ports', {})
for ofport in dp.ports.values():
self.port_add(ofport)
@@ -442,23 +443,27 @@ class Bridge(object):
self.bridge_id,
self.bridge_times,
ofport)
+ self.ports_state[ofport.port_no] = ofport.state
- def port_delete(self, port_no):
- self.link_down(port_no)
- self.ports[port_no].delete()
- del self.ports[port_no]
+ def port_delete(self, ofp_port):
+ self.link_down(ofp_port)
+ self.ports[ofp_port.port_no].delete()
+ del self.ports[ofp_port.port_no]
+ del self.ports_state[ofp_port.port_no]
- def link_up(self, port_no):
- port = self.ports[port_no]
+ def link_up(self, ofp_port):
+ port = self.ports[ofp_port.port_no]
port.up(DESIGNATED_PORT, self.root_priority, self.root_times)
+ self.ports_state[ofp_port.port_no] = ofp_port.state
- def link_down(self, port_no):
+ def link_down(self, ofp_port):
""" DESIGNATED_PORT/NON_DESIGNATED_PORT: change status to DISABLE.
ROOT_PORT: change status to DISABLE and recalculate STP. """
- port = self.ports[port_no]
+ port = self.ports[ofp_port.port_no]
init_stp_flg = bool(port.role is ROOT_PORT)
port.down(PORT_STATE_DISABLE, msg_init=True)
+ self.ports_state[ofp_port.port_no] = ofp_port.state
if init_stp_flg:
self.recalculate_spanning_tree()