summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-12-19 23:00:13 +0100
committerChristian Poessinger <christian@poessinger.com>2019-12-20 14:41:17 +0100
commit033205eb58acda9f571fbb5e84374a29186837e6 (patch)
treeb9c4596a127d902657683f262ba40d6129c60e5b /src
parent9a0f6371be5ef97974a4cc6d8f4fb97c3f9741ac (diff)
downloadvyos-1x-033205eb58acda9f571fbb5e84374a29186837e6.tar.gz
vyos-1x-033205eb58acda9f571fbb5e84374a29186837e6.zip
igmp-proxy: T1893: verify that proxy interface exists
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/igmp_proxy.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/conf_mode/igmp_proxy.py b/src/conf_mode/igmp_proxy.py
index 37744535e..cd0704124 100755
--- a/src/conf_mode/igmp_proxy.py
+++ b/src/conf_mode/igmp_proxy.py
@@ -20,6 +20,7 @@ import sys
import os
import jinja2
+from netifaces import interfaces
from vyos.config import Config
from vyos import ConfigError
@@ -51,11 +52,11 @@ quickleave
{% endif -%}
{% for interface in interfaces %}
-# Configuration for {{ interface.interface }} ({{ interface.role }} interface)
+# Configuration for {{ interface.name }} ({{ interface.role }} interface)
{% if interface.role == 'disabled' -%}
-phyint {{ interface.interface }} disabled
+phyint {{ interface.name }} disabled
{%- else -%}
-phyint {{ interface.interface }} {{ interface.role }} ratelimit 0 threshold {{ interface.threshold }}
+phyint {{ interface.name }} {{ interface.role }} ratelimit 0 threshold {{ interface.threshold }}
{%- endif -%}
{%- for subnet in interface.alt_subnet %}
altnet {{ subnet }}
@@ -91,7 +92,7 @@ def get_config():
for intf in conf.list_nodes('interface'):
conf.set_level('protocols igmp-proxy interface {0}'.format(intf))
interface = {
- 'interface': intf,
+ 'name': intf,
'alt_subnet': [],
'role': 'downstream',
'threshold': '1',
@@ -130,6 +131,8 @@ def verify(igmp_proxy):
upstream = 0
for interface in igmp_proxy['interfaces']:
+ if interface['name'] not in interfaces():
+ raise ConfigError('Interface "{}" does not exist'.format(interface['name']))
if "upstream" == interface['role']:
upstream += 1