diff options
author | Yi Tseng <a86487817@gmail.com> | 2016-06-03 16:07:28 +0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-06-05 15:24:42 +0900 |
commit | 865d6e52d7e925e31a761cd0a9017576104a6f9d (patch) | |
tree | f7dbef2c78bac10f4b1a731535d595397460c2f7 | |
parent | d090b291bee5a8e1883cb4a75b9045b2703cdba8 (diff) |
Fix RuntimeError of lldp_packet_in_handler
Items should not be removed during iteration
Error message
```
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/ryu/base/app_manager.py", line 290, in _event_loop
handler(ev)
File "/usr/local/lib/python3.4/dist-packages/ryu/topology/switches.py", line 821, in lldp_packet_in_handler
for host in self.hosts.values():
RuntimeError: dictionary changed size during iteration
```
Signed-off-by: Yi Tseng <a86487817@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/topology/switches.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ryu/topology/switches.py b/ryu/topology/switches.py index 971d30bf..e1081ae0 100644 --- a/ryu/topology/switches.py +++ b/ryu/topology/switches.py @@ -817,10 +817,14 @@ class Switches(app_manager.RyuApp): if link not in self.links: self.send_event_to_observers(event.EventLinkAdd(link)) - # remove hosts from edge port + # remove hosts if it's not attached to edge port + host_to_del = [] for host in self.hosts.values(): if not self._is_edge_port(host.port): - del self.hosts[host.mac] + host_to_del.append(host.mac) + + for host_mac in host_to_del: + del self.hosts[host_mac] if not self.links.update_link(src, dst): # reverse link is not detected yet. |