Skip to content

Commit

Permalink
Remove flowMonitor key after the MultipartReply is received (#64)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
wenyingd authored Jun 29, 2023
1 parent b62fdc5 commit 1905af8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.8.0
v0.8.1
25 changes: 12 additions & 13 deletions ofctrl/ofSwitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,19 @@ func (self *OFSwitch) handleMessages(dpid net.HardwareAddr, msg util.Message) {

case *openflow15.MultipartReply:
log.Debugf("Received MultipartReply")
rep := (*openflow15.MultipartReply)(t)
if self.monitorEnabled {
key := fmt.Sprintf("%d", rep.Xid)
switch t.Type {
case openflow15.MultipartType_FlowDesc:
key := fmt.Sprintf("%d", t.Xid)
replyChan, found := monitoredFlows.Get(key)
if found {
replyChan <- rep
if self.monitorEnabled {
replyChan <- t
}
monitoredFlows.Remove(key)
}
}
// send packet rcvd callback
self.app.MultipartReply(self, rep)
self.app.MultipartReply(self, t)
case *openflow15.VendorError:
errData := t.ErrorMsg.Data.Bytes()
result := MessageResult{
Expand Down Expand Up @@ -437,18 +440,14 @@ func (self *OFSwitch) DumpFlowStats(cookieID uint64, cookieMask *uint64, flowMat
select {
case reply := <-replyChan:
flowStates := make([]*openflow15.FlowDesc, 0)
if reply.Type == openflow15.MultipartType_FlowDesc {
flowArr := reply.Body
for _, entry := range flowArr {
flowStates = append(flowStates, entry.(*openflow15.FlowDesc))
}
return flowStates, nil
flowArr := reply.Body
for _, entry := range flowArr {
flowStates = append(flowStates, entry.(*openflow15.FlowDesc))
}

return flowStates, nil
case <-time.After(2 * time.Second):
return nil, errors.New("timeout to wait for MultipartReply message")
}
return nil, nil
}

func (self *OFSwitch) CheckStatus(timeout time.Duration) bool {
Expand Down

0 comments on commit 1905af8

Please sign in to comment.