Search in sources :

Example 6 with OFFactory

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

the class SwitchManager method deleteRuleWithCookie.

@Override
public List<Long> deleteRuleWithCookie(final DatapathId dpid, final List<Long> cookiesToRemove) throws SwitchOperationException {
    IOFSwitch sw = lookupSwitch(dpid);
    OFFactory ofFactory = sw.getOFFactory();
    for (long cookie : cookiesToRemove) {
        OFFlowDelete dropFlowDelete = ofFactory.buildFlowDelete().setCookie(U64.of(cookie)).build();
        pushFlow(sw, "--DeleteFlow--", dropFlowDelete);
    }
    // TODO: it'd be better to identify what was deleted and what wasn't there .. and confirm it is deleted.
    return cookiesToRemove;
}
Also used : OFFlowDelete(org.projectfloodlight.openflow.protocol.OFFlowDelete) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory)

Example 7 with OFFactory

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

the class SwitchManager method installLegacyMeter.

private long installLegacyMeter(final IOFSwitch sw, final DatapathId dpid, final long bandwidth, final long burstSize, final long meterId) throws OFInstallException {
    logger.debug("installing legacy meter {} on OVS switch {} width bandwidth {}", meterId, dpid, bandwidth);
    Set<OFLegacyMeterFlags> flags = new HashSet<>(asList(OFLegacyMeterFlags.KBPS, OFLegacyMeterFlags.BURST));
    OFFactory ofFactory = sw.getOFFactory();
    OFLegacyMeterBandDrop.Builder bandBuilder = ofFactory.legacyMeterBandDrop(bandwidth, burstSize).createBuilder();
    OFLegacyMeterMod meterMod = ofFactory.buildLegacyMeterMod().setMeterId(meterId).setCommand(OFLegacyMeterModCommand.ADD).setMeters(singletonList(bandBuilder.build())).setFlags(flags).build();
    return pushFlow(sw, "--InstallMeter", meterMod);
}
Also used : OFLegacyMeterFlags(org.projectfloodlight.openflow.protocol.OFLegacyMeterFlags) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFLegacyMeterBandDrop(org.projectfloodlight.openflow.protocol.OFLegacyMeterBandDrop) OFLegacyMeterMod(org.projectfloodlight.openflow.protocol.OFLegacyMeterMod) HashSet(java.util.HashSet)

Example 8 with OFFactory

use of org.projectfloodlight.openflow.protocol.OFFactory 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());
}
Also used : OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFFactoryVer12Mock(org.openkilda.floodlight.OFFactoryVer12Mock) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Test(org.junit.Test)

Example 9 with OFFactory

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

the class SwitchManager method installMeter.

private long installMeter(final IOFSwitch sw, final DatapathId dpid, final long bandwidth, final long burstSize, final long meterId) throws OFInstallException {
    logger.debug("installing meter {} on switch {} width bandwidth {}", meterId, dpid, bandwidth);
    Set<OFMeterFlags> flags = new HashSet<>(asList(OFMeterFlags.KBPS, OFMeterFlags.BURST));
    OFFactory ofFactory = sw.getOFFactory();
    OFMeterBandDrop.Builder bandBuilder = ofFactory.meterBands().buildDrop().setRate(bandwidth).setBurstSize(burstSize);
    OFMeterMod.Builder meterModBuilder = ofFactory.buildMeterMod().setMeterId(meterId).setCommand(OFMeterModCommand.ADD).setFlags(flags);
    if (sw.getOFFactory().getVersion().compareTo(OF_13) > 0) {
        meterModBuilder.setBands(singletonList(bandBuilder.build()));
    } else {
        meterModBuilder.setMeters(singletonList(bandBuilder.build()));
    }
    OFMeterMod meterMod = meterModBuilder.build();
    return pushFlow(sw, "--InstallMeter--", meterMod);
}
Also used : OFMeterFlags(org.projectfloodlight.openflow.protocol.OFMeterFlags) OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFMeterBandDrop(org.projectfloodlight.openflow.protocol.meterband.OFMeterBandDrop) HashSet(java.util.HashSet)

Example 10 with OFFactory

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

the class SwitchManager method deleteMeter.

public long deleteMeter(IOFSwitch sw, final DatapathId dpid, final long meterId) throws OFInstallException {
    logger.debug("deleting meter {} from switch {}", meterId, dpid);
    OFFactory ofFactory = sw.getOFFactory();
    OFMeterMod.Builder meterDeleteBuilder = ofFactory.buildMeterMod().setMeterId(meterId).setCommand(OFMeterModCommand.DELETE);
    if (sw.getOFFactory().getVersion().compareTo(OF_13) > 0) {
        meterDeleteBuilder.setBands(emptyList());
    } else {
        meterDeleteBuilder.setMeters(emptyList());
    }
    OFMeterMod meterDelete = meterDeleteBuilder.build();
    return pushFlow(sw, "--DeleteMeter--", meterDelete);
}
Also used : OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory)

Aggregations

OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)13 OFFlowDelete (org.projectfloodlight.openflow.protocol.OFFlowDelete)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 OFFlowStatsReply (org.projectfloodlight.openflow.protocol.OFFlowStatsReply)2 OFFlowStatsRequest (org.projectfloodlight.openflow.protocol.OFFlowStatsRequest)2 OFLegacyMeterMod (org.projectfloodlight.openflow.protocol.OFLegacyMeterMod)2 OFMeterMod (org.projectfloodlight.openflow.protocol.OFMeterMod)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 TimeUnit (java.util.concurrent.TimeUnit)1 Function (java.util.function.Function)1 Collectors.toList (java.util.stream.Collectors.toList)1 IFloodlightProviderService (net.floodlightcontroller.core.IFloodlightProviderService)1