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);
});
}
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);
}
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);
}
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);
}
}
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));
}
Aggregations