use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes in project netvirt by opendaylight.
the class EvpnUtils method withdrawEvpnRT2Routes.
public void withdrawEvpnRT2Routes(EvpnAugmentation evpnAugmentation, String elanName) {
if (evpnAugmentation == null || evpnAugmentation.getEvpnName() == null) {
LOG.trace("withdrawEvpnRT2Routes, evpnAugmentation is null");
return;
}
String evpnName = evpnAugmentation.getEvpnName();
String rd = vpnManager.getVpnRd(broker, evpnName);
if (rd == null) {
LOG.debug("withdrawEvpnRT2Routes : rd is null for {}", elanName);
return;
}
List<MacEntry> macEntries = elanUtils.getElanMacEntries(elanName);
if (macEntries == null || macEntries.isEmpty()) {
LOG.debug("withdrawEvpnRT2Routes : macEntries is empty for elan {} ", elanName);
return;
}
for (MacEntry macEntry : macEntries) {
if (!isIpv4PrefixAvailable.test(macEntry)) {
LOG.debug("withdrawEvpnRT2Routes macEntry does not have IPv4 prefix {}", macEntry);
continue;
}
String prefix = macEntry.getIpPrefix().getIpv4Address().getValue();
LOG.info("Withdrawing routes with rd {}, prefix {}", rd, prefix);
bgpManager.withdrawPrefix(rd, prefix);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes in project netvirt by opendaylight.
the class VpnInterfaceManager method getVpnsExportingMyRoute.
private List<VpnInstanceOpDataEntry> getVpnsExportingMyRoute(final String vpnName) {
List<VpnInstanceOpDataEntry> vpnsToExportRoute = new ArrayList<>();
String vpnRd = VpnUtil.getVpnRd(dataBroker, vpnName);
final VpnInstanceOpDataEntry vpnInstanceOpDataEntry = VpnUtil.getVpnInstanceOpData(dataBroker, vpnRd);
if (vpnInstanceOpDataEntry == null) {
LOG.debug("getVpnsExportingMyRoute: Could not retrieve vpn instance op data for {}" + " to check for vpns exporting the routes", vpnName);
return vpnsToExportRoute;
}
Predicate<VpnInstanceOpDataEntry> excludeVpn = input -> {
if (input.getVpnInstanceName() == null) {
LOG.error("getVpnsExportingMyRoute.excludeVpn: Received vpn instance with rd {} without a name", input.getVrfId());
return false;
}
return !input.getVpnInstanceName().equals(vpnName);
};
Predicate<VpnInstanceOpDataEntry> matchRTs = input -> {
Iterable<String> commonRTs = VpnUtil.intersection(VpnUtil.getRts(vpnInstanceOpDataEntry, VpnTarget.VrfRTType.ImportExtcommunity), VpnUtil.getRts(input, VpnTarget.VrfRTType.ExportExtcommunity));
return Iterators.size(commonRTs.iterator()) > 0;
};
vpnsToExportRoute = VpnUtil.getAllVpnInstanceOpData(dataBroker).stream().filter(excludeVpn).filter(matchRTs).collect(Collectors.toList());
return vpnsToExportRoute;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes in project netvirt by opendaylight.
the class VpnInterfaceManager method removeAdjacencyFromBgpvpn.
private void removeAdjacencyFromBgpvpn(Adjacency nextHop, List<String> nhList, String vpnName, String primaryRd, BigInteger dpnId, String rd, String interfaceName, WriteTransaction writeConfigTxn) {
List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
nhList.forEach((nh) -> {
// IRT: remove routes from other vpns importing it
vpnManager.removePrefixFromBGP(primaryRd, rd, vpnName, nextHop.getIpAddress(), nextHop.getNextHopIpList().get(0), nh, dpnId, writeConfigTxn);
for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
String vpnRd = vpn.getVrfId();
if (vpnRd != null) {
fibManager.removeOrUpdateFibEntry(vpnRd, nextHop.getIpAddress(), nh, writeConfigTxn);
LOG.info("removeAdjacenciesFromVpn: Removed Exported route with rd {}" + " prefix {} nextHop {} from VPN {} parentVpn {}" + " for interface {} on dpn {}", vpnRd, nextHop.getIpAddress(), nh, vpn.getVpnInstanceName(), vpnName, interfaceName, dpnId);
}
}
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes in project netvirt by opendaylight.
the class BgpConfigurationManager method deleteExternalFibRoutes.
/*
* BGP config remove scenario, Need to remove all the
* external routes from FIB.
*/
public void deleteExternalFibRoutes() {
totalExternalRoutes = 0;
totalExternalMacRoutes = 0;
try {
InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
Optional<FibEntries> fibEntries = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (fibEntries.isPresent()) {
if (fibEntries.get().getVrfTables() == null) {
LOG.error("deleteExternalFibRoutes::getVrfTables is null");
return;
}
List<VrfTables> staleVrfTables = fibEntries.get().getVrfTables();
for (VrfTables vrfTable : staleVrfTables) {
String rd = vrfTable.getRouteDistinguisher();
if (vrfTable.getVrfEntry() != null) {
for (VrfEntry vrfEntry : vrfTable.getVrfEntry()) {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
// route cleanup is only meant for the routes learned through BGP.
continue;
}
totalExternalRoutes++;
fibDSWriter.removeFibEntryFromDS(rd, vrfEntry.getDestPrefix());
}
} else if (vrfTable.getMacVrfEntry() != null) {
for (MacVrfEntry macEntry : vrfTable.getMacVrfEntry()) {
if (RouteOrigin.value(macEntry.getOrigin()) != RouteOrigin.BGP) {
// route cleanup is only meant for the routes learned through BGP.
continue;
}
totalExternalMacRoutes++;
fibDSWriter.removeMacEntryFromDS(rd, macEntry.getMac());
}
}
}
} else {
LOG.error("deleteExternalFibRoutes:: FIBentries.class is not present");
}
} catch (ReadFailedException e) {
LOG.error("deleteExternalFibRoutes:: error ", e);
}
LOG.debug("deleted {} fib entries {} mac entries", totalExternalRoutes, totalExternalMacRoutes);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes in project netvirt by opendaylight.
the class EvpnSnatFlowProgrammer method evpnDelFibTsAndReverseTraffic.
public void evpnDelFibTsAndReverseTraffic(final BigInteger dpnId, final long routerId, final String externalIp, final String vpnName, String extGwMacAddress, WriteTransaction removeFlowInvTx) {
/*
* 1) Remove the flow INTERNAL_TUNNEL_TABLE (table=36)-> INBOUND_NAPT_TABLE (table=44)
* (FIP VM on DPN1 is responding back to external fixed IP on DPN2) {DNAT to SNAT traffic on
* different Hypervisor}
*
* 2) Remove the flow L3_GW_MAC_TABLE (table=19)-> INBOUND_NAPT_TABLE (table=44)
* (FIP VM on DPN1 is responding back to external fixed IP on DPN1 itself){DNAT to SNAT traffic on
* Same Hypervisor}
*
* 3) Remove the flow PDNAT_TABLE (table=25)-> INBOUND_NAPT_TABLE (table=44)
* (If there is no FIP Match on table 25 (PDNAT_TABLE) then default flow to INBOUND_NAPT_TABLE (table=44))
*
* 4) Remove the flow L3_FIB_TABLE (table=21)-> INBOUND_NAPT_TABLE (table=44)
* (FIP VM on DPN1 is responding back to external fixed Ip on DPN1 itself. ie. same Hypervisor)
* {DNAT to SNAT Intra DC traffic}
*/
String rd = NatUtil.getVpnRd(dataBroker, vpnName);
if (rd == null) {
LOG.error("evpnDelFibTsAndReverseTraffic : Could not retrieve RD value from VPN Name {}", vpnName);
return;
}
long vpnId = NatUtil.getVpnId(dataBroker, vpnName);
if (vpnId == NatConstants.INVALID_ID) {
LOG.error("evpnDelFibTsAndReverseTraffic : Invalid Vpn Id is found for Vpn Name {}", vpnName);
return;
}
if (extGwMacAddress == null) {
LOG.error("evpnDelFibTsAndReverseTraffic : Unable to Get External Gateway MAC address for " + "External Router ID {} ", routerId);
return;
}
long l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
if (l3Vni == NatConstants.DEFAULT_L3VNI_VALUE) {
LOG.debug("evpnDelFibTsAndReverseTraffic : L3VNI value is not configured in Internet VPN {} and RD {} " + "Carve-out L3VNI value from OpenDaylight VXLAN VNI Pool and continue with installing " + "SNAT flows for External Fixed IP {}", vpnName, rd, externalIp);
l3Vni = NatOverVxlanUtil.getInternetVpnVni(idManager, vpnName, routerId).longValue();
}
final String externalFixedIp = NatUtil.validateAndAddNetworkMask(externalIp);
RemoveFibEntryInput input = new RemoveFibEntryInputBuilder().setVpnName(vpnName).setSourceDpid(dpnId).setIpAddress(externalFixedIp).setIpAddressSource(RemoveFibEntryInput.IpAddressSource.ExternalFixedIP).setServiceId(l3Vni).build();
LOG.debug("evpnDelFibTsAndReverseTraffic : Removing custom FIB table {} --> table {} flow on " + "NAPT Switch {} with l3Vni {}, ExternalFixedIp {}, ExternalVpnName {} for RouterId {}", NwConstants.L3_FIB_TABLE, NwConstants.INBOUND_NAPT_TABLE, dpnId, l3Vni, externalIp, vpnName, routerId);
Future<RpcResult<Void>> future = fibService.removeFibEntry(input);
ListenableFuture<RpcResult<Void>> futureVxlan = JdkFutureAdapters.listenInPoolThread(future);
final long finalL3Vni = l3Vni;
Futures.addCallback(futureVxlan, new FutureCallback<RpcResult<Void>>() {
@Override
public void onFailure(@Nonnull Throwable error) {
LOG.error("evpnDelFibTsAndReverseTraffic : Error in custom fib routes remove process for " + "External Fixed IP {} on DPN {} with l3Vni {}, ExternalVpnName {} for RouterId {}", externalIp, dpnId, finalL3Vni, vpnName, routerId, error);
}
@Override
public void onSuccess(@Nonnull RpcResult<Void> result) {
if (result.isSuccessful()) {
LOG.info("evpnDelFibTsAndReverseTraffic : Successfully removed custom FIB routes for " + "External Fixed IP {} on DPN {} with l3Vni {}, ExternalVpnName {} for " + "RouterId {}", externalIp, dpnId, finalL3Vni, vpnName, routerId);
// remove INTERNAL_TUNNEL_TABLE (table=36)-> INBOUND_NAPT_TABLE (table=44) flow
removeTunnelTableEntry(dpnId, finalL3Vni, removeFlowInvTx);
// remove L3_GW_MAC_TABLE (table=19)-> INBOUND_NAPT_TABLE (table=44) flow
NatUtil.removePreDnatToSnatTableEntry(mdsalManager, dpnId, removeFlowInvTx);
// remove PDNAT_TABLE (table=25)-> INBOUND_NAPT_TABLE (table=44) flow
NatEvpnUtil.removeL3GwMacTableEntry(dpnId, vpnId, extGwMacAddress, mdsalManager, removeFlowInvTx);
}
}
}, MoreExecutors.directExecutor());
}
Aggregations