diff options
author | Jernej Jakob <jernej.jakob@gmail.com> | 2020-04-22 17:12:25 +0200 |
---|---|---|
committer | Jernej Jakob <jernej.jakob@gmail.com> | 2020-04-23 16:09:33 +0200 |
commit | d6c08414d55eadd8232b693303f2b14bfe121c01 (patch) | |
tree | cf7e5bd23fb6f2efa9f376cf4eec440bac31ff81 | |
parent | 76feb7d154a452ba5475b9b6ee720a7a8f5491d5 (diff) | |
download | vyos-1x-d6c08414d55eadd8232b693303f2b14bfe121c01.tar.gz vyos-1x-d6c08414d55eadd8232b693303f2b14bfe121c01.zip |
interfaces: T2362: delete and re-add all EUI64 addresses if MAC has changed
-rw-r--r-- | python/vyos/configdict.py | 3 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-bonding.py | 8 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-bridge.py | 8 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-ethernet.py | 8 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-pseudo-ethernet.py | 8 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-wireless.py | 8 |
6 files changed, 38 insertions, 5 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 611f7dd6e..71c85b36d 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -225,6 +225,9 @@ def vlan_to_dict(conf): # Media Access Control (MAC) address if conf.exists('mac'): vlan['mac'] = conf.return_value('mac') + # always recreate EUI64 addresses if mac is set + # I'm not sure how to check if a vlan interface exists or how to get its current mac. + vlan['ipv6_eui64_prefix_remove'] += vlan['ipv6_eui64_prefix'] # Maximum Transmission Unit (MTU) if conf.exists('mtu'): diff --git a/src/conf_mode/interfaces-bonding.py b/src/conf_mode/interfaces-bonding.py index 0ce376a16..001da081c 100755 --- a/src/conf_mode/interfaces-bonding.py +++ b/src/conf_mode/interfaces-bonding.py @@ -20,7 +20,7 @@ from copy import deepcopy from sys import exit from netifaces import interfaces -from vyos.ifconfig import BondIf +from vyos.ifconfig import BondIf, Section from vyos.ifconfig_vlan import apply_vlan_config, verify_vlan_config from vyos.configdict import list_diff, vlan_to_dict from vyos.config import Config @@ -228,6 +228,12 @@ def get_config(): if conf.exists('mac'): bond['mac'] = conf.return_value('mac') + # Find out if MAC has changed - if so, we need to delete all IPv6 EUI64 addresses + # before re-adding them + if ( bond['mac'] and bond['intf'] in Section.interfaces(section='bonding') + and bond['mac'] != BondIf(bond['intf'], create=False).get_mac() ): + bond['ipv6_eui64_prefix_remove'] += bond['ipv6_eui64_prefix'] + # Bonding mode if conf.exists('mode'): act_mode = conf.return_value('mode') diff --git a/src/conf_mode/interfaces-bridge.py b/src/conf_mode/interfaces-bridge.py index ba459f871..2ad5ecf2b 100755 --- a/src/conf_mode/interfaces-bridge.py +++ b/src/conf_mode/interfaces-bridge.py @@ -20,7 +20,7 @@ from copy import deepcopy from sys import exit from netifaces import interfaces -from vyos.ifconfig import BridgeIf +from vyos.ifconfig import BridgeIf, Section from vyos.ifconfig.stp import STP from vyos.configdict import list_diff from vyos.config import Config @@ -186,6 +186,12 @@ def get_config(): if conf.exists('mac'): bridge['mac'] = conf.return_value('mac') + # Find out if MAC has changed - if so, we need to delete all IPv6 EUI64 addresses + # before re-adding them + if ( bridge['mac'] and bridge['intf'] in Section.interfaces(section='bridge') + and bridge['mac'] != BridgeIf(bridge['intf'], create=False).get_mac() ): + bridge['ipv6_eui64_prefix_remove'] += bridge['ipv6_eui64_prefix'] + # Interval at which neighbor bridges are removed if conf.exists('max-age'): bridge['max_age'] = int(conf.return_value('max-age')) diff --git a/src/conf_mode/interfaces-ethernet.py b/src/conf_mode/interfaces-ethernet.py index 01a805e8b..f620cc6ab 100755 --- a/src/conf_mode/interfaces-ethernet.py +++ b/src/conf_mode/interfaces-ethernet.py @@ -20,7 +20,7 @@ from sys import exit from copy import deepcopy from netifaces import interfaces -from vyos.ifconfig import EthernetIf +from vyos.ifconfig import EthernetIf, Section from vyos.ifconfig_vlan import apply_vlan_config, verify_vlan_config from vyos.configdict import list_diff, vlan_to_dict from vyos.config import Config @@ -201,6 +201,12 @@ def get_config(): if conf.exists('mac'): eth['mac'] = conf.return_value('mac') + # Find out if MAC has changed - if so, we need to delete all IPv6 EUI64 addresses + # before re-adding them + if ( eth['mac'] and eth['intf'] in Section.interfaces(section='ethernet') + and eth['mac'] != EthernetIf(eth['intf'], create=False).get_mac() ): + eth['ipv6_eui64_prefix_remove'] += eth['ipv6_eui64_prefix'] + # Maximum Transmission Unit (MTU) if conf.exists('mtu'): eth['mtu'] = int(conf.return_value('mtu')) diff --git a/src/conf_mode/interfaces-pseudo-ethernet.py b/src/conf_mode/interfaces-pseudo-ethernet.py index d7863512e..bf19e46b9 100755 --- a/src/conf_mode/interfaces-pseudo-ethernet.py +++ b/src/conf_mode/interfaces-pseudo-ethernet.py @@ -22,7 +22,7 @@ from netifaces import interfaces from vyos.config import Config from vyos.configdict import list_diff, vlan_to_dict -from vyos.ifconfig import MACVLANIf +from vyos.ifconfig import MACVLANIf, Section from vyos.ifconfig_vlan import apply_vlan_config, verify_vlan_config from vyos.validate import is_bridge_member from vyos import ConfigError @@ -190,6 +190,12 @@ def get_config(): if conf.exists(['mac']): peth['mac'] = conf.return_value(['mac']) + # Find out if MAC has changed - if so, we need to delete all IPv6 EUI64 addresses + # before re-adding them + if ( peth['mac'] and peth['intf'] in Section.interfaces(section='pseudo-ethernet') + and peth['mac'] != MACVLANIf(peth['intf'], create=False).get_mac() ): + peth['ipv6_eui64_prefix_remove'] += peth['ipv6_eui64_prefix'] + # MACvlan mode if conf.exists(['mode']): peth['mode'] = conf.return_value(['mode']) diff --git a/src/conf_mode/interfaces-wireless.py b/src/conf_mode/interfaces-wireless.py index e7c14e3fb..82a5a892a 100755 --- a/src/conf_mode/interfaces-wireless.py +++ b/src/conf_mode/interfaces-wireless.py @@ -25,7 +25,7 @@ from netaddr import EUI, mac_unix_expanded from vyos.config import Config from vyos.configdict import list_diff, vlan_to_dict -from vyos.ifconfig import WiFiIf +from vyos.ifconfig import WiFiIf, Section from vyos.ifconfig_vlan import apply_vlan_config, verify_vlan_config from vyos.template import render from vyos.util import chown, call @@ -402,6 +402,12 @@ def get_config(): if conf.exists('mac'): wifi['mac'] = conf.return_value('mac') + # Find out if MAC has changed - if so, we need to delete all IPv6 EUI64 addresses + # before re-adding them + if ( wifi['mac'] and wifi['intf'] in Section.interfaces(section='wireless') + and wifi['mac'] != WiFiIf(wifi['intf'], create=False).get_mac() ): + wifi['ipv6_eui64_prefix_remove'] += wifi['ipv6_eui64_prefix'] + # Maximum number of wireless radio stations if conf.exists('max-stations'): wifi['max_stations'] = conf.return_value('max-stations') |