summaryrefslogtreecommitdiff
path: root/src/op_mode/neighbor.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2022-06-17 09:06:01 -0400
committerDaniil Baturin <daniil@vyos.io>2022-06-17 09:06:01 -0400
commit651eb5794d22576d90ae8ff2fe0b1aeda92dd581 (patch)
treed0c327c2a47166f6681152842b0f772938e400f8 /src/op_mode/neighbor.py
parent53c9b500f085394ddfb92f03b6aae99b4e399460 (diff)
downloadvyos-1x-651eb5794d22576d90ae8ff2fe0b1aeda92dd581.tar.gz
vyos-1x-651eb5794d22576d90ae8ff2fe0b1aeda92dd581.zip
T2719: handle non-existent interfaces in the neighbor script
Diffstat (limited to 'src/op_mode/neighbor.py')
-rwxr-xr-xsrc/op_mode/neighbor.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/op_mode/neighbor.py b/src/op_mode/neighbor.py
index b0b52c082..d86a372ac 100755
--- a/src/op_mode/neighbor.py
+++ b/src/op_mode/neighbor.py
@@ -32,12 +32,17 @@ import typing
import vyos.opmode
+def interface_exists(interface):
+ import os
+ return os.path.exists(f'/sys/class/net/{interface}')
def get_raw_data(family, interface=None, state=None):
from json import loads
from vyos.util import cmd
if interface:
+ if not interface_exists(interface):
+ raise ValueError(f"Interface '{interface}' does not exist in the system")
interface = f"dev {interface}"
else:
interface = ""