@@ -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
176183def verify_speed_duplex (ethernet : dict , ethtool : Ethtool ):
@@ -301,8 +308,26 @@ 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 NAT features"""
313+ ifname = ethernet ['ifname' ]
314+
315+ for vif_type in ['vif_remove' , 'vif_s_remove' ]:
316+ for vif in ethernet .get (vif_type , []):
317+ vif_name = f'{ ifname } .{ vif } '
318+
319+ for path in ['vpp.nat44' , 'vpp.nat.cgnat' ]:
320+ for direction in ['inside' , 'outside' ]:
321+ interfaces = dict_search (f'{ path } .interface.{ direction } ' , ethernet )
322+ if interfaces and vif_name in interfaces :
323+ raise ConfigError (
324+ f'Cannot delete interface "{ vif_name } ", it is still in use by '
325+ f'"{ path .replace ("." , " " )} " as { direction } interface'
326+ )
327+
304328def verify (ethernet ):
305329 verify_flowtable (ethernet )
330+ verify_vpp_remove_vif (ethernet )
306331
307332 if 'deleted' in ethernet :
308333 return None
0 commit comments