diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-10-13 12:34:10 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-10-13 12:34:15 +0200 |
commit | 67ca26dc6f6e548dfd0a1bc787aa039d96450b97 (patch) | |
tree | c1ba321ab09b882683461a7d04d30691e88613f9 /src/conf_mode/interface-ethernet.py | |
parent | 177de5378a1e9e6983e34ef4a5244310b78d870a (diff) | |
download | vyos-1x-67ca26dc6f6e548dfd0a1bc787aa039d96450b97.tar.gz vyos-1x-67ca26dc6f6e548dfd0a1bc787aa039d96450b97.zip |
Python/ifconfig: T1557: add support for DHCPv6 client options
Diffstat (limited to 'src/conf_mode/interface-ethernet.py')
-rwxr-xr-x | src/conf_mode/interface-ethernet.py | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/src/conf_mode/interface-ethernet.py b/src/conf_mode/interface-ethernet.py index 267f5cb3b..cd40aff3e 100755 --- a/src/conf_mode/interface-ethernet.py +++ b/src/conf_mode/interface-ethernet.py @@ -79,10 +79,21 @@ def apply_vlan_config(vlan, config): if config['dhcp_vendor_class_id']: opt['vendor_class_id'] = config['dhcp_vendor_class_id'] - # store DHCP config dictionary - used later on when addresses - # are requested + # store DHCP config dictionary - used later on when addresses are aquired vlan.set_dhcp_options(opt) + # get DHCPv6 config dictionary and update values + opt = vlan.get_dhcpv6_options() + + if config['dhcpv6_prm_only']: + opt['dhcpv6_prm_only'] = True + + if config['dhcpv6_temporary']: + opt['dhcpv6_temporary'] = True + + # store DHCPv6 config dictionary - used later on when addresses are aquired + vlan.set_dhcpv6_options(opt) + # update interface description used e.g. within SNMP vlan.set_alias(config['description']) # ignore link state changes @@ -157,11 +168,11 @@ def get_config(): # DHCPv6 only acquire config parameters, no address if conf.exists('dhcpv6-options parameters-only'): - eth['dhcpv6_prm_only'] = conf.return_value('dhcpv6-options parameters-only') + eth['dhcpv6_prm_only'] = True # DHCPv6 temporary IPv6 address if conf.exists('dhcpv6-options temporary'): - eth['dhcpv6_temporary'] = conf.return_value('dhcpv6-options temporary') + eth['dhcpv6_temporary'] = True # ignore link state changes if conf.exists('disable-link-detect'): @@ -270,6 +281,9 @@ def verify(eth): if eth['speed'] != 'auto': raise ConfigError('If duplex is hardcoded, speed must be hardcoded, too') + if eth['dhcpv6_prm_only'] and eth['dhcpv6_temporary']: + raise ConfigError('DHCPv6 temporary and parameters-only options are mutually exclusive!') + conf = Config() # some options can not be changed when interface is enslaved to a bond for bond in conf.list_nodes('interfaces bonding'): @@ -279,6 +293,18 @@ def verify(eth): if eth['address']: raise ConfigError('Can not assign address to interface {} which is a member of {}').format(eth['intf'], bond) + # DHCPv6 parameters-only and temporary address are mutually exclusive + for vif_s in eth['vif_s']: + if vif_s['dhcpv6_prm_only'] and vif_s['dhcpv6_temporary']: + raise ConfigError('DHCPv6 temporary and parameters-only options are mutually exclusive!') + + for vif_c in vif_s['vif_c']: + if vif_c['dhcpv6_prm_only'] and vif_c['dhcpv6_temporary']: + raise ConfigError('DHCPv6 temporary and parameters-only options are mutually exclusive!') + + for vif in eth['vif']: + if vif['dhcpv6_prm_only'] and vif['dhcpv6_temporary']: + raise ConfigError('DHCPv6 temporary and parameters-only options are mutually exclusive!') return None @@ -306,10 +332,21 @@ def apply(eth): if eth['dhcp_vendor_class_id']: opt['vendor_class_id'] = eth['dhcp_vendor_class_id'] - # store DHCP config dictionary - used later on when addresses - # are requested + # store DHCP config dictionary - used later on when addresses are aquired e.set_dhcp_options(opt) + # get DHCPv6 config dictionary and update values + opt = e.get_dhcpv6_options() + + if eth['dhcpv6_prm_only']: + opt['dhcpv6_prm_only'] = True + + if eth['dhcpv6_temporary']: + opt['dhcpv6_temporary'] = True + + # store DHCPv6 config dictionary - used later on when addresses are aquired + e.set_dhcpv6_options(opt) + # ignore link state changes e.set_link_detect(eth['disable_link_detect']) # disable ethernet flow control (pause frames) |