use of org.projectfloodlight.openflow.protocol.OFFlowMod 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.OFFlowMod 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.OFFlowMod in project open-kilda by telstra.
the class SwitchManager method installDropFlow.
/**
* {@inheritDoc}
*/
@Override
public void installDropFlow(final DatapathId dpid) throws SwitchOperationException {
// TODO: leverage installDropFlowCustom
IOFSwitch sw = lookupSwitch(dpid);
OFFlowMod flowMod = buildFlowMod(sw, null, null, null, DROP_RULE_COOKIE, 1);
String flowName = "--DropRule--" + dpid.toString();
pushFlow(sw, flowName, flowMod);
}
use of org.projectfloodlight.openflow.protocol.OFFlowMod 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.OFFlowMod in project open-kilda by telstra.
the class SwitchManagerOF12Test method installTransitFlow.
@Test
public void installTransitFlow() throws Exception {
Capture<OFFlowMod> capture = prepareForInstallFlowOperation();
String flowId = "test-transit-flow-rule";
int inputPort = 2;
int outputPort = 4;
int transitVlanId = 512;
switchManager.installTransitFlow(switchDpId, flowId, commonFlowCookie, inputPort, outputPort, transitVlanId);
OFFactory referenceOfFactory = new OFFactoryVer12Mock();
OFFlowMod expected = referenceOfFactory.buildFlowAdd().setCookie(U64.of(commonFlowCookie).applyMask(U64.of(SwitchManager.FLOW_COOKIE_MASK))).setPriority(FlowModUtils.PRIORITY_VERY_HIGH).setMatch(referenceOfFactory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(inputPort)).setMasked(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(transitVlanId), OFVlanVidMatch.ofRawVid((short) 0x0FFF)).build()).setInstructions(singletonList(referenceOfFactory.instructions().applyActions(singletonList(referenceOfFactory.actions().buildOutput().setMaxLen(0xFFFFFFFF).setPort(OFPort.of(outputPort)).build())).createBuilder().build())).build();
assertEquals(expected, capture.getValue());
}
Aggregations