VOL-2511 - copy the read buffer for processing
Change-Id: I47e0618e1e3e7d4c25ff196c523f3c85c6ba590a
diff --git a/internal/pkg/openflow/client.go b/internal/pkg/openflow/client.go
index ccceb44..6e832e5 100644
--- a/internal/pkg/openflow/client.go
+++ b/internal/pkg/openflow/client.go
@@ -345,8 +345,10 @@
}
// Decode and process the packet
- decoder := goloxi.NewDecoder(buf[:need])
- header, err := ofp.DecodeHeader(decoder)
+ msgbuf := make([]byte, need)
+ copy(msgbuf, buf[:need])
+ decoder := goloxi.NewDecoder(msgbuf)
+ msg, err := ofp.DecodeHeader(decoder)
if err != nil {
js, _ := json.Marshal(decoder)
logger.Errorw("failed-to-decode",
@@ -357,13 +359,13 @@
break top
}
if logger.V(log.DebugLevel) {
- js, _ := json.Marshal(header)
+ js, _ := json.Marshal(msg)
logger.Debugw("packet-header",
log.Fields{
"device-id": ofc.DeviceID,
"header": js})
}
- ofc.parseHeader(header)
+ ofc.parseHeader(msg)
}
}
logger.Debugw("end-of-stream",