[VOL-1385] Remove parent's device flows after child deletion
This commit fixes the following:
1) Do not automatically raise an error when no routes can be
found when decomposing a flow. In some cases flows can still
be decomposed (e.g. some trap flows).
2) Delete flows from a parent device when receiving delete flow
instructions from the OF controller after a child device has
been deleted (previously was failing as no route could be
obtained).
Change-Id: I33dd45d52626146f0a6b4668048c979b5c931f9c
diff --git a/rw_core/core/device/agent.go b/rw_core/core/device/agent.go
index 8d18e10..264b44f 100755
--- a/rw_core/core/device/agent.go
+++ b/rw_core/core/device/agent.go
@@ -574,6 +574,36 @@
return nil
}
+//filterOutFlows removes flows from a device using the uni-port as filter
+func (agent *Agent) filterOutFlows(ctx context.Context, uniPort uint32, flowMetadata *voltha.FlowMetadata) error {
+ device, err := agent.getDevice(ctx)
+ if err != nil {
+ return err
+ }
+ existingFlows := proto.Clone(device.Flows).(*voltha.Flows)
+ var flowsToDelete []*ofp.OfpFlowStats
+
+ // If an existing flow has the uniPort as an InPort or OutPort or as a Tunnel ID then it needs to be removed
+ for _, flow := range existingFlows.Items {
+ if fu.GetInPort(flow) == uniPort || fu.GetOutPort(flow) == uniPort || fu.GetTunnelId(flow) == uint64(uniPort) {
+ flowsToDelete = append(flowsToDelete, flow)
+ }
+ }
+ logger.Debugw("flows-to-delete", log.Fields{"device-id": agent.deviceID, "uni-port": uniPort, "flows": flowsToDelete})
+ if len(flowsToDelete) == 0 {
+ return nil
+ }
+
+ response, err := agent.deleteFlowsAndGroupsFromAdapter(ctx, flowsToDelete, []*ofp.OfpGroupEntry{}, flowMetadata)
+ if err != nil {
+ return err
+ }
+ if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, response); res != nil {
+ return status.Errorf(codes.Aborted, "errors-%s", res)
+ }
+ return nil
+}
+
func (agent *Agent) updateFlowsAndGroupsToAdapter(ctx context.Context, updatedFlows []*ofp.OfpFlowStats, updatedGroups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) (coreutils.Response, error) {
logger.Debugw("updateFlowsAndGroups", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})