@@ -293,6 +293,9 @@ type SecondaryLayer2NetworkController struct {
293293
294294 // EgressIP controller utilized only to initialize a network with OVN polices to support EgressIP functionality.
295295 eIPController * EgressIPController
296+
297+ // reconcile the virtual machine default gateway sending GARPs and RAs
298+ defaultGatewayReconciler * kubevirt.DefaultGatewayReconciler
296299}
297300
298301// NewSecondaryLayer2NetworkController create a new OVN controller for the given secondary layer2 nad
@@ -363,6 +366,7 @@ func NewSecondaryLayer2NetworkController(
363366 if err != nil {
364367 return nil , fmt .Errorf ("unable to create new service controller while creating new layer2 network controller: %w" , err )
365368 }
369+ oc .defaultGatewayReconciler = kubevirt .NewDefaultGatewayReconciler (oc .watchFactory , oc .GetNetInfo (), util .GetNetworkScopedK8sMgmtHostIntfName (uint (oc .GetNetworkID ())))
366370 }
367371
368372 if oc .allocatesPodAnnotation () {
@@ -908,15 +912,20 @@ func (oc *SecondaryLayer2NetworkController) updateLocalPodEvent(pod *corev1.Pod)
908912}
909913
910914func (oc * SecondaryLayer2NetworkController ) reconcileLiveMigrationTargetZone (kubevirtLiveMigrationStatus * kubevirt.LiveMigrationStatus ) error {
911- // Only primary networks has a gateway to reconcile
912- if ! oc .IsPrimaryNetwork () {
915+ if oc .defaultGatewayReconciler == nil {
913916 return nil
914917 }
915- mgmtInterfaceName := util .GetNetworkScopedK8sMgmtHostIntfName (uint (oc .GetNetworkID ()))
916-
917- if hasIPv4Subnet , _ := oc .IPMode (); hasIPv4Subnet {
918- if err := kubevirt .NewDefaultGatewayReconciler (oc .watchFactory , oc .GetNetInfo (), mgmtInterfaceName ).ReconcileIPv4AfterLiveMigration (kubevirtLiveMigrationStatus ); err != nil {
919- return err
918+ hasIPv4Subnet , hasIPv6Subnet := oc .IPMode ()
919+ if hasIPv4Subnet {
920+ if err := oc .defaultGatewayReconciler .ReconcileIPv4AfterLiveMigration (kubevirtLiveMigrationStatus ); err != nil {
921+ return fmt .Errorf ("failed reconciling IPv4 default gw after live migration at target pod '%s/%s': %w" ,
922+ kubevirtLiveMigrationStatus .TargetPod .Namespace , kubevirtLiveMigrationStatus .TargetPod .Name , err )
923+ }
924+ }
925+ if hasIPv6Subnet {
926+ if err := oc .defaultGatewayReconciler .ReconcileIPv6AfterLiveMigration (kubevirtLiveMigrationStatus ); err != nil {
927+ return fmt .Errorf ("failed reconciling IPv6 default gw after live migration at target pod '%s/%s': %w" ,
928+ kubevirtLiveMigrationStatus .TargetPod .Namespace , kubevirtLiveMigrationStatus .TargetPod .Name , err )
920929 }
921930 }
922931 return nil
0 commit comments