Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove flowMonitor key after the MultipartReply is received #64

Merged
merged 1 commit into from
Jun 29, 2023

Conversation

wenyingd
Copy link

@wenyingd wenyingd commented Jun 27, 2023

After "monitorEnabled" is enabled, an OpenFlow FlowDesc message is sent to dump the flow stats if a user calls OFSwitch.DumpFlowStats or Flow.MonitorRealizeStatus. At this time the message's transactionsID is added into a concurrent map monitoredFlows. The issue is the transactionID is not removed after the reply of FlowDesc message is received.
This change is to fix the issue.

Fix: #63

VERSION Outdated
@@ -1 +1 @@
v0.7.3
v0.7.4

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged #61 so you should make this v0.8.1

replyChan <- rep
switch t.Type {
case openflow15.MultipartType_FlowDesc:
if self.monitorEnabled {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, the following code would be a bit safer:

key := fmt.Sprintf("%d", t.Xid)
ch, found := monitoredFlows.Get(key)
if found {
        if self.monitorEnabled {
                replyChan := ch.(chan *openflow15.MultipartReply)
                replyChan <- rep
        }
        monitoredFlows.Remove(key)
}

this way we make sure that the key is removed from the map if present, regardless of the value of self.monitorEnabled. I prefer it because the rest of the code doesn't really offer strong guarantees, such as DumpFlowStats only being called when self.monitorEnabled is true.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, updated.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the latest version is not what I suggested
I was suggesting checking for existence of the key even if self.monitorEnabled is false, to ensure proper cleanup (also, ideally, entries in the map that are not removed should be expired after some time, in case no reply is ever received?).

VERSION Outdated Show resolved Hide resolved
replyChan <- rep
switch t.Type {
case openflow15.MultipartType_FlowDesc:
if self.monitorEnabled {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the latest version is not what I suggested
I was suggesting checking for existence of the key even if self.monitorEnabled is false, to ensure proper cleanup (also, ideally, entries in the map that are not removed should be expired after some time, in case no reply is ever received?).

After "monitorEnabled" is enabled, an OpenFlow FlowDesc message is sent to dump
the flow stats if a user calls OFSwitch.DumpFlowStats or
Flow.MonitorRealizeStatus. At this time the message's transactionsID is added
into a concurrent map monitoredFlows. The issue is the transactionID is not
removed after the reply of FlowDesc message is received.  This change is to fix
the issue.

Signed-off-by: wenyingd <wenyingd@vmware.com>
@antoninbas antoninbas merged commit 1905af8 into antrea-io:main Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contents of monitoredFlows concurrent map are never deleted
2 participants