Search in sources :

Example 56 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ElanDmacUtils method buildDmacFlowForExternalRemoteMac.

/**
 * Builds a Flow to be programmed in a DPN's DMAC table. This method must be
 * used when the MAC is located in an External Device (TOR). The flow
 * matches on the specified MAC and 1) sends the packet over the CSS-TOR
 * tunnel if SHFlag is not set, or 2) drops it if SHFlag is set (what means
 * the packet came from an external tunnel)
 *
 * @param dpId
 *            DPN whose DMAC table is going to be modified
 * @param extDeviceNodeId
 *            Hwvtep node where the mac is attached to
 * @param elanTag
 *            ElanId to which the MAC is being added to
 * @param vni
 *            the vni
 * @param dstMacAddress
 *            The mac address to be programmed
 * @param displayName
 *            the display name
 * @return the flow
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public Flow buildDmacFlowForExternalRemoteMac(BigInteger dpId, String extDeviceNodeId, long elanTag, Long vni, String dstMacAddress, String displayName) {
    List<MatchInfo> mkMatches = ElanUtils.buildMatchesForElanTagShFlagAndDstMac(elanTag, /* shFlag */
    false, dstMacAddress);
    List<Instruction> mkInstructions = new ArrayList<>();
    try {
        List<Action> actions = elanItmUtils.getExternalTunnelItmEgressAction(dpId, new NodeId(extDeviceNodeId), vni);
        mkInstructions.add(MDSALUtil.buildApplyActionsInstruction(actions));
    } catch (Exception e) {
        LOG.error("Could not get Egress Actions for DpId {} externalNode {}", dpId, extDeviceNodeId, e);
    }
    return MDSALUtil.buildFlowNew(NwConstants.ELAN_DMAC_TABLE, ElanUtils.getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, extDeviceNodeId, dstMacAddress, elanTag, false), 20, /* prio */
    displayName, 0, /* idleTimeout */
    0, /* hardTimeout */
    ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) ElanException(org.opendaylight.netvirt.elan.ElanException)

Example 57 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ElanUtils method buildLocalDmacFlowEntry.

/**
 * Builds the flow to be programmed in the DMAC table of the local DPN (that
 * is, where the MAC is attached to). This flow consists in:
 *
 * <p>Match: + elanTag in metadata + packet goes to a MAC locally attached
 * Actions: + optionally, pop-vlan + set-vlan-id + output to ifName's
 * portNumber
 *
 * @param elanTag
 *            the elan tag
 * @param dpId
 *            the dp id
 * @param ifName
 *            the if name
 * @param macAddress
 *            the mac address
 * @param elanInfo
 *            the elan info
 * @param ifTag
 *            the if tag
 * @return the flow
 */
public Flow buildLocalDmacFlowEntry(long elanTag, BigInteger dpId, String ifName, String macAddress, ElanInstance elanInfo, long ifTag) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanTag), MetaDataUtil.METADATA_MASK_SERVICE));
    mkMatches.add(new MatchEthernetDestination(new MacAddress(macAddress)));
    List<Instruction> mkInstructions = new ArrayList<>();
    List<Action> actions = getEgressActionsForInterface(ifName, /* tunnelKey */
    null);
    mkInstructions.add(MDSALUtil.buildApplyActionsInstruction(actions));
    Flow flow = MDSALUtil.buildFlowNew(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, ifTag, macAddress, elanTag), 20, elanInfo.getElanInstanceName(), 0, 0, ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
    return flow;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) 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)

Example 58 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ElanUtils method getFlowIid.

public static InstanceIdentifier<Flow> getFlowIid(Flow flow, BigInteger dpnId) {
    FlowKey flowKey = new FlowKey(new FlowId(flow.getId()));
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId nodeId = new org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId("openflow:" + dpnId);
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node nodeDpn = new NodeBuilder().setId(nodeId).setKey(new NodeKey(nodeId)).build();
    return InstanceIdentifier.builder(Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
}
Also used : 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) MacTableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTableKey) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) 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) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)

Example 59 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ElanUtils method setupLocalDmacFlow.

private void setupLocalDmacFlow(long elanTag, BigInteger dpId, String ifName, String macAddress, ElanInstance elanInfo, IMdsalApiManager mdsalApiManager, long ifTag, WriteTransaction writeFlowGroupTx) {
    Flow flowEntity = buildLocalDmacFlowEntry(elanTag, dpId, ifName, macAddress, elanInfo, ifTag);
    mdsalApiManager.addFlowToTx(dpId, flowEntity, writeFlowGroupTx);
    installEtreeLocalDmacFlow(elanTag, dpId, ifName, macAddress, elanInfo, ifTag, writeFlowGroupTx);
}
Also used : Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 60 with Flow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.

the class ElanUtils method setupTermDmacFlows.

/**
 * Installs a Flow in INTERNAL_TUNNEL_TABLE of the affected DPN that sends
 * the packet through the specified interface if the tunnel_id matches the
 * interface's lportTag.
 *
 * @param interfaceInfo
 *            the interface info
 * @param mdsalApiManager
 *            the mdsal API manager
 * @param writeFlowGroupTx
 *            the writeFLowGroup tx
 */
public void setupTermDmacFlows(InterfaceInfo interfaceInfo, IMdsalApiManager mdsalApiManager, WriteTransaction writeFlowGroupTx) {
    BigInteger dpId = interfaceInfo.getDpId();
    int lportTag = interfaceInfo.getInterfaceTag();
    Flow flow = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE, getIntTunnelTableFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, lportTag), 5, String.format("%s:%d", "ITM Flow Entry ", lportTag), 0, 0, ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(lportTag)), getTunnelIdMatchForFilterEqualsLPortTag(lportTag), getInstructionsInPortForOutGroup(interfaceInfo.getInterfaceName()));
    mdsalApiManager.addFlowToTx(dpId, flow, writeFlowGroupTx);
    LOG.debug("Terminating service table flow entry created on dpn:{} for logical Interface port:{}", dpId, interfaceInfo.getPortName());
}
Also used : BigInteger(java.math.BigInteger) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Aggregations

Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)155 ArrayList (java.util.ArrayList)127 BigInteger (java.math.BigInteger)83 Test (org.junit.Test)67 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)65 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)55 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)51 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)47 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)44 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)41 List (java.util.List)36 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)35 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)35 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)33 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)31 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)30 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)30 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)28 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)24 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)24