[VOL-5164] - flow handling during port delete
Change-Id: I325dcf3719ce932d7fe05012c30c5f4c16552546
diff --git a/internal/pkg/controller/controller.go b/internal/pkg/controller/controller.go
index b1939b9..9ccb21d 100644
--- a/internal/pkg/controller/controller.go
+++ b/internal/pkg/controller/controller.go
@@ -313,7 +313,8 @@
}
// DelFlows to delete flows
-func (v *VoltController) DelFlows(cntx context.Context, port string, device string, flow *of.VoltFlow) error {
+// delFlowsOnlyInDevice flag indicates that flows should be deleted only in DB/device and should not be forwarded to core
+func (v *VoltController) DelFlows(cntx context.Context, port string, device string, flow *of.VoltFlow, delFlowsOnlyInDevice bool) error {
d, err := v.GetDevice(device)
if err != nil {
logger.Errorw(ctx, "Device Not Found", log.Fields{"Device": device})
@@ -351,10 +352,18 @@
}
}
} else {
- flow.Command = of.CommandDel
- d.UpdateFlows(flow, devPort)
- for cookie := range flow.SubFlows {
- logger.Debugw(ctx, "Flow Del added to queue", log.Fields{"Cookie": cookie, "Device": device, "Port": port})
+ // Delete flows only in DB/device when Port Delete has come. Do not send flows to core during Port Delete
+ if delFlowsOnlyInDevice {
+ for cookie, subFlow := range flow.SubFlows {
+ err := d.DelFlow(ctx, subFlow)
+ logger.Infow(ctx, "Flow Deleted from device/DB", log.Fields{"Cookie": cookie, "Device": device, "Port": port, "Error": err})
+ }
+ } else {
+ flow.Command = of.CommandDel
+ d.UpdateFlows(flow, devPort)
+ for cookie := range flow.SubFlows {
+ logger.Debugw(ctx, "Flow Del added to queue", log.Fields{"Cookie": cookie, "Device": device, "Port": port})
+ }
}
}
return nil