Search in sources :

Example 26 with Match

use of org.projectfloodlight.openflow.protocol.match.Match in project onos by opennetworkinglab.

the class FlowModBuilderVer10 method buildFlowAdd.

@Override
public OFFlowAdd buildFlowAdd() {
    Match match = buildMatch();
    List<OFAction> actions = buildActions();
    long cookie = flowRule().id().value();
    OFFlowAdd fm = factory().buildFlowAdd().setXid(xid).setCookie(U64.of(cookie)).setBufferId(OFBufferId.NO_BUFFER).setActions(actions).setMatch(match).setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM)).setPriority(flowRule().priority()).setHardTimeout(flowRule().hardTimeout()).build();
    return fm;
}
Also used : OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) Match(org.projectfloodlight.openflow.protocol.match.Match) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd)

Example 27 with Match

use of org.projectfloodlight.openflow.protocol.match.Match 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 28 with Match

use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.

the class SwitchManager method simpleDstMatch.

/**
 * A simple Match rule based on destination mac address and mask.
 * TODO: Could be generalized
 *
 * @param dstMac
 * @param dstMask
 * @return
 */
private Match simpleDstMatch(IOFSwitch sw, String dstMac, String dstMask) throws SwitchOperationException {
    Match match = null;
    if (dstMac != null && dstMask != null && dstMac.length() > 0 && dstMask.length() > 0) {
        Builder builder = sw.getOFFactory().buildMatch();
        builder.setMasked(MatchField.ETH_DST, MacAddress.of(dstMac), MacAddress.NO_MASK);
        match = builder.build();
    }
    return match;
}
Also used : Builder(org.projectfloodlight.openflow.protocol.match.Match.Builder) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Example 29 with Match

use of org.projectfloodlight.openflow.protocol.match.Match 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)

Example 30 with Match

use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.

the class SwitchManager method installDropFlowCustom.

/**
 * Installs custom drop rule .. ie cookie, priority, match
 *
 * @param dpid datapathId of switch
 * @param dstMac Destination Mac address to match on
 * @param dstMask Destination Mask to match on
 * @param cookie Cookie to use for this rule
 * @param priority Priority of the rule
 * @throws SwitchOperationException
 */
@Override
public void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask, final long cookie, final int priority) throws SwitchOperationException {
    IOFSwitch sw = lookupSwitch(dpid);
    Match match = simpleDstMatch(sw, dstMac, dstMask);
    OFFlowMod flowMod = buildFlowMod(sw, match, null, null, cookie, priority);
    String flowName = "--CustomDropRule--" + dpid.toString();
    pushFlow(sw, flowName, flowMod);
}
Also used : OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Aggregations

Match (org.projectfloodlight.openflow.protocol.match.Match)64 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)32 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)28 OFFlowMod (org.projectfloodlight.openflow.protocol.OFFlowMod)18 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)18 OFInstructionApplyActions (org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions)18 RoutingMetadata (org.openkilda.floodlight.utils.metadata.RoutingMetadata)10 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)8 OFInstructionGotoTable (org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable)7 ArrayList (java.util.ArrayList)6 OFFlowDelete (org.projectfloodlight.openflow.protocol.OFFlowDelete)6 OFInstruction (org.projectfloodlight.openflow.protocol.instruction.OFInstruction)6 SwitchFeature (org.openkilda.model.SwitchFeature)5 OFFactoryVer13 (org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13)5 HashSet (java.util.HashSet)4 Test (org.junit.Test)4 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)4 OFFlowAdd (org.projectfloodlight.openflow.protocol.OFFlowAdd)4 Builder (org.projectfloodlight.openflow.protocol.match.Match.Builder)3 U64 (org.projectfloodlight.openflow.types.U64)3