use of org.onosproject.net.flow.instructions.L2ModificationInstruction in project onos by opennetworkinglab.
the class FlowModBuilderVer10 method buildL2Modification.
private OFAction buildL2Modification(Instruction i) {
L2ModificationInstruction l2m = (L2ModificationInstruction) i;
ModEtherInstruction eth;
switch(l2m.subtype()) {
case ETH_DST:
eth = (ModEtherInstruction) l2m;
return factory().actions().setDlDst(MacAddress.of(eth.mac().toLong()));
case ETH_SRC:
eth = (ModEtherInstruction) l2m;
return factory().actions().setDlSrc(MacAddress.of(eth.mac().toLong()));
case VLAN_ID:
ModVlanIdInstruction vlanId = (ModVlanIdInstruction) l2m;
return factory().actions().setVlanVid(VlanVid.ofVlan(vlanId.vlanId().toShort()));
case VLAN_PCP:
ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m;
return factory().actions().setVlanPcp(VlanPcp.of(vlanPcp.vlanPcp()));
case VLAN_POP:
return factory().actions().stripVlan();
case VLAN_PUSH:
return null;
default:
log.warn("Unimplemented action type {}.", l2m.subtype());
break;
}
return null;
}
use of org.onosproject.net.flow.instructions.L2ModificationInstruction in project onos by opennetworkinglab.
the class FlowObjectiveCompositionUtil method revertTreatmentSelector.
public static TrafficSelector revertTreatmentSelector(TrafficTreatment trafficTreatment, TrafficSelector trafficSelector) {
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
Map<Criterion.Type, Criterion> criterionMap = new HashMap<>();
for (Criterion criterion : trafficSelector.criteria()) {
criterionMap.put(criterion.type(), criterion);
}
for (Instruction instruction : trafficTreatment.allInstructions()) {
switch(instruction.type()) {
case OUTPUT:
break;
case GROUP:
break;
case L0MODIFICATION:
{
L0ModificationInstruction l0 = (L0ModificationInstruction) instruction;
switch(l0.subtype()) {
case OCH:
if (criterionMap.containsKey(Criterion.Type.OCH_SIGID)) {
if (((OchSignalCriterion) criterionMap.get((Criterion.Type.OCH_SIGID))).lambda().equals(((L0ModificationInstruction.ModOchSignalInstruction) l0).lambda())) {
criterionMap.remove(Criterion.Type.OCH_SIGID);
} else {
return null;
}
}
default:
break;
}
break;
}
case L1MODIFICATION:
{
L1ModificationInstruction l1 = (L1ModificationInstruction) instruction;
switch(l1.subtype()) {
case ODU_SIGID:
if (criterionMap.containsKey(Criterion.Type.ODU_SIGID)) {
if (((OduSignalIdCriterion) criterionMap.get((Criterion.Type.ODU_SIGID))).oduSignalId().equals(((L1ModificationInstruction.ModOduSignalIdInstruction) l1).oduSignalId())) {
criterionMap.remove(Criterion.Type.ODU_SIGID);
} else {
return null;
}
}
default:
break;
}
break;
}
case L2MODIFICATION:
{
L2ModificationInstruction l2 = (L2ModificationInstruction) instruction;
switch(l2.subtype()) {
case ETH_SRC:
if (criterionMap.containsKey(Criterion.Type.ETH_SRC)) {
if (((EthCriterion) criterionMap.get((Criterion.Type.ETH_SRC))).mac().equals(((L2ModificationInstruction.ModEtherInstruction) l2).mac())) {
criterionMap.remove(Criterion.Type.ETH_SRC);
} else {
return null;
}
} else {
break;
}
case ETH_DST:
if (criterionMap.containsKey(Criterion.Type.ETH_DST)) {
if (((EthCriterion) criterionMap.get((Criterion.Type.ETH_DST))).mac().equals(((L2ModificationInstruction.ModEtherInstruction) l2).mac())) {
criterionMap.remove(Criterion.Type.ETH_DST);
} else {
return null;
}
} else {
break;
}
case VLAN_ID:
if (criterionMap.containsKey(Criterion.Type.VLAN_VID)) {
if (((VlanIdCriterion) criterionMap.get((Criterion.Type.VLAN_VID))).vlanId().equals(((L2ModificationInstruction.ModVlanIdInstruction) l2).vlanId())) {
criterionMap.remove(Criterion.Type.VLAN_VID);
} else {
return null;
}
} else {
break;
}
case VLAN_PCP:
if (criterionMap.containsKey(Criterion.Type.VLAN_PCP)) {
if (((VlanPcpCriterion) criterionMap.get((Criterion.Type.VLAN_PCP))).priority() == ((L2ModificationInstruction.ModVlanPcpInstruction) l2).vlanPcp()) {
criterionMap.remove(Criterion.Type.VLAN_PCP);
} else {
return null;
}
} else {
break;
}
case MPLS_LABEL:
if (criterionMap.containsKey(Criterion.Type.MPLS_LABEL)) {
if (((MplsCriterion) criterionMap.get((Criterion.Type.MPLS_LABEL))).label().equals(((L2ModificationInstruction.ModMplsLabelInstruction) l2).label())) {
criterionMap.remove(Criterion.Type.ETH_DST);
} else {
return null;
}
} else {
break;
}
default:
break;
}
break;
}
case TABLE:
break;
case L3MODIFICATION:
{
L3ModificationInstruction l3 = (L3ModificationInstruction) instruction;
switch(l3.subtype()) {
case IPV4_SRC:
if (criterionMap.containsKey(Criterion.Type.IPV4_SRC)) {
if (((IPCriterion) criterionMap.get(Criterion.Type.IPV4_SRC)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
criterionMap.remove(Criterion.Type.IPV4_SRC);
} else {
return null;
}
} else {
break;
}
case IPV4_DST:
if (criterionMap.containsKey(Criterion.Type.IPV4_DST)) {
if (((IPCriterion) criterionMap.get(Criterion.Type.IPV4_DST)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
criterionMap.remove(Criterion.Type.IPV4_DST);
} else {
return null;
}
} else {
break;
}
case IPV6_SRC:
if (criterionMap.containsKey(Criterion.Type.IPV6_SRC)) {
if (((IPCriterion) criterionMap.get(Criterion.Type.IPV6_SRC)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
criterionMap.remove(Criterion.Type.IPV6_SRC);
} else {
return null;
}
} else {
break;
}
case IPV6_DST:
if (criterionMap.containsKey(Criterion.Type.IPV6_DST)) {
if (((IPCriterion) criterionMap.get(Criterion.Type.IPV6_DST)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
criterionMap.remove(Criterion.Type.IPV6_DST);
} else {
return null;
}
} else {
break;
}
case IPV6_FLABEL:
if (criterionMap.containsKey(Criterion.Type.IPV6_FLABEL)) {
if (((IPv6FlowLabelCriterion) criterionMap.get(Criterion.Type.IPV6_FLABEL)).flowLabel() == (((L3ModificationInstruction.ModIPv6FlowLabelInstruction) l3).flowLabel())) {
criterionMap.remove(Criterion.Type.IPV4_SRC);
} else {
return null;
}
} else {
break;
}
default:
break;
}
break;
}
case METADATA:
break;
default:
break;
}
}
for (Criterion criterion : criterionMap.values()) {
selectorBuilder.add(criterion);
}
return selectorBuilder.build();
}
use of org.onosproject.net.flow.instructions.L2ModificationInstruction in project onos by opennetworkinglab.
the class HPPipelineV3800 method checkUnSupportedFeatures.
// Return TRUE if ForwardingObjective fwd includes UNSUPPORTED features
@Override
protected boolean checkUnSupportedFeatures(TrafficSelector selector, TrafficTreatment treatment) {
boolean unsupportedFeatures = false;
for (Criterion criterion : selector.criteria()) {
if (this.unsupportedCriteria.contains(criterion.type())) {
log.warn("HP V3800 Driver - unsupported criteria {}", criterion.type());
unsupportedFeatures = true;
}
}
for (Instruction instruction : treatment.allInstructions()) {
if (this.unsupportedInstructions.contains(instruction.type())) {
log.warn("HP V3800 Driver - unsupported instruction {}", instruction.type());
unsupportedFeatures = true;
}
if (instruction.type() == Instruction.Type.L2MODIFICATION) {
if (this.unsupportedL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
log.warn("HP V3800 Driver - unsupported L2MODIFICATION instruction {}", ((L2ModificationInstruction) instruction).subtype());
unsupportedFeatures = true;
}
}
if (instruction.type() == Instruction.Type.L3MODIFICATION) {
if (this.unsupportedL3mod.contains(((L3ModificationInstruction) instruction).subtype())) {
log.warn("HP V3800 Driver - unsupported L3MODIFICATION instruction {}", ((L3ModificationInstruction) instruction).subtype());
unsupportedFeatures = true;
}
}
}
return unsupportedFeatures;
}
use of org.onosproject.net.flow.instructions.L2ModificationInstruction in project onos by opennetworkinglab.
the class HPPipelineV3800 method tableIdForForwardingObjective.
@Override
protected int tableIdForForwardingObjective(TrafficSelector selector, TrafficTreatment treatment) {
boolean hardwareProcess = true;
log.debug("HP V3800 Driver - Evaluating the ForwardingObjective for proper TableID");
// Check criteria supported in hardware
for (Criterion criterion : selector.criteria()) {
if (!this.hardwareCriteria.contains(criterion.type())) {
log.warn("HP V3800 Driver - criterion {} only supported in SOFTWARE", criterion.type());
hardwareProcess = false;
break;
}
// HP3800 does not support hardware match on ETH_TYPE of value TYPE_VLAN
if (criterion.type() == Criterion.Type.ETH_TYPE) {
if (((EthTypeCriterion) criterion).ethType().toShort() == Ethernet.TYPE_VLAN) {
log.warn("HP V3800 Driver - ETH_TYPE == VLAN (0x8100) is only supported in software");
hardwareProcess = false;
break;
}
}
}
// Check if a CLEAR action is included
if (treatment.clearedDeferred()) {
log.warn("HP V3800 Driver - CLEAR action only supported in SOFTWARE");
hardwareProcess = false;
}
// If criteria can be processed in hardware, then check treatment
if (hardwareProcess) {
for (Instruction instruction : treatment.allInstructions()) {
// Check if the instruction type is contained in the hardware instruction
if (!this.hardwareInstructions.contains(instruction.type())) {
log.warn("HP V3800 Driver - instruction {} only supported in SOFTWARE", instruction.type());
hardwareProcess = false;
break;
}
/**
* If output is CONTROLLER_PORT the flow entry could be installed in hardware
* but is anyway processed in software because OPENFLOW header has to be added
*/
if (instruction.type() == Instruction.Type.OUTPUT) {
if (((Instructions.OutputInstruction) instruction).port() == PortNumber.CONTROLLER) {
log.warn("HP V3800 Driver - Forwarding to CONTROLLER only supported in software");
hardwareProcess = false;
break;
}
}
// Check if the specific L2MODIFICATION.subtype is supported in hardware
if (instruction.type() == Instruction.Type.L2MODIFICATION) {
if (!this.hardwareInstructionsL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
log.warn("HP V3800 Driver - L2MODIFICATION.subtype {} only supported in SOFTWARE", ((L2ModificationInstruction) instruction).subtype());
hardwareProcess = false;
break;
}
}
// TODO --- check if all the buckets contains one and only one output action
if (instruction.type() == Instruction.Type.GROUP) {
boolean groupInstalled = false;
GroupId groupId = ((Instructions.GroupInstruction) instruction).groupId();
Iterable<Group> groupsOnDevice = groupService.getGroups(deviceId);
for (Group group : groupsOnDevice) {
if ((group.state() == Group.GroupState.ADDED) && (group.id().equals(groupId))) {
groupInstalled = true;
if (group.type() != Group.Type.ALL) {
log.warn("HP V3800 Driver - group type {} only supported in SOFTWARE", group.type().toString());
hardwareProcess = false;
}
break;
}
}
if (!groupInstalled) {
log.warn("HP V3800 Driver - referenced group is not installed on the device.");
hardwareProcess = false;
}
}
}
}
if (hardwareProcess) {
log.warn("HP V3800 Driver - This flow rule is supported in HARDWARE");
return HP_HARDWARE_TABLE;
} else {
// TODO: create a specific flow in table 100 to redirect selected traffic on table 200
log.warn("HP V3800 Driver - This flow rule is only supported in SOFTWARE");
return HP_SOFTWARE_TABLE;
}
}
use of org.onosproject.net.flow.instructions.L2ModificationInstruction in project onos by opennetworkinglab.
the class HPPipelineV1 method tableIdForForwardingObjective.
@Override
protected int tableIdForForwardingObjective(TrafficSelector selector, TrafficTreatment treatment) {
boolean hardwareProcess = true;
log.debug("HP V1 Driver - Evaluating the ForwardingObjective for proper TableID");
// Check criteria supported in hardware
for (Criterion criterion : selector.criteria()) {
if (!this.hardwareCriteria.contains(criterion.type())) {
log.warn("HP V1 Driver - criterion {} only supported in SOFTWARE", criterion.type());
hardwareProcess = false;
break;
}
// HP3500 supports hardware match on ETH_TYPE only with value TYPE_IPV4
if (criterion.type() == Criterion.Type.ETH_TYPE) {
if (((EthTypeCriterion) criterion).ethType().toShort() != Ethernet.TYPE_IPV4) {
log.warn("HP V1 Driver - only ETH_TYPE == IPv4 (0x0800) is supported in hardware");
hardwareProcess = false;
break;
}
}
// HP3500 supports IN_PORT criterion in hardware only if associated with ETH_TYPE criterion
if (criterion.type() == Criterion.Type.IN_PORT) {
hardwareProcess = false;
for (Criterion requiredCriterion : selector.criteria()) {
if (requiredCriterion.type() == Criterion.Type.ETH_TYPE) {
hardwareProcess = true;
}
}
if (!hardwareProcess) {
log.warn("HP V1 Driver - IN_PORT criterion without ETH_TYPE is not supported in hardware");
break;
}
}
}
// Check if a CLEAR action is included
if (treatment.clearedDeferred()) {
log.warn("HP V1 Driver - CLEAR action only supported in SOFTWARE");
hardwareProcess = false;
}
// If criteria can be processed in hardware, then check treatment
if (hardwareProcess) {
for (Instruction instruction : treatment.allInstructions()) {
// Check if the instruction type is contained in the hardware instruction
if (!this.hardwareInstructions.contains(instruction.type())) {
log.warn("HP V1 Driver - instruction {} only supported in SOFTWARE", instruction.type());
hardwareProcess = false;
break;
}
/**
* If output is CONTROLLER_PORT the flow entry could be installed in hardware
* but is anyway processed in software because openflow header has to be added
*/
if (instruction.type() == Instruction.Type.OUTPUT) {
if (((Instructions.OutputInstruction) instruction).port() == PortNumber.CONTROLLER) {
log.warn("HP V1 Driver - Forwarding to CONTROLLER only supported in software");
hardwareProcess = false;
break;
}
}
/**
* Only L2MODIFICATION supported in hardware is MODIFY VLAN_PRIORITY.
* Check if the specific L2MODIFICATION.subtype is supported in hardware
*/
if (instruction.type() == Instruction.Type.L2MODIFICATION) {
if (!this.hardwareInstructionsL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
log.warn("HP V1 Driver - L2MODIFICATION.subtype {} only supported in SOFTWARE", ((L2ModificationInstruction) instruction).subtype());
hardwareProcess = false;
break;
}
}
}
}
if (hardwareProcess) {
log.warn("HP V1 Driver - This flow rule is supported in HARDWARE");
return HP_HARDWARE_TABLE;
} else {
// TODO: create a specific flow in table 100 to redirect selected traffic on table 200
log.warn("HP V1 Driver - This flow rule is only supported in SOFTWARE");
return HP_SOFTWARE_TABLE;
}
}
Aggregations