Search in sources :

Example 81 with FlowEntity

use of org.opendaylight.genius.mdsalutil.FlowEntity in project netvirt by opendaylight.

the class EvpnUtils method programEvpnL2vniFlow.

private void programEvpnL2vniFlow(ElanInstance elanInfo, BiConsumer<BigInteger, FlowEntity> flowHandler) {
    long elanTag = elanInfo.getElanTag();
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchTunnelId(BigInteger.valueOf(elanUtils.getVxlanSegmentationId(elanInfo))));
    NWUtil.getOperativeDPNs(broker).forEach(dpnId -> {
        LOG.debug("Updating tunnel flow to dpnid {}", dpnId);
        List<InstructionInfo> instructions = getInstructionsForExtTunnelTable(elanTag);
        String flowRef = getFlowRef(NwConstants.L2VNI_EXTERNAL_TUNNEL_DEMUX_TABLE, elanTag, dpnId);
        FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L2VNI_EXTERNAL_TUNNEL_DEMUX_TABLE, flowRef, // prio
        5, // flowName
        elanInfo.getElanInstanceName(), // idleTimeout
        0, // hardTimeout
        0, ITMConstants.COOKIE_ITM_EXTERNAL.add(BigInteger.valueOf(elanTag)), mkMatches, instructions);
        flowHandler.accept(dpnId, flowEntity);
    });
}
Also used : MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 82 with FlowEntity

use of org.opendaylight.genius.mdsalutil.FlowEntity in project netvirt by opendaylight.

the class ElanInterfaceManager method unsetExternalTunnelTable.

/**
 * Removes, from External Tunnel table, the flow that translates from VNI to
 * elanTag. Important: ensure this method is only called whenever there is
 * no other ElanInterface in the specified DPN
 *
 * @param dpnId
 *            DPN whose Ext Tunnel table is going to be modified
 * @param elanInfo
 *            holds the elanTag needed for selecting the flow to be removed
 */
public void unsetExternalTunnelTable(BigInteger dpnId, ElanInstance elanInfo) {
    // TODO: Use DataStoreJobCoordinator in order to avoid that removing the
    // last ElanInstance plus
    // adding a new one does (almost at the same time) are executed in that
    // exact order
    String flowId = getFlowRef(NwConstants.EXTERNAL_TUNNEL_TABLE, elanInfo.getElanTag());
    FlowEntity flowEntity = new FlowEntityBuilder().setDpnId(dpnId).setTableId(NwConstants.EXTERNAL_TUNNEL_TABLE).setFlowId(flowId).build();
    mdsalManager.removeFlow(flowEntity);
}
Also used : FlowEntityBuilder(org.opendaylight.genius.mdsalutil.FlowEntityBuilder) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 83 with FlowEntity

use of org.opendaylight.genius.mdsalutil.FlowEntity in project netvirt by opendaylight.

the class ElanNodeListener method setupExternalL2vniTableMissFlow.

private void setupExternalL2vniTableMissFlow(BigInteger dpnId) {
    List<MatchInfo> matches = new ArrayList<>();
    List<ActionInfo> actionsInfos = Collections.singletonList(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE));
    List<InstructionInfo> instructions = Collections.singletonList(new InstructionApplyActions(actionsInfos));
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L2VNI_EXTERNAL_TUNNEL_DEMUX_TABLE, getTableMissFlowRef(NwConstants.L2VNI_EXTERNAL_TUNNEL_DEMUX_TABLE), 0, "External L2VNI Table Miss Flow", 0, 0, ElanConstants.COOKIE_L2VNI_DEMUX, matches, instructions);
    mdsalManager.installFlow(flowEntity);
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 84 with FlowEntity

use of org.opendaylight.genius.mdsalutil.FlowEntity in project netvirt by opendaylight.

the class VpnServiceChainUtils method programLPortDispatcherFlowForVpnToScf.

/**
 * Installs/removes a flow in LPortDispatcher table that is in charge
 * of sending the traffic to the SCF Pipeline.
 */
public static void programLPortDispatcherFlowForVpnToScf(IMdsalApiManager mdsalManager, BigInteger dpId, int lportTag, long scfTag, short gotoTableId, int addOrRemove) {
    LOG.trace("programLPortDispatcherFlowForVpnToScf: dpId={} lportTag={} scfTag={} gotoTableId={} addOrRemove={}", dpId, lportTag, scfTag, gotoTableId, addOrRemove);
    FlowEntity flowEntity = VpnServiceChainUtils.buildLportFlowDispForVpnToScf(dpId, lportTag, scfTag, gotoTableId);
    if (addOrRemove == NwConstants.ADD_FLOW) {
        mdsalManager.installFlow(flowEntity);
    } else {
        mdsalManager.removeFlow(flowEntity);
    }
}
Also used : FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 85 with FlowEntity

use of org.opendaylight.genius.mdsalutil.FlowEntity in project netvirt by opendaylight.

the class VPNServiceChainHandlerTest method testProgramVpnToScfWithVpnIfacesAlreadyBound.

@Test
public void testProgramVpnToScfWithVpnIfacesAlreadyBound() throws Exception {
    // ///////////////////
    // Basic stubbing //
    // ///////////////////
    String ifaceName = "eth0";
    stubGetRouteDistinguisher(VPN_NAME, RD);
    stubGetVpnInstance(RD, "1.2.3.4", ifaceName);
    VrfEntry vrfEntry = FibHelper.getVrfEntryBuilder("11.12.13.14", 2000L, DC_GW_IP, RouteOrigin.STATIC, null).build();
    stubGetVrfEntries(RD, Collections.singletonList(vrfEntry));
    stubReadVpnToDpnList(RD, DPN_ID, Collections.singletonList(ifaceName));
    stubScfIsBoundOnIface(SCF_TAG, ifaceName);
    // ///////
    // SUT //
    // ///////
    short tableId = 10;
    vpnsch.programVpnToScfPipeline(VPN_NAME, tableId, SCF_TAG, LPORT_TAG, NwConstants.ADD_FLOW);
    // //////////
    // Verify //
    // //////////
    ArgumentCaptor<FlowEntity> argumentCaptor = ArgumentCaptor.forClass(FlowEntity.class);
    verify(mdsalMgr, times(2)).installFlow(argumentCaptor.capture());
    List<FlowEntity> installedFlowsCaptured = argumentCaptor.getAllValues();
    assert installedFlowsCaptured.size() == 2;
    RoutePaths routePath = vrfEntry.getRoutePaths().get(0);
    FlowEntity expectedLFibFlowEntity = VpnServiceChainUtils.buildLFibVpnPseudoPortFlow(DPN_ID, routePath.getLabel(), routePath.getNexthopAddress(), LPORT_TAG);
    assert new FlowEntityMatcher(expectedLFibFlowEntity).matches(installedFlowsCaptured.get(0));
    FlowEntity expectedLPortDispatcher = VpnServiceChainUtils.buildLportFlowDispForVpnToScf(DPN_ID, LPORT_TAG, SCF_TAG, tableId);
    assert new FlowEntityMatcher(expectedLPortDispatcher).matches(installedFlowsCaptured.get(1));
}
Also used : VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) FlowEntityMatcher(org.opendaylight.netvirt.cloudservicechain.matchers.FlowEntityMatcher) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) Test(org.junit.Test)

Aggregations

FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)119 ArrayList (java.util.ArrayList)56 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)52 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)50 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)37 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)37 BigInteger (java.math.BigInteger)23 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)22 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)17 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)14 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)12 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)9 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)9 MatchTunnelId (org.opendaylight.genius.mdsalutil.matches.MatchTunnelId)7 Test (org.junit.Test)6 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)6 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)6 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)6 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)6 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)5