bit SEND_FLOW_REM;
}
}
+ 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 {
uses generic_flow_attributes;
leaf removed_reason {
- type removed_reason_flags;
+ type removed-flow-reason;
}
leaf duration_nsec {
*/
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 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.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;
-
+ private static final Logger logger = LoggerFactory.getLogger(FlowRemovedTranslator.class);
public FlowRemovedTranslator(ConvertorExecutor convertorExecutor) {
this.convertorExecutor = convertorExecutor;
}
.setPriority(input.getPriority())
.setTableId(translateTableId(input));
+ if(Objects.nonNull(input.getReason())) {
+ flowRemovedBld.setReason(translateReason(input));
+ }
+
return flowRemovedBld.build();
}
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.Objects;
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.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.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.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;
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
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) {