[VOL-3355] Return MeterMod Error on meter faliure
Change-Id: Iba26d7c2c37263f3dad6fbf3f64ed94a7124ce4c
diff --git a/internal/pkg/openflow/meter.go b/internal/pkg/openflow/meter.go
index df1b533..1a110ac 100644
--- a/internal/pkg/openflow/meter.go
+++ b/internal/pkg/openflow/meter.go
@@ -16,7 +16,9 @@
package openflow
import (
+ "encoding/binary"
"encoding/json"
+ "unsafe"
ofp "github.com/opencord/goloxi/of13"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
@@ -98,5 +100,21 @@
log.Fields{
"device-id": ofc.DeviceID,
"error": err})
+ message := ofp.NewMeterModFailedErrorMsg()
+ message.SetXid(request.Xid)
+ //OF 1.3
+ message.SetVersion(4)
+ //FIXME Hardcoding to Invalid Meter for now.
+ message.SetCode(ofp.OFPMMFCInvalidMeter)
+ meterByteId := make([]byte, 4)
+ binary.BigEndian.PutUint32(meterByteId, request.MeterId)
+ message.SetData(meterByteId)
+ message.Length = uint16(unsafe.Sizeof(*message))
+ if err := ofc.SendMessage(ctx, message); err != nil {
+ logger.Errorw(ctx, "Error reporting failure of MeterMod to controller",
+ log.Fields{
+ "device-id": ofc.DeviceID,
+ "error": err})
+ }
}
}