From b8fb4de2f641dce18e60b5c7c1c3afe04ea8bd29 Mon Sep 17 00:00:00 2001 From: Omer Anson Date: Sun, 17 Mar 2019 22:02:47 +0200 Subject: [PATCH] Clear registered table handlers on datapath set_up Datapath set_up overwrites old applications with new applications (usually of the same type). If any of these applications registered a table handler - upon reconnect, this table handler will already be registered and that would raise an Exception. This change clears table handlers of old applications. Only new-type applications should be affected (legacy-type apps should remain the same). Change-Id: I356758175e9816d57d2831c34f35df8e69cafbcf Closes-Bug: #1820533 --- dragonflow/switch/drivers/ovs/datapath.py | 8 ++++++++ dragonflow/switch/drivers/ovs/os_ken_base_app.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dragonflow/switch/drivers/ovs/datapath.py b/dragonflow/switch/drivers/ovs/datapath.py index e5d228784..46b3623c5 100644 --- a/dragonflow/switch/drivers/ovs/datapath.py +++ b/dragonflow/switch/drivers/ovs/datapath.py @@ -78,6 +78,7 @@ class Datapath(object): Instantiate the applications (Including table and register allocation) Wire the applications (including translating registers) """ + self.clear_old_set_up() self._dp = os_ken_base.datapath self._table_generator = _sequence_generator( cfg.CONF.df.datapath_autoalloc_table_offset) @@ -121,6 +122,13 @@ class Datapath(object): for edge in self._layout.edges: self._install_edge(edge) + def clear_old_set_up(self): + if self.apps: + for name, app in self.apps.items(): + dp_alloc = self._dp_allocs[name] + for state_name, table_num in dp_alloc.states.items(): + app.api.unregister_table_handler(table_num) + def _get_app_class(self, app_type): """Get an application class (Python class) by app name""" mgr = stevedore.NamedExtensionManager( diff --git a/dragonflow/switch/drivers/ovs/os_ken_base_app.py b/dragonflow/switch/drivers/ovs/os_ken_base_app.py index 93d6d8ac8..232988660 100644 --- a/dragonflow/switch/drivers/ovs/os_ken_base_app.py +++ b/dragonflow/switch/drivers/ovs/os_ken_base_app.py @@ -87,7 +87,7 @@ class OsKenDFAdapter(ofp_handler.OFPHandler): ) self.table_handlers[table_id] = handler - def unregister_table_handler(self, table_id, handler): + def unregister_table_handler(self, table_id): self.table_handlers.pop(table_id, None) def notify_switch_sync_finished(self):