use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths in project netvirt by opendaylight.
the class VrfEntryListener method cleanUpDpnForVpn.
public void cleanUpDpnForVpn(final BigInteger dpnId, final long vpnId, final String rd, final FutureCallback<List<Void>> callback) {
LOG.trace("cleanUpDpnForVpn: Remove dpn {} for vpn {} : cleanUpDpnForVpn", dpnId, rd);
InstanceIdentifier<VrfTables> id = buildVrfId(rd);
final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
List<SubTransaction> txnObjects = new ArrayList<>();
final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, dpnId), () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (vrfTable.isPresent()) {
synchronized (vpnInstance.getVpnInstanceName().intern()) {
futures.add(retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
for (final VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
/* Handle subnet routes here */
SubnetRoute subnetRoute = vrfEntry.getAugmentation(SubnetRoute.class);
if (subnetRoute != null) {
LOG.trace("SUBNETROUTE: cleanUpDpnForVpn: Cleaning subnetroute {} on dpn {}" + " for vpn {}", vrfEntry.getDestPrefix(), dpnId, rd);
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, null, NwConstants.DEL_FLOW, tx, null);
List<RoutePaths> routePaths = vrfEntry.getRoutePaths();
if (routePaths != null) {
for (RoutePaths routePath : routePaths) {
makeLFibTableEntry(dpnId, routePath.getLabel(), null, DEFAULT_FIB_FLOW_PRIORITY, NwConstants.DEL_FLOW, tx);
LOG.trace("SUBNETROUTE: cleanUpDpnForVpn: Released subnetroute label {}" + " for rd {} prefix {}", routePath.getLabel(), rd, vrfEntry.getDestPrefix());
}
}
installSubnetBroadcastAddrDropRule(dpnId, rd, vpnId, vrfEntry, NwConstants.DEL_FLOW, tx);
continue;
}
// ping responder for router interfaces
RouterInterface routerInt = vrfEntry.getAugmentation(RouterInterface.class);
if (routerInt != null) {
LOG.trace("Router augmented vrfentry found for rd:{}, uuid:{}, ip:{}, mac:{}", rd, routerInt.getUuid(), routerInt.getIpAddress(), routerInt.getMacAddress());
routerInterfaceVrfEntryHandler.installRouterFibEntry(vrfEntry, dpnId, vpnId, routerInt.getIpAddress(), new MacAddress(routerInt.getMacAddress()), NwConstants.DEL_FLOW);
continue;
}
// Handle local flow deletion for imports
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.SELF_IMPORTED) {
java.util.Optional<Long> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
if (optionalLabel.isPresent()) {
List<String> nextHopList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
LabelRouteInfo lri = getLabelRouteInfo(optionalLabel.get());
if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopList, lri) && lri.getDpnId().equals(dpnId)) {
deleteLocalFibEntry(vpnId, rd, vrfEntry);
}
}
}
// Passing null as we don't know the dpn
// to which prefix is attached at this point
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
Optional<Routes> extraRouteOptional;
// an adjacency in the vpn
if (usedRds != null && !usedRds.isEmpty()) {
if (usedRds.size() > 1) {
LOG.error("The extra route prefix is still present in some DPNs");
return;
} else {
extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, vpnName, usedRds.get(0), vrfEntry.getDestPrefix());
}
} else {
extraRouteOptional = Optional.absent();
}
if (RouteOrigin.BGP.getValue().equals(vrfEntry.getOrigin())) {
bgpRouteVrfEntryHandler.deleteRemoteRoute(null, dpnId, vpnId, vrfTable.get().getKey(), vrfEntry, extraRouteOptional, tx, txnObjects);
} else {
baseVrfEntryHandler.deleteRemoteRoute(null, dpnId, vpnId, vrfTable.get().getKey(), vrfEntry, extraRouteOptional, tx);
}
}
}));
}
if (callback != null) {
ListenableFuture<List<Void>> listenableFuture = Futures.allAsList(futures);
Futures.addCallback(listenableFuture, callback, MoreExecutors.directExecutor());
}
}
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths in project netvirt by opendaylight.
the class VrfEntryListener method manageRemoteRouteOnDPN.
public void manageRemoteRouteOnDPN(final boolean action, final BigInteger localDpnId, final long vpnId, final String rd, final String destPrefix, final String destTepIp, final long label) {
final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
if (vpnInstance == null) {
LOG.error("VpnInstance for rd {} not present for prefix {}", rd, destPrefix);
return;
}
jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, localDpnId), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
synchronized (vpnInstance.getVpnInstanceName().intern()) {
VrfTablesKey vrfTablesKey = new VrfTablesKey(rd);
VrfEntry vrfEntry = getVrfEntry(dataBroker, rd, destPrefix);
if (vrfEntry == null) {
return;
}
LOG.trace("manageRemoteRouteOnDPN :: action {}, DpnId {}, vpnId {}, rd {}, destPfx {}", action, localDpnId, vpnId, rd, destPrefix);
List<RoutePaths> routePathList = vrfEntry.getRoutePaths();
VrfEntry modVrfEntry;
if (routePathList == null || routePathList.isEmpty()) {
modVrfEntry = FibHelper.getVrfEntryBuilder(vrfEntry, label, Collections.singletonList(destTepIp), RouteOrigin.value(vrfEntry.getOrigin()), null).build();
} else {
modVrfEntry = vrfEntry;
}
if (action) {
LOG.trace("manageRemoteRouteOnDPN updated(add) vrfEntry :: {}", modVrfEntry);
createRemoteFibEntry(localDpnId, vpnId, vrfTablesKey.getRouteDistinguisher(), modVrfEntry, tx);
} else {
LOG.trace("manageRemoteRouteOnDPN updated(remove) vrfEntry :: {}", modVrfEntry);
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
if (usedRds.size() > 1) {
LOG.debug("The extra route prefix is still present in some DPNs");
return;
}
// Is this fib route an extra route? If yes, get the nexthop which would be
// an adjacency in the vpn
Optional<Routes> extraRouteOptional = Optional.absent();
if (usedRds.size() != 0) {
extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, fibUtil.getVpnNameFromId(vpnInstance.getVpnId()), usedRds.get(0), vrfEntry.getDestPrefix());
}
baseVrfEntryHandler.deleteRemoteRoute(null, localDpnId, vpnId, vrfTablesKey, modVrfEntry, extraRouteOptional, tx);
}
}
})));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths in project netvirt by opendaylight.
the class VPNServiceChainHandlerTest method testProgramVpnToScfWithIfacesNotBound.
@Test
public void testProgramVpnToScfWithIfacesNotBound() 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));
stubScfIsNotBoundOnIface(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(ifaceMgr).bindService(eq(ifaceName), eq(ServiceModeIngress.class), anyObject());
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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths in project netvirt by opendaylight.
the class FibEntriesListener method update.
@Override
protected void update(InstanceIdentifier<VrfEntry> identifier, VrfEntry original, VrfEntry update) {
final VrfTablesKey key = identifier.firstKeyOf(VrfTables.class, VrfTablesKey.class);
String rd = key.getRouteDistinguisher();
List<RoutePaths> originalRoutePaths = new ArrayList<>(original.getRoutePaths());
List<RoutePaths> updateRoutePaths = new ArrayList<>(update.getRoutePaths());
if (originalRoutePaths.size() < updateRoutePaths.size()) {
updateRoutePaths.removeAll(originalRoutePaths);
addLabelToVpnInstance(rd, updateRoutePaths);
} else if (originalRoutePaths.size() > updateRoutePaths.size()) {
originalRoutePaths.removeAll(updateRoutePaths);
removeLabelFromVpnInstance(rd, originalRoutePaths);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths in project netvirt by opendaylight.
the class FibEntriesListener method remove.
@Override
protected void remove(InstanceIdentifier<VrfEntry> identifier, VrfEntry del) {
LOG.trace("Remove Fib event - Key : {}, value : {} ", identifier, del);
final VrfTablesKey key = identifier.firstKeyOf(VrfTables.class, VrfTablesKey.class);
String rd = key.getRouteDistinguisher();
List<RoutePaths> routePaths = del.getRoutePaths();
removeLabelFromVpnInstance(rd, routePaths);
}
Aggregations