@@ -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 {
@@ -322,9 +321,8 @@ func (i *Initializer) initInterfaceStore() error {
322321 intf = cniserver .ParseOVSPortInterfaceConfig (port , ovsPort )
323322 case interfacestore .AntreaTrafficControl :
324323 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- }
324+ case interfacestore .AntreaIPsec :
325+ intf = noderoute .ParseTunnelInterfaceConfig (port , ovsPort )
328326 default :
329327 klog .InfoS ("Unknown Antrea interface type" , "type" , interfaceType )
330328 }
@@ -376,6 +374,30 @@ func (i *Initializer) initInterfaceStore() error {
376374 return nil
377375}
378376
377+ func (i * Initializer ) restorePortConfigs () error {
378+ ovsCtlClient := ovsctl .NewClient (i .ovsBridge )
379+ ovsPorts , err := i .ovsBridgeClient .GetPortList ()
380+ if err != nil {
381+ return fmt .Errorf ("failed to list OVS ports: %w" , err )
382+ }
383+ for _ , port := range ovsPorts {
384+ interfaceType , ok := port .ExternalIDs [interfacestore .AntreaInterfaceTypeKey ]
385+ if ! ok {
386+ continue
387+ }
388+ switch interfaceType {
389+ case interfacestore .AntreaIPsec :
390+ fallthrough
391+ case interfacestore .AntreaTrafficControl :
392+ if err := ovsCtlClient .SetPortNoFlood (int (port .OFPort )); err != nil {
393+ return fmt .Errorf ("failed to set port %s with no-flood: %w" , port .Name , err )
394+ }
395+ klog .InfoS ("Set port no-flood successfully" , "PortName" , port .Name )
396+ }
397+ }
398+ return nil
399+ }
400+
379401// Initialize sets up agent initial configurations.
380402func (i * Initializer ) Initialize () error {
381403 klog .Info ("Setting up node network" )
@@ -394,6 +416,10 @@ func (i *Initializer) Initialize() error {
394416 return err
395417 }
396418
419+ if err := i .restorePortConfigs (); err != nil {
420+ return err
421+ }
422+
397423 if i .enableL7NetworkPolicy {
398424 // prepareL7NetworkPolicyInterfaces must be executed after setupOVSBridge since it requires interfaceStore.
399425 if err := i .prepareL7NetworkPolicyInterfaces (); err != nil {
@@ -568,11 +594,17 @@ func (i *Initializer) initOpenFlowPipeline() error {
568594 i .ofClient .ReplayFlows ()
569595 klog .Info ("Flow replay completed" )
570596
597+ klog .InfoS ("Restoring OF port configs to OVS bridge" )
598+ if err := i .restorePortConfigs (); err != nil {
599+ klog .ErrorS (err , "Failed to restore OF port configs" )
600+ } else {
601+ klog .InfoS ("Port configs restoration completed" )
602+ }
571603 // ofClient and ovsBridgeClient have their own mechanisms to restore connections with OVS, and it could
572604 // happen that ovsBridgeClient's connection is not ready when ofClient completes flow replay. We retry it
573605 // with a timeout that is longer time than ovsBridgeClient's maximum connecting retry interval (8 seconds)
574606 // to ensure the flag can be removed successfully.
575- err : = wait .PollImmediate (200 * time .Millisecond , 10 * time .Second , func () (done bool , err error ) {
607+ err = wait .PollImmediate (200 * time .Millisecond , 10 * time .Second , func () (done bool , err error ) {
576608 if err := i .FlowRestoreComplete (); err != nil {
577609 return false , nil
578610 }
0 commit comments