Skip to content

Commit 859daf8

Browse files
committed
T7950: VPP: Unexpected None interface in CGNAT when ethernet subinterface is removed from vif
Do not allow to delete subinterface if it is in use in VPP features
1 parent c284938 commit 859daf8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/conf_mode/interfaces_ethernet.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ def get_config(config=None):
171171

172172
ethernet['flowtable_interfaces'] = get_flowtable_interfaces(conf)
173173

174+
ethernet['vpp'] = conf.get_config_dict(
175+
['vpp'],
176+
key_mangling=('-', '_'),
177+
get_first_key=True,
178+
no_tag_node_value_mangle=True,
179+
)
180+
174181
return ethernet
175182

176183
def verify_speed_duplex(ethernet: dict, ethtool: Ethtool):
@@ -301,8 +308,31 @@ def verify_flowtable(ethernet: dict):
301308
if vifcname in ethernet['flowtable_interfaces']:
302309
raise ConfigError(f'Cannot delete interface "{vifcname}", still referenced on a flowtable')
303310

311+
def verify_vpp_remove_vif(ethernet: dict):
312+
"""Ensure that VIF interfaces being removed are not used by VPP features"""
313+
ifname = ethernet['ifname']
314+
315+
vpp_dict_paths = dict_to_paths_values(ethernet.get('vpp'))
316+
317+
for vif_type in ['vif_remove', 'vif_s_remove']:
318+
for vif in ethernet.get(vif_type, []):
319+
vif_name = f'{ifname}.{vif}'
320+
321+
vif_in_vpp = [
322+
k
323+
for k, v in vpp_dict_paths.items()
324+
if v == vif_name or (isinstance(v, list) and vif_name in v)
325+
]
326+
327+
if vif_in_vpp:
328+
raise ConfigError(
329+
f'Cannot delete interface "{vif_name}", it is still in use by '
330+
f'"vpp {vif_in_vpp[0].replace(".", " ")}"'
331+
)
332+
304333
def verify(ethernet):
305334
verify_flowtable(ethernet)
335+
verify_vpp_remove_vif(ethernet)
306336

307337
if 'deleted' in ethernet:
308338
return None

0 commit comments

Comments
 (0)