@@ -287,7 +287,6 @@ func (i *Initializer) initInterfaceStore() error {
287287 return intf
288288 }
289289 ifaceList := make ([]* interfacestore.InterfaceConfig , 0 , len (ovsPorts ))
290- ovsCtlClient := ovsctl .NewClient (i .ovsBridge )
291290 for index := range ovsPorts {
292291 port := & ovsPorts [index ]
293292 ovsPort := & interfacestore.OVSPortConfig {
@@ -305,6 +304,8 @@ func (i *Initializer) initInterfaceStore() error {
305304 case interfacestore .AntreaUplink :
306305 intf = parseUplinkInterfaceFunc (port , ovsPort )
307306 case interfacestore .AntreaTunnel :
307+ fallthrough
308+ case interfacestore .AntreaIPsecTunnel :
308309 intf = parseTunnelInterfaceFunc (port , ovsPort )
309310 case interfacestore .AntreaHost :
310311 if port .Name == i .ovsBridge {
@@ -322,9 +323,6 @@ func (i *Initializer) initInterfaceStore() error {
322323 intf = cniserver .ParseOVSPortInterfaceConfig (port , ovsPort )
323324 case interfacestore .AntreaTrafficControl :
324325 intf = trafficcontrol .ParseTrafficControlInterfaceConfig (port , ovsPort )
325- if err := ovsCtlClient .SetPortNoFlood (int (ovsPort .OFPort )); err != nil {
326- klog .ErrorS (err , "Failed to set port with no-flood config" , "PortName" , port .Name )
327- }
328326 default :
329327 klog .InfoS ("Unknown Antrea interface type" , "type" , interfaceType )
330328 }
@@ -348,7 +346,11 @@ func (i *Initializer) initInterfaceStore() error {
348346 fallthrough
349347 case port .IFType == ovsconfig .STTTunnel :
350348 intf = parseTunnelInterfaceFunc (port , ovsPort )
351- antreaIFType = interfacestore .AntreaTunnel
349+ if intf .Type == interfacestore .IPSecTunnelInterface {
350+ antreaIFType = interfacestore .AntreaIPsecTunnel
351+ } else {
352+ antreaIFType = interfacestore .AntreaTunnel
353+ }
352354 case port .Name == i .ovsBridge :
353355 intf = nil
354356 antreaIFType = interfacestore .AntreaHost
@@ -376,6 +378,23 @@ func (i *Initializer) initInterfaceStore() error {
376378 return nil
377379}
378380
381+ func (i * Initializer ) restorePortConfigs () error {
382+ ovsCtlClient := ovsctl .NewClient (i .ovsBridge )
383+ interfaces := i .ifaceStore .ListInterfaces ()
384+ for _ , intf := range interfaces {
385+ switch intf .Type {
386+ case interfacestore .IPSecTunnelInterface :
387+ fallthrough
388+ case interfacestore .TrafficControlInterface :
389+ if err := ovsCtlClient .SetPortNoFlood (int (intf .OFPort )); err != nil {
390+ return fmt .Errorf ("failed to set port %s with no-flood: %w" , intf .InterfaceName , err )
391+ }
392+ klog .InfoS ("Set port no-flood successfully" , "PortName" , intf .InterfaceName )
393+ }
394+ }
395+ return nil
396+ }
397+
379398// Initialize sets up agent initial configurations.
380399func (i * Initializer ) Initialize () error {
381400 klog .Info ("Setting up node network" )
@@ -394,6 +413,10 @@ func (i *Initializer) Initialize() error {
394413 return err
395414 }
396415
416+ if err := i .restorePortConfigs (); err != nil {
417+ return err
418+ }
419+
397420 if i .enableL7NetworkPolicy {
398421 // prepareL7NetworkPolicyInterfaces must be executed after setupOVSBridge since it requires interfaceStore.
399422 if err := i .prepareL7NetworkPolicyInterfaces (); err != nil {
@@ -568,11 +591,17 @@ func (i *Initializer) initOpenFlowPipeline() error {
568591 i .ofClient .ReplayFlows ()
569592 klog .Info ("Flow replay completed" )
570593
594+ klog .InfoS ("Restoring OF port configs to OVS bridge" )
595+ if err := i .restorePortConfigs (); err != nil {
596+ klog .ErrorS (err , "Failed to restore OF port configs" )
597+ } else {
598+ klog .InfoS ("Port configs restoration completed" )
599+ }
571600 // ofClient and ovsBridgeClient have their own mechanisms to restore connections with OVS, and it could
572601 // happen that ovsBridgeClient's connection is not ready when ofClient completes flow replay. We retry it
573602 // with a timeout that is longer time than ovsBridgeClient's maximum connecting retry interval (8 seconds)
574603 // to ensure the flag can be removed successfully.
575- err : = wait .PollImmediate (200 * time .Millisecond , 10 * time .Second , func () (done bool , err error ) {
604+ err = wait .PollImmediate (200 * time .Millisecond , 10 * time .Second , func () (done bool , err error ) {
576605 if err := i .FlowRestoreComplete (); err != nil {
577606 return false , nil
578607 }
0 commit comments