From 0439ade98cd8a0301351dfcdfe3e3f4dc7040473 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Tue, 20 Jun 2023 09:29:11 -0500 Subject: vyos.util: T5300: check_port_availability: return False iff EADDRINUSE At boot, the util function check_port_availability can return False with EADDRNOTAVAIL if the interface is not yet up; check explicitly for address in use. --- python/vyos/util.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'python/vyos/util.py') diff --git a/python/vyos/util.py b/python/vyos/util.py index 61ce59324..e62f9d5cf 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -1063,9 +1063,13 @@ def check_port_availability(ipaddress, port, protocol): if protocol == 'udp': server = UDPServer((ipaddress, port), None, bind_and_activate=True) server.server_close() - return True - except: - return False + except Exception as e: + # errno.h: + #define EADDRINUSE 98 /* Address already in use */ + if e.errno == 98: + return False + + return True def install_into_config(conf, config_paths, override_prompt=True): # Allows op-mode scripts to install values if called from an active config session -- cgit v1.2.3