Search in sources :

Example 1 with RuleType

use of org.openkilda.messaging.command.flow.RuleType in project open-kilda by telstra.

the class SwitchManager method deleteRulesByCriteria.

@Override
public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException {
    List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid);
    IOFSwitch sw = lookupSwitch(dpid);
    OFFactory ofFactory = sw.getOFFactory();
    for (DeleteRulesCriteria criteriaEntry : criteria) {
        OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType);
        logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid);
        pushFlow(sw, "--DeleteFlow--", dropFlowDelete);
    }
    // Wait for OFFlowDelete to be processed.
    sendBarrierRequest(sw);
    List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid);
    Set<Long> cookiesAfter = flowStatsAfter.stream().map(entry -> entry.getCookie().getValue()).collect(Collectors.toSet());
    return flowStatsBefore.stream().map(entry -> entry.getCookie().getValue()).filter(cookie -> !cookiesAfter.contains(cookie)).peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)).collect(toList());
}
Also used : OFFlowStatsEntry(org.projectfloodlight.openflow.protocol.OFFlowStatsEntry) TableId(org.projectfloodlight.openflow.types.TableId) U64(org.projectfloodlight.openflow.types.U64) Arrays(java.util.Arrays) DEFAULT_METERS(org.openkilda.model.MeterId.DEFAULT_METERS) OFPortMod(org.projectfloodlight.openflow.protocol.OFPortMod) MeteredFlowGenerator(org.openkilda.floodlight.switchmanager.factory.generator.MeteredFlowGenerator) DROP_VERIFICATION_LOOP_RULE_COOKIE(org.openkilda.model.cookie.Cookie.DROP_VERIFICATION_LOOP_RULE_COOKIE) OFFlowStatsRequest(org.projectfloodlight.openflow.protocol.OFFlowStatsRequest) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) VERIFICATION_UNICAST_VXLAN_RULE_COOKIE(org.openkilda.model.cookie.Cookie.VERIFICATION_UNICAST_VXLAN_RULE_COOKIE) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) Collections.singletonList(java.util.Collections.singletonList) InetAddress(java.net.InetAddress) MULTITABLE_POST_INGRESS_DROP_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_POST_INGRESS_DROP_COOKIE) OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) Future(java.util.concurrent.Future) SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) OFGroupDescStatsRequest(org.projectfloodlight.openflow.protocol.OFGroupDescStatsRequest) OFMeterModCommand(org.projectfloodlight.openflow.protocol.OFMeterModCommand) Match(org.projectfloodlight.openflow.protocol.match.Match) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFGroupType(org.projectfloodlight.openflow.protocol.OFGroupType) OFBarrierReply(org.projectfloodlight.openflow.protocol.OFBarrierReply) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) OFGroupAdd(org.projectfloodlight.openflow.protocol.OFGroupAdd) OFMeterConfigStatsRequest(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsRequest) InvalidMeterIdException(org.openkilda.floodlight.error.InvalidMeterIdException) MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE) Set(java.util.Set) OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) RuleType(org.openkilda.messaging.command.flow.RuleType) IRestApiService(net.floodlightcontroller.restserver.IRestApiService) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) ROUND_TRIP_LATENCY_RULE_COOKIE(org.openkilda.model.cookie.Cookie.ROUND_TRIP_LATENCY_RULE_COOKIE) CorrelationContext(org.openkilda.floodlight.utils.CorrelationContext) Stream(java.util.stream.Stream) LLDP_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_INGRESS_COOKIE) Meter(org.openkilda.model.Meter) OF_12(org.projectfloodlight.openflow.protocol.OFVersion.OF_12) OF_13(org.projectfloodlight.openflow.protocol.OFVersion.OF_13) SwitchFlowUtils.isOvs(org.openkilda.floodlight.switchmanager.SwitchFlowUtils.isOvs) OFBufferId(org.projectfloodlight.openflow.types.OFBufferId) OFOxms(org.projectfloodlight.openflow.protocol.oxm.OFOxms) LLDP_POST_INGRESS_ONE_SWITCH_METER_ID(org.openkilda.model.MeterId.LLDP_POST_INGRESS_ONE_SWITCH_METER_ID) OFInstructionWriteMetadata(org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) LLDP_POST_INGRESS_VXLAN_METER_ID(org.openkilda.model.MeterId.LLDP_POST_INGRESS_VXLAN_METER_ID) CollectionUtils(org.apache.commons.collections4.CollectionUtils) VERIFICATION_UNICAST_VXLAN_METER_ID(org.openkilda.model.MeterId.VERIFICATION_UNICAST_VXLAN_METER_ID) ArrayList(java.util.ArrayList) EthType(org.projectfloodlight.openflow.types.EthType) Lists(com.google.common.collect.Lists) OFMeterFlags(org.projectfloodlight.openflow.protocol.OFMeterFlags) OFActionType(org.projectfloodlight.openflow.protocol.OFActionType) OFFlowStatsReply(org.projectfloodlight.openflow.protocol.OFFlowStatsReply) MacAddress(org.projectfloodlight.openflow.types.MacAddress) Cookie.isDefaultRule(org.openkilda.model.cookie.Cookie.isDefaultRule) SwitchFlowFactory(org.openkilda.floodlight.switchmanager.factory.SwitchFlowFactory) LLDP_TRANSIT_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_TRANSIT_COOKIE) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Builder(org.projectfloodlight.openflow.protocol.match.Match.Builder) ErrorType(org.openkilda.messaging.error.ErrorType) OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) SERVER_42_ISL_RTT_OUTPUT_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_ISL_RTT_OUTPUT_COOKIE) ARP_INPUT_PRE_DROP_METER_ID(org.openkilda.model.MeterId.ARP_INPUT_PRE_DROP_METER_ID) DROP_RULE_COOKIE(org.openkilda.model.cookie.Cookie.DROP_RULE_COOKIE) ARP_POST_INGRESS_VXLAN_METER_ID(org.openkilda.model.MeterId.ARP_POST_INGRESS_VXLAN_METER_ID) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) OFActions(org.projectfloodlight.openflow.protocol.action.OFActions) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) ExecutionException(java.util.concurrent.ExecutionException) KafkaUtilityService(org.openkilda.floodlight.service.kafka.KafkaUtilityService) NewCorrelationContextRequired(org.openkilda.floodlight.utils.NewCorrelationContextRequired) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata) FloodlightModuleConfigurationProvider(org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider) OFMeterBandDrop(org.projectfloodlight.openflow.protocol.meterband.OFMeterBandDrop) VERIFICATION_UNICAST_RULE_COOKIE(org.openkilda.model.cookie.Cookie.VERIFICATION_UNICAST_RULE_COOKIE) OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) IFloodlightService(net.floodlightcontroller.core.module.IFloodlightService) ARP_POST_INGRESS_METER_ID(org.openkilda.model.MeterId.ARP_POST_INGRESS_METER_ID) IpProtocol(org.projectfloodlight.openflow.types.IpProtocol) OFFlowDelete(org.projectfloodlight.openflow.protocol.OFFlowDelete) ARP_POST_INGRESS_ONE_SWITCH_METER_ID(org.openkilda.model.MeterId.ARP_POST_INGRESS_ONE_SWITCH_METER_ID) DatapathId(org.projectfloodlight.openflow.types.DatapathId) VERIFICATION_BROADCAST_RULE_COOKIE(org.openkilda.model.cookie.Cookie.VERIFICATION_BROADCAST_RULE_COOKIE) VERIFICATION_BROADCAST_METER_ID(org.openkilda.model.MeterId.VERIFICATION_BROADCAST_METER_ID) OFActionSetField(org.projectfloodlight.openflow.protocol.action.OFActionSetField) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) OfPortDescConverter(org.openkilda.floodlight.converter.OfPortDescConverter) ARP_POST_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.ARP_POST_INGRESS_COOKIE) DeleteRulesCriteria(org.openkilda.messaging.command.switches.DeleteRulesCriteria) KildaCore(org.openkilda.floodlight.KildaCore) SwitchFeature(org.openkilda.model.SwitchFeature) LLDP_POST_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_POST_INGRESS_COOKIE) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) ARP_INPUT_PRE_DROP_COOKIE(org.openkilda.model.cookie.Cookie.ARP_INPUT_PRE_DROP_COOKIE) SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) ARP_TRANSIT_METER_ID(org.openkilda.model.MeterId.ARP_TRANSIT_METER_ID) SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE) OFFlowStatsEntry(org.projectfloodlight.openflow.protocol.OFFlowStatsEntry) FlowModUtils(net.floodlightcontroller.util.FlowModUtils) TransportPort(org.projectfloodlight.openflow.types.TransportPort) ConnectModeRequest(org.openkilda.messaging.command.switches.ConnectModeRequest) LLDP_TRANSIT_METER_ID(org.openkilda.model.MeterId.LLDP_TRANSIT_METER_ID) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) Collectors.toSet(java.util.stream.Collectors.toSet) LLDP_POST_INGRESS_VXLAN_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_POST_INGRESS_VXLAN_COOKIE) OFGroupDelete(org.projectfloodlight.openflow.protocol.OFGroupDelete) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) ImmutableSet(com.google.common.collect.ImmutableSet) OFPortConfig(org.projectfloodlight.openflow.protocol.OFPortConfig) ImmutableMap(com.google.common.collect.ImmutableMap) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) LLDP_POST_INGRESS_METER_ID(org.openkilda.model.MeterId.LLDP_POST_INGRESS_METER_ID) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) NOVIFLOW_PUSH_POP_VXLAN(org.openkilda.model.SwitchFeature.NOVIFLOW_PUSH_POP_VXLAN) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) VERIFICATION_UNICAST_METER_ID(org.openkilda.model.MeterId.VERIFICATION_UNICAST_METER_ID) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) IOFMessageListener(net.floodlightcontroller.core.IOFMessageListener) Objects(java.util.Objects) OFPort(org.projectfloodlight.openflow.types.OFPort) MULTITABLE_EGRESS_PASS_THROUGH_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_EGRESS_PASS_THROUGH_COOKIE) List(java.util.List) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) SwitchFlowTuple(org.openkilda.floodlight.switchmanager.factory.SwitchFlowTuple) OFMetadata(org.projectfloodlight.openflow.types.OFMetadata) IFloodlightProviderService(net.floodlightcontroller.core.IFloodlightProviderService) Optional(java.util.Optional) ARP_POST_INGRESS_VXLAN_COOKIE(org.openkilda.model.cookie.Cookie.ARP_POST_INGRESS_VXLAN_COOKIE) OFType(org.projectfloodlight.openflow.protocol.OFType) ARP_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.ARP_INGRESS_COOKIE) OFGroup(org.projectfloodlight.openflow.types.OFGroup) MULTITABLE_TRANSIT_DROP_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_TRANSIT_DROP_COOKIE) SERVER_42_FLOW_RTT_TURNING_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_TURNING_COOKIE) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SwitchFlowGenerator(org.openkilda.floodlight.switchmanager.factory.generator.SwitchFlowGenerator) HashMap(java.util.HashMap) KILDA_OVS_PUSH_POP_MATCH_VXLAN(org.openkilda.model.SwitchFeature.KILDA_OVS_PUSH_POP_MATCH_VXLAN) ARP_POST_INGRESS_ONE_SWITCH_COOKIE(org.openkilda.model.cookie.Cookie.ARP_POST_INGRESS_ONE_SWITCH_COOKIE) CATCH_BFD_RULE_COOKIE(org.openkilda.model.cookie.Cookie.CATCH_BFD_RULE_COOKIE) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) MULTITABLE_INGRESS_DROP_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_INGRESS_DROP_COOKIE) IPathVerificationService(org.openkilda.floodlight.pathverification.IPathVerificationService) Cookie(org.openkilda.model.cookie.Cookie) OFErrorMsg(org.projectfloodlight.openflow.protocol.OFErrorMsg) OFBarrierRequest(org.projectfloodlight.openflow.protocol.OFBarrierRequest) SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE) FlowEncapsulationType(org.openkilda.model.FlowEncapsulationType) Logger(org.slf4j.Logger) POST_INGRESS(org.openkilda.messaging.command.flow.RuleType.POST_INGRESS) ARP_INGRESS_METER_ID(org.openkilda.model.MeterId.ARP_INGRESS_METER_ID) OFMeterConfigStatsReply(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply) ARP_TRANSIT_COOKIE(org.openkilda.model.cookie.Cookie.ARP_TRANSIT_COOKIE) LLDP_INPUT_PRE_DROP_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_INPUT_PRE_DROP_COOKIE) SwitchManagerWebRoutable(org.openkilda.floodlight.switchmanager.web.SwitchManagerWebRoutable) IPv4Address(org.projectfloodlight.openflow.types.IPv4Address) SwitchFlowUtils.convertDpIdToMac(org.openkilda.floodlight.switchmanager.SwitchFlowUtils.convertDpIdToMac) MeterId.createMeterIdForDefaultRule(org.openkilda.model.MeterId.createMeterIdForDefaultRule) FloodlightModuleException(net.floodlightcontroller.core.module.FloodlightModuleException) IFloodlightModule(net.floodlightcontroller.core.module.IFloodlightModule) MeterId(org.openkilda.model.MeterId) TimeUnit(java.util.concurrent.TimeUnit) OFGroupDescStatsReply(org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply) Collectors.toList(java.util.stream.Collectors.toList) SERVER_42_ISL_RTT_TURNING_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_ISL_RTT_TURNING_COOKIE) LLDP_INPUT_PRE_DROP_METER_ID(org.openkilda.model.MeterId.LLDP_INPUT_PRE_DROP_METER_ID) OfInstallException(org.openkilda.floodlight.error.OfInstallException) SwitchId(org.openkilda.model.SwitchId) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Destination(org.openkilda.messaging.Destination) MatchField(org.projectfloodlight.openflow.protocol.match.MatchField) LLDP_INGRESS_METER_ID(org.openkilda.model.MeterId.LLDP_INGRESS_METER_ID) VisibleForTesting(com.google.common.annotations.VisibleForTesting) LATENCY_PACKET_UDP_PORT(org.openkilda.floodlight.pathverification.PathVerificationService.LATENCY_PACKET_UDP_PORT) ErrorData(org.openkilda.messaging.error.ErrorData) GroupId(org.openkilda.model.GroupId) Collections(java.util.Collections) LLDP_POST_INGRESS_ONE_SWITCH_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_POST_INGRESS_ONE_SWITCH_COOKIE) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFFlowDelete(org.projectfloodlight.openflow.protocol.OFFlowDelete) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) DeleteRulesCriteria(org.openkilda.messaging.command.switches.DeleteRulesCriteria)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 String.format (java.lang.String.format)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1