From d6c08414d55eadd8232b693303f2b14bfe121c01 Mon Sep 17 00:00:00 2001 From: Jernej Jakob Date: Wed, 22 Apr 2020 17:12:25 +0200 Subject: interfaces: T2362: delete and re-add all EUI64 addresses if MAC has changed --- src/conf_mode/interfaces-bonding.py | 8 +++++++- src/conf_mode/interfaces-bridge.py | 8 +++++++- src/conf_mode/interfaces-ethernet.py | 8 +++++++- src/conf_mode/interfaces-pseudo-ethernet.py | 8 +++++++- src/conf_mode/interfaces-wireless.py | 8 +++++++- 5 files changed, 35 insertions(+), 5 deletions(-) (limited to 'src') 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') -- cgit v1.2.3