summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-06-25 20:09:31 +0200
committerChristian Breunig <christian@breunig.cc>2023-06-25 20:25:30 +0200
commitc77e641c521c03b6098613833fe22e09b11ad23f (patch)
tree80ed85663637db90c5f7c375be7885ef14e56aa0 /src
parent9c756d5dd20ee059b76a3e8ba2d5602e5a9bbefc (diff)
downloadvyos-1x-c77e641c521c03b6098613833fe22e09b11ad23f.tar.gz
vyos-1x-c77e641c521c03b6098613833fe22e09b11ad23f.zip
bcast-relay: T5313: verify() relay interfaces have IPv4 address configured
(cherry picked from commit ca7c063666c038d104082542f04ead6062e79246)
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/bcast_relay.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/conf_mode/bcast_relay.py b/src/conf_mode/bcast_relay.py
index d93a2a8f4..265ececbd 100755
--- a/src/conf_mode/bcast_relay.py
+++ b/src/conf_mode/bcast_relay.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2017-2020 VyOS maintainers and contributors
+# Copyright (C) 2017-2023 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -17,12 +17,14 @@
import os
from glob import glob
-from netifaces import interfaces
+from netifaces import AF_INET
from sys import exit
from vyos.config import Config
-from vyos.util import call
+from vyos.configverify import verify_interface_exists
from vyos.template import render
+from vyos.util import call
+from vyos.validate import is_afi_configured
from vyos import ConfigError
from vyos import airbag
airbag.enable()
@@ -52,16 +54,14 @@ def verify(relay):
if 'port' not in config:
raise ConfigError(f'Port number mandatory for udp broadcast relay "{instance}"')
- # if only oone interface is given it's a string -> move to list
- if isinstance(config.get('interface', []), str):
- config['interface'] = [ config['interface'] ]
# Relaying data without two interface is kinda senseless ...
if len(config.get('interface', [])) < 2:
raise ConfigError('At least two interfaces are required for udp broadcast relay "{instance}"')
for interface in config.get('interface', []):
- if interface not in interfaces():
- raise ConfigError('Interface "{interface}" does not exist!')
+ verify_interface_exists(interface)
+ if not is_afi_configured(interface, AF_INET):
+ raise ConfigError(f'Interface "{interface}" has no IPv4 address configured!')
return None