use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions in project open-kilda by telstra.
the class SwitchManager method installTransitFlow.
/**
* {@inheritDoc}
*/
@Override
public long installTransitFlow(final DatapathId dpid, final String flowId, final Long cookie, final int inputPort, final int outputPort, final int transitVlanId) throws SwitchOperationException {
List<OFAction> actionList = new ArrayList<>();
IOFSwitch sw = lookupSwitch(dpid);
// build match by input port and transit vlan id
Match match = matchFlow(sw, inputPort, transitVlanId);
// transmit packet from outgoing port
actionList.add(actionSetOutputPort(sw, outputPort));
// build instruction with action list
OFInstructionApplyActions actions = buildInstructionApplyActions(sw, actionList);
// build FLOW_MOD command, no meter
OFFlowMod flowMod = buildFlowMod(sw, match, null, actions, cookie & FLOW_COOKIE_MASK, FlowModUtils.PRIORITY_VERY_HIGH);
return pushFlow(sw, flowId, flowMod);
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions in project open-kilda by telstra.
the class SwitchManager method installOneSwitchFlow.
/**
* {@inheritDoc}
*/
@Override
public long installOneSwitchFlow(final DatapathId dpid, final String flowId, final Long cookie, final int inputPort, final int outputPort, final int inputVlanId, final int outputVlanId, final OutputVlanType outputVlanType, final long meterId) throws SwitchOperationException {
// TODO: As per other locations, how different is this to IngressFlow? Why separate code path?
// As with any set of tests, the more we test the same code path, the better.
// Based on brief glance, this looks 90% the same as IngressFlow.
List<OFAction> actionList = new ArrayList<>();
IOFSwitch sw = lookupSwitch(dpid);
// build match by input port and transit vlan id
Match match = matchFlow(sw, inputPort, inputVlanId);
// build meter instruction
OFInstructionMeter meter = null;
if (meterId != 0L && !OVS_MANUFACTURER.equals(sw.getSwitchDescription().getManufacturerDescription())) {
if (sw.getOFFactory().getVersion().compareTo(OF_12) <= 0) {
actionList.add(legacyMeterAction(sw, meterId));
} else if (sw.getOFFactory().getVersion().compareTo(OF_15) == 0) {
actionList.add(sw.getOFFactory().actions().buildMeter().setMeterId(meterId).build());
} else /* OF_13, OF_14 */
{
meter = sw.getOFFactory().instructions().buildMeter().setMeterId(meterId).build();
}
}
// output action based on encap scheme
actionList.addAll(pushSchemeOutputVlanTypeToOFActionList(sw, outputVlanId, outputVlanType));
// transmit packet from outgoing port
actionList.add(actionSetOutputPort(sw, outputPort));
// build instruction with action list
OFInstructionApplyActions actions = buildInstructionApplyActions(sw, actionList);
// build FLOW_MOD command with meter
OFFlowMod flowMod = buildFlowMod(sw, match, meter, actions, cookie & FLOW_COOKIE_MASK, FlowModUtils.PRIORITY_VERY_HIGH);
pushFlow(sw, flowId, flowMod);
return flowMod.getXid();
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions in project open-kilda by telstra.
the class SwitchManager method installVerificationRule.
/**
* {@inheritDoc}
*/
@Override
public void installVerificationRule(final DatapathId dpid, final boolean isBroadcast) throws SwitchOperationException {
IOFSwitch sw = lookupSwitch(dpid);
// Don't install the unicast for OpenFlow 1.2 doesn't work properly
if (!isBroadcast) {
if (sw.getOFFactory().getVersion().compareTo(OF_12) > 0) {
logger.debug("installing unicast verification match for {}", dpid.toString());
} else {
logger.debug("not installing unicast verification match for {}", dpid.toString());
return;
}
}
logger.debug("installing verification rule for {}", dpid.toString());
Match match = matchVerification(sw, isBroadcast);
ArrayList<OFAction> actionList = new ArrayList<>(2);
actionList.add(actionSendToController(sw));
actionList.add(actionSetDstMac(sw, dpidToMac(sw)));
OFInstructionApplyActions instructionApplyActions = sw.getOFFactory().instructions().applyActions(actionList).createBuilder().build();
final long cookie = isBroadcast ? VERIFICATION_BROADCAST_RULE_COOKIE : VERIFICATION_UNICAST_RULE_COOKIE;
OFFlowMod flowMod = buildFlowMod(sw, match, null, instructionApplyActions, cookie, FlowModUtils.PRIORITY_VERY_HIGH);
String flowname = (isBroadcast) ? "Broadcast" : "Unicast";
flowname += "--VerificationFlow--" + dpid.toString();
pushFlow(sw, flowname, flowMod);
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions in project open-kilda by telstra.
the class SwitchManager method installEgressFlow.
/**
* {@inheritDoc}
*/
@Override
public long installEgressFlow(final DatapathId dpid, String flowId, final Long cookie, final int inputPort, final int outputPort, final int transitVlanId, final int outputVlanId, final OutputVlanType outputVlanType) throws SwitchOperationException {
List<OFAction> actionList = new ArrayList<>();
IOFSwitch sw = lookupSwitch(dpid);
// build match by input port and transit vlan id
Match match = matchFlow(sw, inputPort, transitVlanId);
// output action based on encap scheme
actionList.addAll(outputVlanTypeToOFActionList(sw, outputVlanId, outputVlanType));
// transmit packet from outgoing port
actionList.add(actionSetOutputPort(sw, outputPort));
// build instruction with action list
OFInstructionApplyActions actions = buildInstructionApplyActions(sw, actionList);
// build FLOW_MOD command, no meter
OFFlowMod flowMod = buildFlowMod(sw, match, null, actions, cookie & FLOW_COOKIE_MASK, FlowModUtils.PRIORITY_VERY_HIGH);
return pushFlow(sw, "--InstallEgressFlow--", flowMod);
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions in project open-kilda by telstra.
the class SwitchManager method installIngressFlow.
/**
* {@inheritDoc}
*/
@Override
public long installIngressFlow(final DatapathId dpid, final String flowId, final Long cookie, final int inputPort, final int outputPort, final int inputVlanId, final int transitVlanId, final OutputVlanType outputVlanType, final long meterId) throws SwitchOperationException {
List<OFAction> actionList = new ArrayList<>();
IOFSwitch sw = lookupSwitch(dpid);
// build match by input port and input vlan id
Match match = matchFlow(sw, inputPort, inputVlanId);
// build meter instruction
OFInstructionMeter meter = null;
if (meterId != 0L && !OVS_MANUFACTURER.equals(sw.getSwitchDescription().getManufacturerDescription())) {
if (sw.getOFFactory().getVersion().compareTo(OF_12) <= 0) {
actionList.add(legacyMeterAction(sw, meterId));
} else if (sw.getOFFactory().getVersion().compareTo(OF_15) == 0) {
actionList.add(sw.getOFFactory().actions().buildMeter().setMeterId(meterId).build());
} else /* OF_13, OF_14 */
{
meter = sw.getOFFactory().instructions().buildMeter().setMeterId(meterId).build();
}
}
// output action based on encap scheme
actionList.addAll(inputVlanTypeToOFActionList(sw, transitVlanId, outputVlanType));
// transmit packet from outgoing port
actionList.add(actionSetOutputPort(sw, outputPort));
// build instruction with action list
OFInstructionApplyActions actions = buildInstructionApplyActions(sw, actionList);
// build FLOW_MOD command with meter
OFFlowMod flowMod = buildFlowMod(sw, match, meter, actions, cookie & FLOW_COOKIE_MASK, FlowModUtils.PRIORITY_VERY_HIGH);
return pushFlow(sw, "--InstallIngressFlow--", flowMod);
}
Aggregations