diff options
author | Wei-Li Tang <alextwl@xinguard.com> | 2014-03-22 21:26:45 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-03-22 21:26:45 +0900 |
commit | b2ce73e16b8e26403e773fa555005d52d6ffb48e (patch) | |
tree | 1da966151fa10242c0ac63289d79cb0759d6677a | |
parent | b4e79003604491f74795c7ec4e1ad6bde9c2e385 (diff) |
topology/switches: duplicate datapath connections handling
The way to handle multiple connections from the same datapath I took
is mostly the same as in dpset, but it's always good to reinstall
the LDAP Packet-In flows even while switch tries to reconnect to us.
Signed-off-by: Wei-Li Tang <alextwl@xinguard.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/topology/switches.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/ryu/topology/switches.py b/ryu/topology/switches.py index fb3af8e0..ddcd2e7f 100644 --- a/ryu/topology/switches.py +++ b/ryu/topology/switches.py @@ -471,12 +471,12 @@ class Switches(app_manager.RyuApp): def _register(self, dp): assert dp.id is not None - assert dp.id not in self.dps self.dps[dp.id] = dp - self.port_state[dp.id] = PortState() - for port in dp.ports.values(): - self.port_state[dp.id].add(port.port_no, port) + if not dp.id in self.port_state: + self.port_state[dp.id] = PortState() + for port in dp.ports.values(): + self.port_state[dp.id].add(port.port_no, port) def _unregister(self, dp): if dp.id in self.dps: @@ -526,10 +526,18 @@ class Switches(app_manager.RyuApp): LOG.debug(dp) if ev.state == MAIN_DISPATCHER: + dp_multiple_conns = False + if dp.id in self.dps: + LOG.warning('multiple connections from %s', dpid_to_str(dp.id)) + dp_multiple_conns = True + self._register(dp) switch = self._get_switch(dp.id) LOG.debug('register %s', switch) - self.send_event_to_observers(event.EventSwitchEnter(switch)) + + # Do not send event while dp has multiple connections. + if not dp_multiple_conns: + self.send_event_to_observers(event.EventSwitchEnter(switch)) if not self.link_discovery: return @@ -571,9 +579,12 @@ class Switches(app_manager.RyuApp): LOG.error('cannot install flow. unsupported version. %x', dp.ofproto.OFP_VERSION) - for port in switch.ports: - if not port.is_reserved(): - self._port_added(port) + # Do not add ports while dp has multiple connections to controller. + if not dp_multiple_conns: + for port in switch.ports: + if not port.is_reserved(): + self._port_added(port) + self.lldp_event.set() elif ev.state == DEAD_DISPATCHER: |