On flow being removed from switch on idle timeout, onFlowRemoved() api was
invoked and while conversion reason was not being converted and added, so
the application using API onFlowRemoved() was not getting the reason for
flow being removed from the switch.
This change will provide the reason invoking onFlowRemoved() API
Change-Id: Id8b957b5b2cc581215fb84b8ca84d1d9a04e5619
Signed-off-by: eeiillu <suja.t@ericsson.com>
(cherry picked from commit
80cee5d71d306b8806d9316d12dceb5c1d1d63e6)
+ typedef removed-flow-reason {
+ type enumeration {
+ enum OFPRR_IDLE_TIMEOUT{
+ value 0;
+ description "Flow idle time exceeded idle_timeout.";
+ }
+ enum OFPRR_HARD_TIMEOUT {
+ value 1;
+ description "Time exceeded hard_timeout.";
+ }
+ enum OFPRR_DELETE {
+ value 2;
+ description "Evicted by a DELETE flow mod.";
+ }
+ enum OFPRR_GROUP_DELETE {
+ value 3;
+ description "Group was removed.";
+ }
- typedef removed_reason_flags {
- type bits {
- bit IDLE_TIMEOUT;
- bit HARD_TIMEOUT;
- bit DELETE;
- bit GROUP_DELETE;
- }
- }
grouping generic_flow_attributes {
leaf priority {
grouping generic_flow_attributes {
leaf priority {
uses generic_flow_attributes;
leaf removed_reason {
uses generic_flow_attributes;
leaf removed_reason {
- type removed_reason_flags;
+ type removed-flow-reason;
import yang-ext {prefix ext; revision-date "2013-07-09";}
import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
import yang-ext {prefix ext; revision-date "2013-07-09";}
import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
- import opendaylight-flow-types {prefix types;revision-date "2013-10-26";}
+ import opendaylight-flow-types {prefix types;revision-date "2013-10-26";}
import opendaylight-group-types {prefix group-type;revision-date "2013-10-18";}
import opendaylight-meter-types {prefix meter-type;revision-date "2013-09-18";}
import flow-capable-transaction {prefix tr; revision-date "2015-03-04";}
import opendaylight-group-types {prefix group-type;revision-date "2013-10-18";}
import opendaylight-meter-types {prefix meter-type;revision-date "2013-09-18";}
import flow-capable-transaction {prefix tr; revision-date "2015-03-04";}
leaf flow-ref {
type types:flow-ref;
}
leaf flow-ref {
type types:flow-ref;
}
+ leaf reason {
+ type types:removed-flow-reason;
+ }
uses node-flow;
uses tr:transaction-aware;
}
uses node-flow;
uses tr:transaction-aware;
}
*/
package org.opendaylight.openflowplugin.impl.translator;
*/
package org.opendaylight.openflowplugin.impl.translator;
+import java.util.Objects;
import java.util.Optional;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
import java.util.Optional;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemovedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemovedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.RemovedFlowReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* translate {@link FlowRemoved} message to FlowRemoved notification (omit instructions)
*/
public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved> {
private final ConvertorExecutor convertorExecutor;
/**
* translate {@link FlowRemoved} message to FlowRemoved notification (omit instructions)
*/
public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved> {
private final ConvertorExecutor convertorExecutor;
+ private static final Logger logger = LoggerFactory.getLogger(FlowRemovedTranslator.class);
public FlowRemovedTranslator(ConvertorExecutor convertorExecutor) {
this.convertorExecutor = convertorExecutor;
}
public FlowRemovedTranslator(ConvertorExecutor convertorExecutor) {
this.convertorExecutor = convertorExecutor;
}
.setPriority(input.getPriority())
.setTableId(translateTableId(input));
.setPriority(input.getPriority())
.setTableId(translateTableId(input));
+ if(Objects.nonNull(input.getReason())) {
+ flowRemovedBld.setReason(translateReason(input));
+ }
+
return flowRemovedBld.build();
}
return flowRemovedBld.build();
}
protected Short translateTableId(FlowRemoved flowRemoved) {
return flowRemoved.getTableId().getValue().shortValue();
}
protected Short translateTableId(FlowRemoved flowRemoved) {
return flowRemoved.getTableId().getValue().shortValue();
}
+
+
+ private RemovedFlowReason translateReason(FlowRemoved removedFlow) {
+ logger.debug("--Entering translateReason within FlowRemovedTranslator with reason:{} " + removedFlow.getReason());
+ switch (removedFlow.getReason()) {
+ case OFPRRIDLETIMEOUT:
+ return RemovedFlowReason.OFPRRIDLETIMEOUT;
+ case OFPRRHARDTIMEOUT:
+ return RemovedFlowReason.OFPRRHARDTIMEOUT;
+ case OFPRRDELETE:
+ return RemovedFlowReason.OFPRRDELETE;
+ case OFPRRGROUPDELETE:
+ return RemovedFlowReason.OFPRRGROUPDELETE;
+ default:
+ logger.debug("The flow is being deleted for some unknown reason ");
+ return RemovedFlowReason.OFPRRDELETE;
+ }
+ }
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
import org.opendaylight.openflowjava.util.ByteBufUtils;
import org.opendaylight.openflowplugin.api.OFConstants;
import java.util.concurrent.CopyOnWriteArrayList;
import org.opendaylight.openflowjava.util.ByteBufUtils;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemovedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemovedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.RemovedReasonFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.RemovedFlowReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.mod.removed.Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.mod.removed.MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.mod.removed.Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.mod.removed.MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst;
salFlowRemoved.setHardTimeout(ofFlow.getHardTimeout());
salFlowRemoved.setPacketCount(ofFlow.getPacketCount());
salFlowRemoved.setByteCount(ofFlow.getByteCount());
salFlowRemoved.setHardTimeout(ofFlow.getHardTimeout());
salFlowRemoved.setPacketCount(ofFlow.getPacketCount());
salFlowRemoved.setByteCount(ofFlow.getByteCount());
- RemovedReasonFlags removeReasonFlag = new RemovedReasonFlags(
- FlowRemovedReason.OFPRRDELETE.equals(ofFlow.getReason()),
- FlowRemovedReason.OFPRRGROUPDELETE.equals(ofFlow.getReason()),
- FlowRemovedReason.OFPRRHARDTIMEOUT.equals(ofFlow.getReason()),
- FlowRemovedReason.OFPRRIDLETIMEOUT.equals(ofFlow.getReason())
- );
- salFlowRemoved.setRemovedReason(removeReasonFlag);
+ if(Objects.nonNull(ofFlow.getReason())) {
+ salFlowRemoved.setRemovedReason(translateReason(ofFlow));
+ }
OpenflowVersion ofVersion = OpenflowVersion.get(sc.getPrimaryConductor().getVersion());
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match ofMatch = ofFlow
OpenflowVersion ofVersion = OpenflowVersion.get(sc.getPrimaryConductor().getVersion());
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match ofMatch = ofFlow
return Collections.emptyList();
}
}
return Collections.emptyList();
}
}
+ private RemovedFlowReason translateReason(FlowRemoved removedFlow) {
+ LOG.debug("--Entering translateReason within FlowRemovedTranslator with reason:{} " + removedFlow.getReason());
+ switch (removedFlow.getReason()) {
+ case OFPRRIDLETIMEOUT:
+ return RemovedFlowReason.OFPRRIDLETIMEOUT;
+ case OFPRRHARDTIMEOUT:
+ return RemovedFlowReason.OFPRRHARDTIMEOUT;
+ case OFPRRDELETE:
+ return RemovedFlowReason.OFPRRDELETE;
+ case OFPRRGROUPDELETE:
+ return RemovedFlowReason.OFPRRGROUPDELETE;
+ default:
+ LOG.debug("The flow being default and hence deleting it ");
+ return RemovedFlowReason.OFPRRDELETE;
+ }
+ }
public Match fromMatch(final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match ofMatch,
final BigInteger datapathid, final OpenflowVersion ofVersion) {
public Match fromMatch(final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match ofMatch,
final BigInteger datapathid, final OpenflowVersion ofVersion) {