From bced875d720277fa91d0da629466447fc22e83c6 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 29 Nov 2020 20:32:22 +0100 Subject: dhcpv6-relay: T3095: improve verify() - Upstream interfaces require a DHCPv6 server to be configured - Listen interface must have a a global unicast address assigned, else ISC dhcrelay won't start. --- src/conf_mode/dhcpv6_relay.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/conf_mode') diff --git a/src/conf_mode/dhcpv6_relay.py b/src/conf_mode/dhcpv6_relay.py index 9a91ace1c..cf8a26674 100755 --- a/src/conf_mode/dhcpv6_relay.py +++ b/src/conf_mode/dhcpv6_relay.py @@ -20,9 +20,11 @@ from sys import exit from vyos.config import Config from vyos.configdict import dict_merge +from vyos.ifconfig import Interface from vyos.template import render from vyos.util import call from vyos.util import dict_search +from vyos.validate import is_ipv6_link_local from vyos.xml import defaults from vyos import ConfigError from vyos import airbag @@ -54,10 +56,25 @@ def verify(relay): if 'upstream_interface' not in relay: raise ConfigError('At least one upstream interface required!') + for interface, config in relay['upstream_interface'].items(): + if 'address' not in config: + raise ConfigError('DHCPv6 server required for upstream ' \ + f'interface {interface}!') if 'listen_interface' not in relay: raise ConfigError('At least one listen interface required!') + # DHCPv6 relay requires at least one global unicat address assigned to the + # interface + for interface in relay['listen_interface']: + has_global = False + for addr in Interface(interface).get_addr(): + if not is_ipv6_link_local(addr.split('/')[0]): + has_global = True + if not has_global: + raise ConfigError(f'Interface {interface} does not have global '\ + 'IPv6 address assigned!') + return None def generate(relay): -- cgit v1.2.3