Search in sources :

Example 1 with OFInstructionApplyActions

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);
}
Also used : OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ArrayList(java.util.ArrayList) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Example 2 with OFInstructionApplyActions

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();
}
Also used : OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OFInstructionMeter(org.projectfloodlight.openflow.protocol.instruction.OFInstructionMeter) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ArrayList(java.util.ArrayList) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Example 3 with OFInstructionApplyActions

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);
}
Also used : OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ArrayList(java.util.ArrayList) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Example 4 with OFInstructionApplyActions

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);
}
Also used : OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ArrayList(java.util.ArrayList) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Example 5 with OFInstructionApplyActions

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);
}
Also used : OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OFInstructionMeter(org.projectfloodlight.openflow.protocol.instruction.OFInstructionMeter) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ArrayList(java.util.ArrayList) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Aggregations

OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)6 OFInstructionApplyActions (org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions)6 ArrayList (java.util.ArrayList)5 OFFlowMod (org.projectfloodlight.openflow.protocol.OFFlowMod)5 Match (org.projectfloodlight.openflow.protocol.match.Match)5 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)5 OFInstructionMeter (org.projectfloodlight.openflow.protocol.instruction.OFInstructionMeter)3 HashMap (java.util.HashMap)1 OFActionType (org.projectfloodlight.openflow.protocol.OFActionType)1 OFInstructionType (org.projectfloodlight.openflow.protocol.OFInstructionType)1 OFActionOutput (org.projectfloodlight.openflow.protocol.action.OFActionOutput)1 OFActionPushVlan (org.projectfloodlight.openflow.protocol.action.OFActionPushVlan)1 OFActionSetField (org.projectfloodlight.openflow.protocol.action.OFActionSetField)1 OFInstruction (org.projectfloodlight.openflow.protocol.instruction.OFInstruction)1