VOL-3212: Fix uni-trap flow match and actions
Change-Id: Iba217562a7631a9ab7dc49a4636d8f5f1a3e3a80
diff --git a/go.mod b/go.mod
index dbecb5d..a10cc84 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@
github.com/gogo/protobuf v1.3.0
github.com/golang/protobuf v1.3.2
github.com/google/uuid v1.1.1
- github.com/opencord/voltha-lib-go/v3 v3.2.8
+ github.com/opencord/voltha-lib-go/v3 v3.2.10
github.com/opencord/voltha-protos/v3 v3.4.1
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/stretchr/testify v1.4.0
diff --git a/go.sum b/go.sum
index cf618f0..475fa00 100644
--- a/go.sum
+++ b/go.sum
@@ -198,8 +198,8 @@
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
-github.com/opencord/voltha-lib-go/v3 v3.2.8 h1:aQGuX6aJmCK3d0JXnYOiMhzDsMwVy+lyw5FOZ/ggakk=
-github.com/opencord/voltha-lib-go/v3 v3.2.8/go.mod h1:MIWsmMGxIRLK8dG+CNVcE/cJCzOondyRbwJ1708BYgU=
+github.com/opencord/voltha-lib-go/v3 v3.2.10 h1:nPOYyR+WsnL0YawstDUExDF3taKtAEqBu1VuPCvwScE=
+github.com/opencord/voltha-lib-go/v3 v3.2.10/go.mod h1:MIWsmMGxIRLK8dG+CNVcE/cJCzOondyRbwJ1708BYgU=
github.com/opencord/voltha-protos/v3 v3.4.1 h1:Nrr0jKy7WiMiFlXYiK8z73RvI4K4L5b/top7d3htQQI=
github.com/opencord/voltha-protos/v3 v3.4.1/go.mod h1:nl1ETp5Iw3avxOaKD8BJlYY5wYI4KeV95aT1pL63nto=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
diff --git a/rw_core/flowdecomposition/flow_decomposer.go b/rw_core/flowdecomposition/flow_decomposer.go
index 2b4f194..986d911 100644
--- a/rw_core/flowdecomposition/flow_decomposer.go
+++ b/rw_core/flowdecomposition/flow_decomposer.go
@@ -144,7 +144,8 @@
} else {
// Trap flow for UNI port
logger.Debug(ctx, "trap-uni")
-
+ var setVid, setPcp uint32
+ var setVidOk, setPcpOk bool
//inPortNo is 0 for wildcard input case, do not include upstream port for controller bound flow in input
var inPorts = map[uint32]struct{}{inPortNo: {}}
if inPortNo == 0 {
@@ -162,8 +163,17 @@
fu.Output(egressHop.Egress),
},
}
- // Augment the matchfields with the ofpfields from the flow
- faParent.MatchFields = append(faParent.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT)...)
+ // Augment the parent device flow matchfields with the ofpfields from the flow
+ faParent.MatchFields = append(faParent.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT, fu.VLAN_VID, fu.VLAN_PCP)...)
+ // Augment the parent device flow matchfields with vlan vid and vlan pcp from action field.
+ // The child device is going to set the vlan and pcp and parent device has to match on them
+ if setVid, setVidOk = fu.GetSetActionField(ctx, flow, fu.VLAN_VID); setVidOk {
+ faParent.MatchFields = append(faParent.MatchFields, fu.VlanVid(setVid))
+ if setPcp, setPcpOk = fu.GetSetActionField(ctx, flow, fu.VLAN_PCP); setPcpOk {
+ faParent.MatchFields = append(faParent.MatchFields, fu.VlanPcp(setPcp))
+ }
+ }
+
fgParent := fu.NewFlowsAndGroups()
fs, err := fu.MkFlowStat(faParent)
if err != nil {
@@ -175,14 +185,16 @@
// Upstream flow on child (onu) device
var actions []*ofp.OfpAction
- setvid := fu.GetVlanVid(flow)
- if setvid != nil {
+ if setVidOk {
// have this child push the vlan the parent is matching/trapping on above
actions = []*ofp.OfpAction{
fu.PushVlan(0x8100),
- fu.SetField(fu.VlanVid(*setvid)),
+ fu.SetField(fu.VlanVid(setVid)),
fu.Output(ingressHop.Egress),
}
+ if setPcpOk {
+ actions = append(actions, fu.SetField(fu.VlanPcp(setPcp)))
+ }
} else {
// otherwise just set the egress port
actions = []*ofp.OfpAction{
@@ -200,11 +212,7 @@
// Augment the matchfields with the ofpfields from the flow.
// If the parent has a match vid and the child is setting that match vid exclude the the match vlan
// for the child given it will be setting that vlan and the parent will be matching on it
- if setvid != nil {
- faChild.MatchFields = append(faChild.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT, fu.VLAN_VID)...)
- } else {
- faChild.MatchFields = append(faChild.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT)...)
- }
+ faChild.MatchFields = append(faChild.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT)...)
fgChild := fu.NewFlowsAndGroups()
fs, err = fu.MkFlowStat(faChild)
if err != nil {
diff --git a/rw_core/flowdecomposition/flow_decomposer_test.go b/rw_core/flowdecomposition/flow_decomposer_test.go
index 6f8c80c..8f0149e 100644
--- a/rw_core/flowdecomposition/flow_decomposer_test.go
+++ b/rw_core/flowdecomposition/flow_decomposer_test.go
@@ -468,7 +468,7 @@
KV: fu.OfpFlowModArgs{"priority": 1000},
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(1),
- fu.VlanVid(50),
+ fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 50),
fu.EthType(0x888e),
},
Actions: []*ofp.OfpAction{
@@ -495,7 +495,7 @@
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(1),
fu.TunnelId(uint64(1)),
- fu.VlanVid(50),
+ fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101),
fu.EthType(0x888e),
},
Actions: []*ofp.OfpAction{
@@ -513,10 +513,11 @@
fu.InPort(2),
fu.TunnelId(uint64(1)),
fu.EthType(0x888e),
+ fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 50),
},
Actions: []*ofp.OfpAction{
fu.PushVlan(0x8100),
- fu.SetField(fu.VlanVid(50)),
+ fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
fu.Output(1),
},
}
@@ -532,7 +533,7 @@
KV: fu.OfpFlowModArgs{"priority": 1000},
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(1),
- fu.VlanVid(0),
+ fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
fu.EthType(0x888e),
},
Actions: []*ofp.OfpAction{
@@ -559,7 +560,7 @@
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(1),
fu.TunnelId(uint64(1)),
- fu.VlanVid(0),
+ fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101),
fu.EthType(0x888e),
},
Actions: []*ofp.OfpAction{
@@ -577,10 +578,11 @@
fu.InPort(2),
fu.TunnelId(uint64(1)),
fu.EthType(0x888e),
+ fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
},
Actions: []*ofp.OfpAction{
fu.PushVlan(0x8100),
- fu.SetField(fu.VlanVid(0)),
+ fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
fu.Output(1),
},
}
@@ -623,6 +625,7 @@
fu.InPort(1),
fu.TunnelId(uint64(1)),
fu.EthType(0x888e),
+ fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101),
},
Actions: []*ofp.OfpAction{
fu.Output(uint32(ofp.OfpPortNo_OFPP_CONTROLLER)),
@@ -641,6 +644,8 @@
fu.EthType(0x888e),
},
Actions: []*ofp.OfpAction{
+ fu.PushVlan(0x8100),
+ fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
fu.Output(1),
},
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
index 188bbbd..b1ce1c3 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
@@ -58,7 +58,7 @@
if err = ptypes.UnmarshalAny(response, unpackResult); err != nil {
logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
}
- logger.Debugw(ctx, "response", log.Fields{"rpc": rpc, "deviceId": deviceId, "success": success, "error": err})
+ logger.Debugw(ctx, "response", log.Fields{"rpc": rpc, "device-id": deviceId, "success": success, "error": err})
// TODO: Need to get the real error code
return status.Errorf(codes.Canceled, "%s", unpackResult.Reason)
}
@@ -136,7 +136,7 @@
}
func (ap *CoreProxy) DeviceUpdate(ctx context.Context, device *voltha.Device) error {
- logger.Debugw(ctx, "DeviceUpdate", log.Fields{"deviceId": device.Id})
+ logger.Debugw(ctx, "DeviceUpdate", log.Fields{"device-id": device.Id})
rpc := "DeviceUpdate"
toTopic := ap.getCoreTopic(device.Id)
args := make([]*kafka.KVArg, 1)
@@ -147,7 +147,7 @@
// Use a device specific topic as we are the only adaptercore handling requests for this device
replyToTopic := ap.getAdapterTopic()
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, device.Id, args...)
- logger.Debugw(ctx, "DeviceUpdate-response", log.Fields{"deviceId": device.Id, "success": success})
+ logger.Debugw(ctx, "DeviceUpdate-response", log.Fields{"device-id": device.Id, "success": success})
return unPackResponse(ctx, rpc, device.Id, success, result)
}
@@ -171,12 +171,12 @@
// Use a device specific topic as we are the only adaptercore handling requests for this device
replyToTopic := ap.getAdapterTopic()
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw(ctx, "PortCreated-response", log.Fields{"deviceId": deviceId, "success": success})
+ logger.Debugw(ctx, "PortCreated-response", log.Fields{"device-id": deviceId, "success": success})
return unPackResponse(ctx, rpc, deviceId, success, result)
}
func (ap *CoreProxy) PortsStateUpdate(ctx context.Context, deviceId string, portTypeFilter uint32, operStatus voltha.OperStatus_Types) error {
- logger.Debugw(ctx, "PortsStateUpdate", log.Fields{"deviceId": deviceId})
+ logger.Debugw(ctx, "PortsStateUpdate", log.Fields{"device-id": deviceId})
rpc := "PortsStateUpdate"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -195,12 +195,12 @@
// Use a device specific topic as we are the only adaptercore handling requests for this device
replyToTopic := ap.getAdapterTopic()
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw(ctx, "PortsStateUpdate-response", log.Fields{"deviceId": deviceId, "success": success})
+ logger.Debugw(ctx, "PortsStateUpdate-response", log.Fields{"device-id": deviceId, "success": success})
return unPackResponse(ctx, rpc, deviceId, success, result)
}
func (ap *CoreProxy) DeleteAllPorts(ctx context.Context, deviceId string) error {
- logger.Debugw(ctx, "DeleteAllPorts", log.Fields{"deviceId": deviceId})
+ logger.Debugw(ctx, "DeleteAllPorts", log.Fields{"device-id": deviceId})
rpc := "DeleteAllPorts"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -216,7 +216,7 @@
// Use a device specific topic as we are the only adaptercore handling requests for this device
replyToTopic := ap.getAdapterTopic()
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw(ctx, "DeleteAllPorts-response", log.Fields{"deviceId": deviceId, "success": success})
+ logger.Debugw(ctx, "DeleteAllPorts-response", log.Fields{"device-id": deviceId, "success": success})
return unPackResponse(ctx, rpc, deviceId, success, result)
}
@@ -293,7 +293,7 @@
func (ap *CoreProxy) DeviceStateUpdate(ctx context.Context, deviceId string,
connStatus voltha.ConnectStatus_Types, operStatus voltha.OperStatus_Types) error {
- logger.Debugw(ctx, "DeviceStateUpdate", log.Fields{"deviceId": deviceId})
+ logger.Debugw(ctx, "DeviceStateUpdate", log.Fields{"device-id": deviceId})
rpc := "DeviceStateUpdate"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -318,13 +318,13 @@
// Use a device specific topic as we are the only adaptercore handling requests for this device
replyToTopic := ap.getAdapterTopic()
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw(ctx, "DeviceStateUpdate-response", log.Fields{"deviceId": deviceId, "success": success})
+ logger.Debugw(ctx, "DeviceStateUpdate-response", log.Fields{"device-id": deviceId, "success": success})
return unPackResponse(ctx, rpc, deviceId, success, result)
}
func (ap *CoreProxy) ChildDeviceDetected(ctx context.Context, parentDeviceId string, parentPortNo int,
childDeviceType string, channelId int, vendorId string, serialNumber string, onuId int64) (*voltha.Device, error) {
- logger.Debugw(ctx, "ChildDeviceDetected", log.Fields{"pDeviceId": parentDeviceId, "channelId": channelId})
+ logger.Debugw(ctx, "ChildDeviceDetected", log.Fields{"parent-device-id": parentDeviceId, "channelId": channelId})
rpc := "ChildDeviceDetected"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -369,7 +369,7 @@
}
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw(ctx, "ChildDeviceDetected-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
+ logger.Debugw(ctx, "ChildDeviceDetected-response", log.Fields{"parent-device-id": parentDeviceId, "success": success})
if success {
volthaDevice := &voltha.Device{}
@@ -384,7 +384,7 @@
if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
}
- logger.Debugw(ctx, "ChildDeviceDetected-return", log.Fields{"deviceid": parentDeviceId, "success": success, "error": err})
+ logger.Debugw(ctx, "ChildDeviceDetected-return", log.Fields{"device-id": parentDeviceId, "success": success, "error": err})
return nil, status.Error(ICProxyErrorCodeToGrpcErrorCode(ctx, unpackResult.Code), unpackResult.Reason)
}
@@ -392,7 +392,7 @@
}
func (ap *CoreProxy) ChildDevicesLost(ctx context.Context, parentDeviceId string) error {
- logger.Debugw(ctx, "ChildDevicesLost", log.Fields{"pDeviceId": parentDeviceId})
+ logger.Debugw(ctx, "ChildDevicesLost", log.Fields{"parent-device-id": parentDeviceId})
rpc := "ChildDevicesLost"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -407,12 +407,12 @@
}
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw(ctx, "ChildDevicesLost-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
+ logger.Debugw(ctx, "ChildDevicesLost-response", log.Fields{"parent-device-id": parentDeviceId, "success": success})
return unPackResponse(ctx, rpc, parentDeviceId, success, result)
}
func (ap *CoreProxy) ChildDevicesDetected(ctx context.Context, parentDeviceId string) error {
- logger.Debugw(ctx, "ChildDevicesDetected", log.Fields{"pDeviceId": parentDeviceId})
+ logger.Debugw(ctx, "ChildDevicesDetected", log.Fields{"parent-device-id": parentDeviceId})
rpc := "ChildDevicesDetected"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -427,12 +427,12 @@
}
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw(ctx, "ChildDevicesDetected-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
+ logger.Debugw(ctx, "ChildDevicesDetected-response", log.Fields{"parent-device-id": parentDeviceId, "success": success})
return unPackResponse(ctx, rpc, parentDeviceId, success, result)
}
func (ap *CoreProxy) GetDevice(ctx context.Context, parentDeviceId string, deviceId string) (*voltha.Device, error) {
- logger.Debugw(ctx, "GetDevice", log.Fields{"deviceId": deviceId})
+ logger.Debugw(ctx, "GetDevice", log.Fields{"device-id": deviceId})
rpc := "GetDevice"
toTopic := ap.getCoreTopic(parentDeviceId)
@@ -446,7 +446,7 @@
}
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw(ctx, "GetDevice-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
+ logger.Debugw(ctx, "GetDevice-response", log.Fields{"parent-device-id": parentDeviceId, "success": success})
if success {
volthaDevice := &voltha.Device{}
@@ -461,14 +461,14 @@
if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
}
- logger.Debugw(ctx, "GetDevice-return", log.Fields{"deviceid": parentDeviceId, "success": success, "error": err})
+ logger.Debugw(ctx, "GetDevice-return", log.Fields{"parent-device-id": parentDeviceId, "success": success, "error": err})
// TODO: Need to get the real error code
return nil, status.Error(ICProxyErrorCodeToGrpcErrorCode(ctx, unpackResult.Code), unpackResult.Reason)
}
}
func (ap *CoreProxy) GetChildDevice(ctx context.Context, parentDeviceId string, kwargs map[string]interface{}) (*voltha.Device, error) {
- logger.Debugw(ctx, "GetChildDevice", log.Fields{"parentDeviceId": parentDeviceId, "kwargs": kwargs})
+ logger.Debugw(ctx, "GetChildDevice", log.Fields{"parent-device-id": parentDeviceId, "kwargs": kwargs})
rpc := "GetChildDevice"
toTopic := ap.getCoreTopic(parentDeviceId)
@@ -506,7 +506,7 @@
}
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw(ctx, "GetChildDevice-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
+ logger.Debugw(ctx, "GetChildDevice-response", log.Fields{"parent-device-id": parentDeviceId, "success": success})
if success {
volthaDevice := &voltha.Device{}
@@ -521,14 +521,14 @@
if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
}
- logger.Debugw(ctx, "GetChildDevice-return", log.Fields{"deviceid": parentDeviceId, "success": success, "error": err})
+ logger.Debugw(ctx, "GetChildDevice-return", log.Fields{"parent-device-id": parentDeviceId, "success": success, "error": err})
return nil, status.Error(ICProxyErrorCodeToGrpcErrorCode(ctx, unpackResult.Code), unpackResult.Reason)
}
}
func (ap *CoreProxy) GetChildDevices(ctx context.Context, parentDeviceId string) (*voltha.Devices, error) {
- logger.Debugw(ctx, "GetChildDevices", log.Fields{"parentDeviceId": parentDeviceId})
+ logger.Debugw(ctx, "GetChildDevices", log.Fields{"parent-device-id": parentDeviceId})
rpc := "GetChildDevices"
toTopic := ap.getCoreTopic(parentDeviceId)
@@ -542,7 +542,7 @@
}
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw(ctx, "GetChildDevices-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
+ logger.Debugw(ctx, "GetChildDevices-response", log.Fields{"parent-device-id": parentDeviceId, "success": success})
if success {
volthaDevices := &voltha.Devices{}
@@ -557,14 +557,14 @@
if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
}
- logger.Debugw(ctx, "GetChildDevices-return", log.Fields{"deviceid": parentDeviceId, "success": success, "error": err})
+ logger.Debugw(ctx, "GetChildDevices-return", log.Fields{"parent-device-id": parentDeviceId, "success": success, "error": err})
return nil, status.Error(ICProxyErrorCodeToGrpcErrorCode(ctx, unpackResult.Code), unpackResult.Reason)
}
}
func (ap *CoreProxy) SendPacketIn(ctx context.Context, deviceId string, port uint32, pktPayload []byte) error {
- logger.Debugw(ctx, "SendPacketIn", log.Fields{"deviceId": deviceId, "port": port, "pktPayload": pktPayload})
+ logger.Debugw(ctx, "SendPacketIn", log.Fields{"device-id": deviceId, "port": port, "pktPayload": pktPayload})
rpc := "PacketIn"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -588,12 +588,12 @@
Value: pkt,
}
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw(ctx, "SendPacketIn-response", log.Fields{"pDeviceId": deviceId, "success": success})
+ logger.Debugw(ctx, "SendPacketIn-response", log.Fields{"device-id": deviceId, "success": success})
return unPackResponse(ctx, rpc, deviceId, success, result)
}
func (ap *CoreProxy) DeviceReasonUpdate(ctx context.Context, deviceId string, deviceReason string) error {
- logger.Debugw(ctx, "DeviceReasonUpdate", log.Fields{"deviceId": deviceId, "deviceReason": deviceReason})
+ logger.Debugw(ctx, "DeviceReasonUpdate", log.Fields{"device-id": deviceId, "deviceReason": deviceReason})
rpc := "DeviceReasonUpdate"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -612,7 +612,7 @@
Value: reason,
}
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw(ctx, "DeviceReason-response", log.Fields{"pDeviceId": deviceId, "success": success})
+ logger.Debugw(ctx, "DeviceReason-response", log.Fields{"device-id": deviceId, "success": success})
return unPackResponse(ctx, rpc, deviceId, success, result)
}
@@ -630,12 +630,12 @@
Value: pmConfigs,
}
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, pmConfigs.Id, args...)
- logger.Debugw(ctx, "DevicePMConfigUpdate-response", log.Fields{"pDeviceId": pmConfigs.Id, "success": success})
+ logger.Debugw(ctx, "DevicePMConfigUpdate-response", log.Fields{"pmconfig-device-id": pmConfigs.Id, "success": success})
return unPackResponse(ctx, rpc, pmConfigs.Id, success, result)
}
func (ap *CoreProxy) ReconcileChildDevices(ctx context.Context, parentDeviceId string) error {
- logger.Debugw(ctx, "ReconcileChildDevices", log.Fields{"parentDeviceId": parentDeviceId})
+ logger.Debugw(ctx, "ReconcileChildDevices", log.Fields{"parent-device-id": parentDeviceId})
rpc := "ReconcileChildDevices"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -647,13 +647,13 @@
}
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw(ctx, "ReconcileChildDevices-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
+ logger.Debugw(ctx, "ReconcileChildDevices-response", log.Fields{"parent-device-id": parentDeviceId, "success": success})
return unPackResponse(ctx, rpc, parentDeviceId, success, result)
}
func (ap *CoreProxy) PortStateUpdate(ctx context.Context, deviceId string, pType voltha.Port_PortType, portNum uint32,
operStatus voltha.OperStatus_Types) error {
- logger.Debugw(ctx, "PortStateUpdate", log.Fields{"deviceId": deviceId, "portType": pType, "portNo": portNum, "operation_status": operStatus})
+ logger.Debugw(ctx, "PortStateUpdate", log.Fields{"device-id": deviceId, "portType": pType, "portNo": portNum, "operation_status": operStatus})
rpc := "PortStateUpdate"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -684,6 +684,6 @@
// Use a device specific topic as we are the only adaptercore handling requests for this device
replyToTopic := ap.getAdapterTopic()
success, result := ap.kafkaICProxy.InvokeRPC(log.WithSpanFromContext(context.Background(), ctx), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw(ctx, "PortStateUpdate-response", log.Fields{"deviceId": deviceId, "success": success})
+ logger.Debugw(ctx, "PortStateUpdate-response", log.Fields{"device-id": deviceId, "success": success})
return unPackResponse(ctx, rpc, deviceId, success, result)
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/request_handler.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/request_handler.go
index a92ed51..f3a93df 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/request_handler.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/request_handler.go
@@ -432,7 +432,7 @@
}
}
}
- logger.Debugw(ctx, "Update_pm_config", log.Fields{"deviceId": device.Id, "pmConfigs": pmConfigs})
+ logger.Debugw(ctx, "Update_pm_config", log.Fields{"device-id": device.Id, "pmConfigs": pmConfigs})
//Invoke the pm config update API of the adapter
if err := rhp.adapter.Update_pm_config(ctx, device, pmConfigs); err != nil {
return nil, status.Errorf(codes.NotFound, "%s", err.Error())
@@ -455,7 +455,7 @@
switch arg.Key {
case "deviceId":
if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-deviceId", log.Fields{"error": err})
+ logger.Warnw(ctx, "cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case "outPort":
@@ -475,7 +475,7 @@
}
}
}
- logger.Debugw(ctx, "Receive_packet_out", log.Fields{"deviceId": deviceId.Val, "outPort": egressPort, "packet": packet})
+ logger.Debugw(ctx, "Receive_packet_out", log.Fields{"device-id": deviceId.Val, "outPort": egressPort, "packet": packet})
//Invoke the adopt device on the adapter
if err := rhp.adapter.Receive_packet_out(ctx, deviceId.Val, int(egressPort.Val), packet); err != nil {
return nil, status.Errorf(codes.NotFound, "%s", err.Error())
@@ -514,7 +514,7 @@
}
}
- logger.Debugw(ctx, "Get_ofp_device_info", log.Fields{"deviceId": device.Id})
+ logger.Debugw(ctx, "Get_ofp_device_info", log.Fields{"device-id": device.Id})
var cap *ic.SwitchCapability
var err error
@@ -582,7 +582,7 @@
logger.Debugw(ctx, "enable_port", log.Fields{"args": args})
deviceId, port, err := rhp.getEnableDisableParams(ctx, args)
if err != nil {
- logger.Warnw(ctx, "enable_port", log.Fields{"args": args, "deviceId": deviceId, "port": port})
+ logger.Warnw(ctx, "enable_port", log.Fields{"args": args, "device-id": deviceId, "port": port})
return err
}
return rhp.adapter.Enable_port(ctx, deviceId, port)
@@ -592,7 +592,7 @@
logger.Debugw(ctx, "disable_port", log.Fields{"args": args})
deviceId, port, err := rhp.getEnableDisableParams(ctx, args)
if err != nil {
- logger.Warnw(ctx, "disable_port", log.Fields{"args": args, "deviceId": deviceId, "port": port})
+ logger.Warnw(ctx, "disable_port", log.Fields{"args": args, "device-id": deviceId, "port": port})
return err
}
return rhp.adapter.Disable_port(ctx, deviceId, port)
@@ -717,7 +717,7 @@
}
case "pDeviceId":
if err := ptypes.UnmarshalAny(arg.Value, pDeviceId); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-parent-deviceId", log.Fields{"error": err})
+ logger.Warnw(ctx, "cannot-unmarshal-parent-device-id", log.Fields{"error": err})
return nil, err
}
case "valuetype":
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/logfeaturescontroller.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/logfeaturescontroller.go
index a0d77b8..f608e1e 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/logfeaturescontroller.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/logfeaturescontroller.go
@@ -25,16 +25,18 @@
)
const (
- defaultTracingStatusKey = "trace_publish" // kvstore key containing tracing configuration status
+ defaultTracingStatusKey = "trace_publish" // kvstore key containing tracing configuration status
+ defaultLogCorrelationStatusKey = "log_correlation" // kvstore key containing log correlation configuration status
)
// ComponentLogFeatureController represents Configuration for Logging related features of Tracing and Log
// Correlation of specific Voltha component.
type ComponentLogFeaturesController struct {
- ComponentName string
- componentNameConfig *ComponentConfig
- configManager *ConfigManager
- initialTracingStatus bool // Initial default tracing status set by helm chart
+ ComponentName string
+ componentNameConfig *ComponentConfig
+ configManager *ConfigManager
+ initialTracingStatus bool // Initial default tracing status set by helm chart
+ initialLogCorrelationStatus bool // Initial default log correlation status set by helm chart
}
func NewComponentLogFeaturesController(ctx context.Context, cm *ConfigManager) (*ComponentLogFeaturesController, error) {
@@ -45,12 +47,14 @@
}
tracingStatus := log.GetGlobalLFM().GetTracePublishingStatus()
+ logCorrelationStatus := log.GetGlobalLFM().GetLogCorrelationStatus()
return &ComponentLogFeaturesController{
- ComponentName: componentName,
- componentNameConfig: nil,
- configManager: cm,
- initialTracingStatus: tracingStatus,
+ ComponentName: componentName,
+ componentNameConfig: nil,
+ configManager: cm,
+ initialTracingStatus: tracingStatus,
+ initialLogCorrelationStatus: logCorrelationStatus,
}, nil
}
@@ -87,14 +91,27 @@
logger.Errorw(ctx, "failed-to-persist-component-initial-tracing-status-at-startup", log.Fields{"error": err, "tracingstatus": statusString})
}
}
+
+ _, err = cc.componentNameConfig.Retrieve(ctx, defaultLogCorrelationStatusKey)
+ if err != nil {
+ statusString := "DISABLED"
+ if cc.initialLogCorrelationStatus {
+ statusString = "ENABLED"
+ }
+ err = cc.componentNameConfig.Save(ctx, defaultLogCorrelationStatusKey, statusString)
+ if err != nil {
+ logger.Errorw(ctx, "failed-to-persist-component-initial-log-correlation-status-at-startup", log.Fields{"error": err, "logcorrelationstatus": statusString})
+ }
+ }
}
// processLogFeaturesConfig will first load and apply configuration of log features. Then it will start waiting for any changes
// made to configuration in config store (etcd) and apply the same
func (cc *ComponentLogFeaturesController) processLogFeaturesConfig(ctx context.Context) {
- // Load and apply Tracing Status for first time
+ // Load and apply Tracing Status and log correlation status for first time
cc.loadAndApplyTracingStatusUpdate(ctx)
+ cc.loadAndApplyLogCorrelationStatusUpdate(ctx)
componentConfigEventChan := cc.componentNameConfig.MonitorForConfigChange(ctx)
@@ -110,6 +127,8 @@
if strings.HasSuffix(configEvent.ConfigAttribute, defaultTracingStatusKey) {
cc.loadAndApplyTracingStatusUpdate(ctx)
+ } else if strings.HasSuffix(configEvent.ConfigAttribute, defaultLogCorrelationStatusKey) {
+ cc.loadAndApplyLogCorrelationStatusUpdate(ctx)
}
}
}
@@ -125,7 +144,7 @@
}
if desiredTracingStatus != "ENABLED" && desiredTracingStatus != "DISABLED" {
- logger.Warnw(ctx, "unsupported-tracing-status-configured-in-config-store", log.Fields{"tracing-status": desiredTracingStatus})
+ logger.Warnw(ctx, "unsupported-tracing-status-configured-in-config-store", log.Fields{"failed-tracing-status": desiredTracingStatus, "tracing-status": log.GetGlobalLFM().GetTracePublishingStatus()})
return
}
@@ -133,3 +152,21 @@
log.GetGlobalLFM().SetTracePublishingStatus(desiredTracingStatus == "ENABLED")
}
+
+func (cc *ComponentLogFeaturesController) loadAndApplyLogCorrelationStatusUpdate(ctx context.Context) {
+
+ desiredLogCorrelationStatus, err := cc.componentNameConfig.Retrieve(ctx, defaultLogCorrelationStatusKey)
+ if err != nil || desiredLogCorrelationStatus == "" {
+ logger.Warn(ctx, "unable-to-retrieve-log-correlation-status-from-config-store")
+ return
+ }
+
+ if desiredLogCorrelationStatus != "ENABLED" && desiredLogCorrelationStatus != "DISABLED" {
+ logger.Warnw(ctx, "unsupported-log-correlation-status-configured-in-config-store", log.Fields{"failed-log-correlation-status": desiredLogCorrelationStatus, "log-correlation-status": log.GetGlobalLFM().GetLogCorrelationStatus()})
+ return
+ }
+
+ logger.Debugw(ctx, "retrieved-log-correlation-status", log.Fields{"log-correlation-status": desiredLogCorrelationStatus})
+
+ log.GetGlobalLFM().SetLogCorrelationStatus(desiredLogCorrelationStatus == "ENABLED")
+}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/flows/flow_utils.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/flows/flow_utils.go
index 66e719c..9b800bf 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/flows/flow_utils.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/flows/flow_utils.go
@@ -491,6 +491,35 @@
return nil
}
+func GetSetActionField(ctx context.Context, flow *ofp.OfpFlowStats, ofbType ofp.OxmOfbFieldTypes) (uint32, bool) {
+ if flow == nil {
+ return 0, false
+ }
+ for _, instruction := range flow.Instructions {
+ if instruction.Type == uint32(APPLY_ACTIONS) {
+ actions := instruction.GetActions()
+ for _, action := range actions.GetActions() {
+ if action.Type == SET_FIELD {
+ setField := action.GetSetField()
+ if setField.Field.GetOfbField().Type == ofbType {
+ switch ofbType {
+ case VLAN_PCP:
+ return setField.Field.GetOfbField().GetVlanPcp(), true
+ case VLAN_VID:
+ return setField.Field.GetOfbField().GetVlanVid(), true
+ default:
+ logger.Errorw(ctx, "unsupported-ofb-field-type", log.Fields{"ofbType": ofbType})
+ return 0, false
+ }
+ }
+ }
+ }
+ return 0, false
+ }
+ }
+ return 0, false
+}
+
func GetTunnelId(flow *ofp.OfpFlowStats) uint64 {
if flow == nil {
return 0
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 2fd46fe..0e5ebad 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -102,7 +102,7 @@
github.com/modern-go/concurrent
# github.com/modern-go/reflect2 v1.0.1
github.com/modern-go/reflect2
-# github.com/opencord/voltha-lib-go/v3 v3.2.8
+# github.com/opencord/voltha-lib-go/v3 v3.2.10
github.com/opencord/voltha-lib-go/v3/pkg/adapters
github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif
github.com/opencord/voltha-lib-go/v3/pkg/adapters/common