Search in sources :

Example 1 with OFFlowDelete

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

the class SwitchManager method deleteAllNonDefaultRules.

@Override
public List<Long> deleteAllNonDefaultRules(final DatapathId dpid) throws SwitchOperationException {
    OFFlowStatsReply flowStats = dumpFlowTable(dpid);
    IOFSwitch sw = lookupSwitch(dpid);
    OFFactory ofFactory = sw.getOFFactory();
    List<Long> removedRules = new ArrayList<>();
    for (OFFlowStatsEntry flowStatsEntry : flowStats.getEntries()) {
        long flowCookie = flowStatsEntry.getCookie().getValue();
        if (flowCookie != DROP_RULE_COOKIE && flowCookie != VERIFICATION_BROADCAST_RULE_COOKIE && flowCookie != VERIFICATION_UNICAST_RULE_COOKIE) {
            OFFlowDelete flowDelete = ofFactory.buildFlowDelete().setCookie(U64.of(flowCookie)).setCookieMask(NON_SYSTEM_MASK).build();
            pushFlow(sw, "--DeleteFlow--", flowDelete);
            removedRules.add(flowCookie);
        }
    }
    return removedRules;
}
Also used : OFFlowStatsEntry(org.projectfloodlight.openflow.protocol.OFFlowStatsEntry) OFFlowDelete(org.projectfloodlight.openflow.protocol.OFFlowDelete) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) ArrayList(java.util.ArrayList) OFFlowStatsReply(org.projectfloodlight.openflow.protocol.OFFlowStatsReply)

Example 2 with OFFlowDelete

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

the class SwitchManager method deleteFlow.

// Utility Methods
/**
 * {@inheritDoc}
 */
@Override
public long deleteFlow(final DatapathId dpid, final String flowId, final Long cookie) throws SwitchOperationException {
    logger.info("deleting flows {} from switch {}", flowId, dpid.toString());
    IOFSwitch sw = lookupSwitch(dpid);
    OFFactory ofFactory = sw.getOFFactory();
    OFFlowDelete flowDelete = ofFactory.buildFlowDelete().setCookie(U64.of(cookie)).setCookieMask(NON_SYSTEM_MASK).build();
    return pushFlow(sw, "--DeleteFlow--", flowDelete);
}
Also used : OFFlowDelete(org.projectfloodlight.openflow.protocol.OFFlowDelete) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory)

Example 3 with OFFlowDelete

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

Aggregations

OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)3 OFFlowDelete (org.projectfloodlight.openflow.protocol.OFFlowDelete)3 ArrayList (java.util.ArrayList)1 OFFlowStatsEntry (org.projectfloodlight.openflow.protocol.OFFlowStatsEntry)1 OFFlowStatsReply (org.projectfloodlight.openflow.protocol.OFFlowStatsReply)1