@@ -229,6 +229,21 @@ def __intermediate_device(self, interface):
229229 # A non-bridge interface that contains L2 options.
230230 return device
231231 device ['type' ] = 'bridge'
232+ if not interface ['ifname' ].startswith ('br-' ):
233+ # Add "br-" prefix to the bridge name
234+ # for backward compatibility: OpenWrt <= 19
235+ # automatically added the "br-" prefix to bridges,
236+ # but later in OpenWrt 21 the bridge logic changed
237+ # and that is no longer true, for that reason
238+ # old configurations of OpenWISP made for OpenWrt 19
239+ # which relied on the bridge names to be prefixed
240+ # automatically with "br-" were breaking;
241+ # to resolve this backward compatibility issue
242+ # we now add the "br-" prefix automatically if needed.
243+ interface ['ifname' ] = f'br-{ interface ["ifname" ]} '
244+ device ['name' ] = interface ['ifname' ]
245+ interface ['device' ] = device ['name' ]
246+
232247 # Add STP options only if STP is enabled
233248 self ._add_options (
234249 'stp' , self ._bridge_interface_options ['stp' ], device , interface
@@ -439,7 +454,7 @@ def __get_device_config_for_interface(self, interface):
439454 del device_config ['type' ]
440455 # ifname has been renamed to device in OpenWrt 21.02
441456 if device_config .get ('type' ) == 'bridge' :
442- interface ['ifname' ] = 'br-{}' . format ( interface .pop ('device' ) )
457+ interface ['ifname' ] = interface .pop ('device' )
443458 elif interface .get ('proto' ) not in self ._proto_dsa_conflict :
444459 interface ['ifname' ] = interface .pop ('device' )
445460 return device_config
0 commit comments