summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-11-05 21:57:14 +0000
committerChristian Breunig <christian@breunig.cc>2026-11-05 21:57:14 +0000
commit0949562e1761bd3885664132e9485347afcc50aa (patch)
tree8f0002d04ace3c5fffb2ad82b8a4c475b845a7cd /python
parent1b5bdef24632bbc497768847719eba8c33d93ef5 (diff)
downloadvyos-1x-0949562e1761bd3885664132e9485347afcc50aa.tar.gz
vyos-1x-0949562e1761bd3885664132e9485347afcc50aa.zip
https: T9559: report a missing VRF instead of a free port
The port check reported a port as free when the VRF to test it in did not exist, so a missing or misspelled VRF passed unnoticed. The device error is now raised like any other error. Callers that verify the VRF beforehand are not affected; the default VRF is still treated like no VRF at all.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/utils/network.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py
index d478f4d2c..c7304d15b 100644
--- a/python/vyos/utils/network.py
+++ b/python/vyos/utils/network.py
@@ -394,7 +394,6 @@ def check_port_availability(address: str = None, port: int = 0,
False if a port is busy or IP address does not exists
True if a port is free and IP address exists
"""
- import errno
import socket
from ipaddress import ip_address
@@ -428,14 +427,8 @@ def check_port_availability(address: str = None, port: int = 0,
# When a VRF is specified, bind the socket to the VRF master
# device so the address is resolved in that VRF's L3 domain.
if vrf:
- try:
- s.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE,
- (vrf + '\0').encode())
- except OSError as e:
- # nothing can listen in a VRF that does not exist (yet)
- if e.errno == errno.ENODEV:
- return True
- raise
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE,
+ (vrf + '\0').encode())
try:
s.bind(sockaddr)
return True # port is free to use