From 531d61f8a9eb6710e1cebd621fcea3af98c73cd0 Mon Sep 17 00:00:00 2001 From: Wenying Dong Date: Mon, 30 Dec 2024 19:15:01 -0800 Subject: [PATCH] [Windows] Support OF port state "down" when installing Pod forwarding rules (#6889) On Windows, OVS has an issue which doesn't correctly update the port status after an OpenFlow port is successfully installed. So OVS may send out PortStatus message with Port state as LIND_DOWN, this issue doesn't impact on the datapath forwarding. This change is a workaround to ensure Pod's OpenFlow entries are installed as long as the OpenFlow port is allocated. Signed-off-by: Wenying Dong --- pkg/agent/cniserver/pod_configuration.go | 20 ++++++++++++++++--- pkg/agent/cniserver/pod_configuration_test.go | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pkg/agent/cniserver/pod_configuration.go b/pkg/agent/cniserver/pod_configuration.go index e1ad05752eb..744628a6d69 100644 --- a/pkg/agent/cniserver/pod_configuration.go +++ b/pkg/agent/cniserver/pod_configuration.go @@ -677,12 +677,26 @@ func (pc *podConfigurator) recordPodEvent(ifConfig *interfacestore.InterfaceConf } func (pc *podConfigurator) processPortStatusMessage(status *openflow15.PortStatus) { - // Update Pod OpenFlow entries only after the OpenFlow port state is live. - if status.Desc.State != openflow15.PS_LIVE { + ofPort := status.Desc.PortNo + state := status.Desc.State + // Update Pod OpenFlow entries only after the OpenFlow port state is live or down. + // Accepting Port state "openflow15.PS_LINK_DOWN" is a workaround for Windows OVS issue https://github.com/openvswitch/ovs-issues/issues/351. + // In which OVS does not correctly implement function netdev_windows_update_flags, so OVS doesn't update ifp_flags + // after a new OpenFlow port is successfully installed. Since this OVS issue doesn't have side impact on datapath + // packets forwarding, antrea-agent will ignore the bad state to ensure the Pod's OpenFlow entries are installed as + // long as the port number is allocated. + if state != openflow15.PS_LIVE && state != openflow15.PS_LINK_DOWN { + klog.InfoS("Ignoring the OVS port status message with undesired state", "ofPort", ofPort, "state", state) + return + } + + if ofPort == 0 { + klog.InfoS("Ignoring the OVS port status message with undesired port number", "ofPort", ofPort, "state", state) return } + ovsPort := string(bytes.Trim(status.Desc.Name, "\x00")) - ofPort := status.Desc.PortNo + klog.InfoS("Processing OVS port status message", "ovsPort", ovsPort, "ofPort", ofPort, "state", state) ifConfig, found := pc.ifaceStore.GetInterfaceByName(ovsPort) if !found { diff --git a/pkg/agent/cniserver/pod_configuration_test.go b/pkg/agent/cniserver/pod_configuration_test.go index b906ec7dcc2..9db1b819521 100644 --- a/pkg/agent/cniserver/pod_configuration_test.go +++ b/pkg/agent/cniserver/pod_configuration_test.go @@ -393,7 +393,7 @@ func TestProcessPortStatusMessage(t *testing.T) { PortNo: 1, Length: 72, Name: []byte(fmt.Sprintf("%s\x00", podIfName)), - State: openflow15.PS_LINK_DOWN, + State: openflow15.PS_BLOCKED, }, }, ovsPortName: podIfName,