add post-down op for vlan's data class interfaces

Vlan's data class do not use the formats vlanNNN os ethX.NNN when
applied in Linux. It creates with the name used in sysinv DB. To
achieve that it uses a pre-up op with "ip link add ..."

This change adds the reverse operation for ifdown, removing the device
in the 'post-down' to make sure the link is removed at the end, in the
same manner that happens for vlanNNN or ethX.NNN interfaces (via
ifup/ifdown binaries from ifupdown package)

Test Plan:
[PASS] add a interface with class=data and type=vlan, then execute
       a) lock/unlock to create the interface in the node
       b) modify the MTU in the new interface
       c) lock/unlock to modify the interface in the node
       After that check interface creation in the kernel

Closes-Bug: 2045658

Change-Id: Ifc9ac45657fafbaa60366bc06decf0ccc6d53341
Signed-off-by: Andre Kantek <andrefernandozanella.kantek@windriver.com>
This commit is contained in:
Andre Kantek 2023-12-04 15:19:15 -03:00
parent e72aca646a
commit 090c4e7e7b
2 changed files with 9 additions and 0 deletions

View File

@ -965,6 +965,8 @@ def add_vlan_interface_creation_command(context, iface, options):
fill_interface_config_option_operation(options, IFACE_PRE_UP_OP,
'ip link add link %s name %s type vlan id %d' %
(lower_os_ifname, os_ifname, iface['vlan_id']))
fill_interface_config_option_operation(options, IFACE_POST_DOWN_OP,
'ip link del %s' % (os_ifname))
def get_bond_interface_options_sysconfig(iface, primary_iface):

View File

@ -1751,6 +1751,7 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
options = {'IPV6_AUTOCONF': 'no',
'PHYSDEV': self.port['name'],
'VLAN': 'yes',
'post_down': 'ip link del vlan#1',
'pre_up': '/sbin/modprobe -q 8021q; ip link add link '
'{} name vlan#1 type vlan id 1'.format(
self.port['name'])}
@ -1769,6 +1770,7 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
mtu = '1500'
set_mtu = self._get_postup_mtu("vlan#1", mtu)
options = {'mtu': mtu,
'post-down': 'ip link del vlan#1',
'pre-up': '/sbin/modprobe -q 8021q; ip link add link '
'{} name vlan#1 type vlan id 1'.format(
self.port['name']),
@ -1794,6 +1796,7 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
config = interface.get_interface_network_config(self.context, vlan, network.id)
options = {'gateway': '192.168.204.1',
'mtu': '1500',
'post-down': 'ip link del vlan100',
'post-up': '/usr/sbin/ip link set dev vlan100 mtu 1500; echo 0 > '
'/proc/sys/net/ipv6/conf/vlan100/autoconf; echo 0 '
'> /proc/sys/net/ipv6/conf/vlan100/accept_ra; echo 0 > '
@ -1821,6 +1824,7 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
config = interface.get_interface_network_config(self.context, vlan,
network.id)
options = {'mtu': '1500',
'post-down': 'ip link del vlan.dot',
'post-up': '/usr/sbin/ip link set dev vlan.dot mtu 1500; echo 0 > '
'/proc/sys/net/ipv6/conf/vlan.dot/autoconf; echo 0 '
'> /proc/sys/net/ipv6/conf/vlan.dot/accept_ra; echo 0 > '
@ -1850,6 +1854,7 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
config = interface.get_interface_network_config(self.context, vlan, network.id)
options = {'gateway': '192.168.204.1',
'mtu': '1500',
'post-down': 'ip link del vlan100',
'post-up': '/usr/sbin/ip link set dev vlan100 mtu 1500; echo 0 > '
'/proc/sys/net/ipv6/conf/vlan100/autoconf; echo 0 '
'> /proc/sys/net/ipv6/conf/vlan100/accept_ra; echo 0 > '
@ -1872,6 +1877,7 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
options = {'IPV6_AUTOCONF': 'no',
'PHYSDEV': bond['ifname'],
'VLAN': 'yes',
'post_down': 'ip link del vlan#1',
'pre_up': '/sbin/modprobe -q 8021q; ip link add link '
'{} name vlan#1 type vlan id 1'.format(
bond['ifname'])}
@ -1891,6 +1897,7 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
mtu = '1500'
set_mtu = self._get_postup_mtu("vlan#1", mtu)
options = {'mtu': mtu,
'post-down': 'ip link del vlan#1',
'pre-up': '/sbin/modprobe -q 8021q; ip link add link '
'{} name vlan#1 type vlan id 1'.format(
bond['ifname']),