From 3d8ca10a91d394670a52137135c2bd56b07de8b9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 2 Jun 2022 10:46:35 +0200 Subject: mod/bridge-port-to: re-enable interfaces with longer delay... ... and in one go to limit the overall runtime. Looks like IPv6 addresses are not flushed if the link down does not last long enough (~ 2 seconds on linux). This results on stale addresses after switching bridge, which breaks connectivity. --- mod/bridge-port-to | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/bridge-port-to b/mod/bridge-port-to index 36b827b..dec5eb1 100644 --- a/mod/bridge-port-to +++ b/mod/bridge-port-to @@ -17,6 +17,7 @@ :foreach BridgePort in=[ /interface/bridge/port/find where !(comment=[]) ] do={ :local BridgePortVal [ /interface/bridge/port/get $BridgePort ]; + :local InterfaceReEnable [ :toarray "" ]; :foreach Config,BridgeDefault in=[ $ParseKeyValueStore ($BridgePortVal->"comment") ] do={ :if ($Config = $BridgePortTo) do={ :local DHCPClient [ /ip/dhcp-client/find where interface=$BridgePortVal->"interface" comment="toggle with bridge port" ]; @@ -44,8 +45,7 @@ } /interface/ethernet/disable [ find where name=$BridgePortVal->"interface" ]; /interface/bridge/port/set disabled=no bridge=$BridgeDefault $BridgePort; - :delay 500ms; - /interface/ethernet/enable [ find where name=$BridgePortVal->"interface" ]; + :set InterfaceReEnable ($InterfaceReEnable, $BridgePortVal->"interface"); } else={ $LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . \ " bridge " . $BridgeDefault . ".") false; @@ -53,5 +53,11 @@ } } } + :if ([ :len $InterfaceReEnable ] > 0) do={ + :delay 2s; + :foreach Interface in=$InterfaceReEnable do={ + /interface/ethernet/enable [ find where name=$Interface ]; + } + } } } -- cgit v1.2.3-70-g09d2