Search in sources :

Example 31 with BoundServices

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices in project genius by opendaylight.

the class FlowBasedServicesUtils method installEgressDispatcherSplitHorizonFlow.

public static void installEgressDispatcherSplitHorizonFlow(BigInteger dpId, BoundServices boundService, String interfaceName, WriteTransaction writeTransaction, int interfaceTag, short currentServiceIndex, Interface iface) {
    // only install split horizon drop flows for external interfaces
    if (!isExternal(iface)) {
        return;
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Installing split horizon drop flow for external interface {} on dpId {}", interfaceName, dpId);
    }
    // BigInteger.ONE is used for
    BigInteger shFlagSet = BigInteger.ONE;
    // checking the Split-Horizon
    // flag
    List<MatchInfoBase> shMatches = FlowBasedServicesUtils.getMatchInfoForEgressDispatcherTable(interfaceTag, currentServiceIndex);
    shMatches.add(new MatchMetadata(shFlagSet, MetaDataUtil.METADATA_MASK_SH_FLAG));
    List<InstructionInfo> shInstructions = new ArrayList<>();
    List<ActionInfo> actionsInfos = new ArrayList<>();
    actionsInfos.add(new ActionDrop());
    shInstructions.add(new InstructionApplyActions(actionsInfos));
    String flowRef = getSplitHorizonFlowRef(dpId, NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, interfaceName, shFlagSet);
    String serviceRef = boundService.getServiceName();
    // This must be higher priority than the egress flow
    int splitHorizonFlowPriority = boundService.getServicePriority() + 1;
    StypeOpenflow stypeOpenFlow = boundService.getAugmentation(StypeOpenflow.class);
    Flow egressSplitHorizonFlow = MDSALUtil.buildFlow(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, flowRef, splitHorizonFlowPriority, serviceRef, 0, 0, stypeOpenFlow.getFlowCookie(), shMatches, shInstructions);
    installFlow(dpId, egressSplitHorizonFlow, writeTransaction);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) StypeOpenflow(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflow) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) BigInteger(java.math.BigInteger) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 32 with BoundServices

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices in project genius by opendaylight.

the class FlowBasedServicesUtils method removeLPortDispatcherFlow.

public static void removeLPortDispatcherFlow(BigInteger dpId, String iface, BoundServices boundServicesOld, WriteTransaction writeTransaction, short currentServiceIndex) {
    LOG.debug("Removing LPort Dispatcher Flows {}, {}", dpId, iface);
    boundServicesOld.getAugmentation(StypeOpenflow.class);
    // build the flow and install it
    String flowRef = getFlowRef(dpId, NwConstants.LPORT_DISPATCHER_TABLE, iface, currentServiceIndex);
    FlowKey flowKey = new FlowKey(new FlowId(flowRef));
    Node nodeDpn = buildInventoryDpnNode(dpId);
    InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(NwConstants.LPORT_DISPATCHER_TABLE)).child(Flow.class, flowKey).build();
    writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 33 with BoundServices

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices in project genius by opendaylight.

the class FlowBasedServicesUtils method installInterfaceIngressFlow.

public static void installInterfaceIngressFlow(BigInteger dpId, Interface iface, BoundServices boundServiceNew, WriteTransaction writeTransaction, List<MatchInfo> matches, int lportTag, short tableId) {
    List<Instruction> instructions = boundServiceNew.getAugmentation(StypeOpenflow.class).getInstruction();
    int serviceInstructionsSize = instructions != null ? instructions.size() : 0;
    List<Instruction> instructionSet = new ArrayList<>();
    int vlanId = 0;
    IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
    if (l2vlan != null && l2vlan.getVlanId() != null) {
        vlanId = l2vlan.getVlanId().getValue();
    }
    if (vlanId != 0) {
        // incrementing instructionSize and using it as actionKey. Because
        // it won't clash with any other instructions
        int actionKey = ++serviceInstructionsSize;
        instructionSet.add(MDSALUtil.buildAndGetPopVlanActionInstruction(actionKey, ++serviceInstructionsSize));
    }
    if (lportTag != 0L) {
        BigInteger[] metadataValues = IfmUtil.mergeOpenflowMetadataWriteInstructions(instructions);
        short index = boundServiceNew.getServicePriority();
        BigInteger metadata = MetaDataUtil.getMetaDataForLPortDispatcher(lportTag, ++index, metadataValues[0], isExternal(iface));
        BigInteger metadataMask = MetaDataUtil.getMetaDataMaskForLPortDispatcher(MetaDataUtil.METADATA_MASK_SERVICE_INDEX, MetaDataUtil.METADATA_MASK_LPORT_TAG_SH_FLAG, metadataValues[1]);
        instructionSet.add(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, ++serviceInstructionsSize));
    }
    if (instructions != null && !instructions.isEmpty()) {
        for (Instruction info : instructions) {
            // Skip meta data write as that is handled already
            if (info.getInstruction() instanceof WriteMetadataCase) {
                continue;
            } else if (info.getInstruction() instanceof WriteActionsCase) {
                info = MDSALUtil.buildWriteActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((WriteActionsCase) info.getInstruction()).getWriteActions().getAction()));
            } else if (info.getInstruction() instanceof ApplyActionsCase) {
                info = MDSALUtil.buildApplyActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((ApplyActionsCase) info.getInstruction()).getApplyActions().getAction()));
            }
            instructionSet.add(info);
        }
    }
    String serviceRef = boundServiceNew.getServiceName();
    String flowRef = getFlowRef(dpId, NwConstants.VLAN_INTERFACE_INGRESS_TABLE, iface.getName(), boundServiceNew.getServicePriority());
    StypeOpenflow stypeOpenflow = boundServiceNew.getAugmentation(StypeOpenflow.class);
    Flow ingressFlow = MDSALUtil.buildFlowNew(tableId, flowRef, stypeOpenflow.getFlowPriority(), serviceRef, 0, 0, stypeOpenflow.getFlowCookie(), matches, instructionSet);
    installFlow(dpId, ingressFlow, writeTransaction);
}
Also used : WriteMetadataCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase) StypeOpenflow(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflow) ArrayList(java.util.ArrayList) WriteActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) BigInteger(java.math.BigInteger) ApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 34 with BoundServices

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices in project genius by opendaylight.

the class FlowBasedServicesUtils method removeIngressFlow.

public static void removeIngressFlow(String name, BoundServices serviceOld, BigInteger dpId, WriteTransaction writeTransaction) {
    String flowKeyStr = getFlowRef(dpId, NwConstants.VLAN_INTERFACE_INGRESS_TABLE, name, serviceOld.getServicePriority());
    LOG.debug("Removing Ingress Flow {}", flowKeyStr);
    FlowKey flowKey = new FlowKey(new FlowId(flowKeyStr));
    Node nodeDpn = buildInventoryDpnNode(dpId);
    InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(NwConstants.VLAN_INTERFACE_INGRESS_TABLE)).child(Flow.class, flowKey).build();
    writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 35 with BoundServices

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices in project genius by opendaylight.

the class FlowBasedServicesUtils method installEgressDispatcherFlow.

private static void installEgressDispatcherFlow(BigInteger dpId, BoundServices boundService, String interfaceName, WriteTransaction writeTransaction, int interfaceTag, short currentServiceIndex, short nextServiceIndex) {
    // Get the metadata and mask from the service's write metadata instruction
    StypeOpenflow stypeOpenflow = boundService.getAugmentation(StypeOpenflow.class);
    if (stypeOpenflow == null) {
        LOG.warn("Could not install egress dispatcher flow, missing service openflow configuration");
        return;
    }
    List<Instruction> serviceInstructions = stypeOpenflow.getInstruction() != null ? stypeOpenflow.getInstruction() : Collections.emptyList();
    // build the final instruction for LPort Dispatcher table flow entry
    List<Action> finalApplyActions = new ArrayList<>();
    List<Instruction> instructions = new ArrayList<>();
    if (boundService.getServicePriority() != ServiceIndex.getIndex(NwConstants.DEFAULT_EGRESS_SERVICE_NAME, NwConstants.DEFAULT_EGRESS_SERVICE_INDEX)) {
        BigInteger[] metadataValues = IfmUtil.mergeOpenflowMetadataWriteInstructions(serviceInstructions);
        BigInteger metadataMask = MetaDataUtil.getWriteMetaDataMaskForEgressDispatcherTable();
        instructions.add(MDSALUtil.buildAndGetWriteMetadaInstruction(metadataValues[0], metadataMask, instructions.size()));
        finalApplyActions.add(MDSALUtil.createSetReg6Action(finalApplyActions.size(), 0, 31, MetaDataUtil.getReg6ValueForLPortDispatcher(interfaceTag, nextServiceIndex)));
    }
    final int applyActionsOffset = finalApplyActions.size();
    for (Instruction info : serviceInstructions) {
        if (info.getInstruction() instanceof WriteActionsCase) {
            List<Action> writeActions = ActionConverterUtil.convertServiceActionToFlowAction(((WriteActionsCase) info.getInstruction()).getWriteActions().getAction());
            instructions.add(MDSALUtil.buildWriteActionsInstruction(writeActions, instructions.size()));
        } else if (info.getInstruction() instanceof ApplyActionsCase) {
            List<Action> applyActions = ActionConverterUtil.convertServiceActionToFlowAction(((ApplyActionsCase) info.getInstruction()).getApplyActions().getAction(), applyActionsOffset);
            finalApplyActions.addAll(applyActions);
        } else if (!(info.getInstruction() instanceof WriteMetadataCase)) {
            // Skip meta data write as that is handled already
            instructions.add(MDSALUtil.buildInstruction(info, instructions.size()));
        }
    }
    if (!finalApplyActions.isEmpty()) {
        instructions.add(MDSALUtil.buildApplyActionsInstruction(finalApplyActions, instructions.size()));
    }
    // build the flow and install it
    String serviceRef = boundService.getServiceName();
    List<? extends MatchInfoBase> matches = FlowBasedServicesUtils.getMatchInfoForEgressDispatcherTable(interfaceTag, currentServiceIndex);
    String flowRef = getFlowRef(dpId, NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, interfaceName, currentServiceIndex);
    Flow egressFlow = MDSALUtil.buildFlowNew(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, flowRef, boundService.getServicePriority(), serviceRef, 0, 0, stypeOpenflow.getFlowCookie(), matches, instructions);
    LOG.debug("Installing Egress Dispatcher Flow for interface : {}, with flow-ref : {}", interfaceName, flowRef);
    installFlow(dpId, egressFlow, writeTransaction);
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) WriteMetadataCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase) StypeOpenflow(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflow) ArrayList(java.util.ArrayList) WriteActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) BigInteger(java.math.BigInteger) List(java.util.List) BoundServicesStateList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.BoundServicesStateList) ArrayList(java.util.ArrayList) ApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase)

Aggregations

BoundServices (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices)32 ArrayList (java.util.ArrayList)18 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)16 BigInteger (java.math.BigInteger)14 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)8 List (java.util.List)6 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)5 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)5 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)4 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)4 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)4 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)4 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)4 StypeOpenflow (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflow)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)3 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)3