diff options
author | John Estabrook <jestabro@vyos.io> | 2023-06-20 09:29:11 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-06-20 10:45:24 -0500 |
commit | 0439ade98cd8a0301351dfcdfe3e3f4dc7040473 (patch) | |
tree | 05dbc54a66bc2043acdfabe7a882f2fd6209f681 /python/vyos/util.py | |
parent | 19c16a47d2ead176c5882e593a5d98e321be9cd4 (diff) | |
download | vyos-1x-0439ade98cd8a0301351dfcdfe3e3f4dc7040473.tar.gz vyos-1x-0439ade98cd8a0301351dfcdfe3e3f4dc7040473.zip |
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.
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r-- | python/vyos/util.py | 10 |
1 files changed, 7 insertions, 3 deletions
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 |