From: Ondrej Lichtner olichtne@redhat.com
The ServerHandler automatically closes all sockets that are either closed from the other side or get into a broken state. This is normally fine, however in case the socket in question is the Netlink socket, the InterfaceManager doesn't get notified of this event and attempts to call on this object fail with EBADF.
This makes sure that whenever the ServerHandler closes the socket, it calls the InterfaceManager reconnect_netlink() method so that a new netlink connection is established.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Slave/NetTestSlave.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py index 8695d5e..157b651 100644 --- a/lnst/Slave/NetTestSlave.py +++ b/lnst/Slave/NetTestSlave.py @@ -842,8 +842,13 @@ class ServerHandler(ConnectionHandler): self._netns = None self._c_socket = None
+ self._if_manager = None + self._security = lnst_config.get_section_values("security")
+ def set_if_manager(self, if_manager): + self._if_manager = if_manager + def accept_connection(self): self._c_socket, addr = self._s_socket.accept() self._c_socket = (SlaveSecSocket(self._c_socket), addr[0]) @@ -880,6 +885,13 @@ class ServerHandler(ConnectionHandler): self.remove_connection(self._c_socket[0]) self._c_socket = None
+ def check_connections(self): + msgs = super(ServerHandler, self).check_connections() + if 'netlink' not in self._connection_mapping: + self._if_manager.reconnect_netlink() + self.add_connection('netlink', self._if_manager.get_nl_socket()) + return msgs + def get_messages(self): messages = self.check_connections()
@@ -963,6 +975,8 @@ class NetTestSlave: self._server_handler = ServerHandler(("", port)) self._if_manager = InterfaceManager(self._server_handler)
+ self._server_handler.set_if_manager(self._if_manager) + self._net_namespaces = {}
self._methods = SlaveMethods(self._cmd_context, log_ctl,