use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class VpnUtil method getVpnHandlingIpv4AssociatedWithInterface.
static Optional<List<String>> getVpnHandlingIpv4AssociatedWithInterface(DataBroker broker, String interfaceName) {
InstanceIdentifier<VpnInterface> interfaceId = getVpnInterfaceIdentifier(interfaceName);
Optional<List<String>> vpnOptional = Optional.absent();
Optional<VpnInterface> optConfiguredVpnInterface = read(broker, LogicalDatastoreType.CONFIGURATION, interfaceId);
if (optConfiguredVpnInterface.isPresent()) {
VpnInterface cfgVpnInterface = optConfiguredVpnInterface.get();
java.util.Optional<List<VpnInstanceNames>> optVpnInstanceList = java.util.Optional.ofNullable(cfgVpnInterface.getVpnInstanceNames());
if (optVpnInstanceList.isPresent()) {
List<String> vpnList = new ArrayList<>();
for (VpnInstanceNames vpnInstance : optVpnInstanceList.get()) {
if (vpnInstance.getAssociatedSubnetType().equals(AssociatedSubnetType.V6Subnet)) {
continue;
}
vpnList.add(vpnInstance.getVpnName());
}
vpnOptional = Optional.of(vpnList);
}
}
return vpnOptional;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class VpnUtil method getListOfRdsFromVpnInstance.
public static List<String> getListOfRdsFromVpnInstance(VpnInstance vpnInstance) {
VpnAfConfig vpnConfig = vpnInstance.getIpv4Family();
LOG.trace("vpnConfig {}", vpnConfig);
return vpnConfig.getRouteDistinguisher() != null ? new ArrayList<>(vpnConfig.getRouteDistinguisher()) : new ArrayList<>();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class EvpnUtils method advertisePrefix.
@SuppressWarnings("checkstyle:IllegalCatch")
public void advertisePrefix(ElanInstance elanInfo, String rd, String macAddress, String prefix, String interfaceName, BigInteger dpnId) {
if (rd == null) {
LOG.debug("advertisePrefix : rd is NULL for elanInfo {}, macAddress {}", elanInfo, macAddress);
return;
}
String nextHop = getEndpointIpAddressForDPN(dpnId);
if (nextHop == null) {
LOG.debug("Failed to get the dpn tep ip for dpn {}", dpnId);
return;
}
int vpnLabel = 0;
long l2vni = elanUtils.getVxlanSegmentationId(elanInfo);
long l3vni = 0;
String gatewayMacAddr = null;
String l3VpName = getL3vpnNameFromElan(elanInfo);
if (l3VpName != null) {
VpnInstance l3VpnInstance = vpnManager.getVpnInstance(broker, l3VpName);
l3vni = l3VpnInstance.getL3vni();
com.google.common.base.Optional<String> gatewayMac = getGatewayMacAddressForInterface(l3VpName, interfaceName, prefix);
gatewayMacAddr = gatewayMac.isPresent() ? gatewayMac.get() : null;
}
LOG.info("Advertising routes with rd {}, macAddress {}, prefix {}, nextHop {}," + " vpnLabel {}, l3vni {}, l2vni {}, gatewayMac {}", rd, macAddress, prefix, nextHop, vpnLabel, l3vni, l2vni, gatewayMacAddr);
try {
bgpManager.advertisePrefix(rd, macAddress, prefix, nextHop, VrfEntryBase.EncapType.Vxlan, vpnLabel, l3vni, l2vni, gatewayMacAddr);
} catch (Exception e) {
LOG.error("Failed to advertisePrefix", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class TunnelInterfaceStateListener method handleTunnelEventForDPNVpn.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleTunnelEventForDPNVpn(StateTunnelList stateTunnelList, Map<Long, String> vpnIdRdMap, TunnelAction tunnelAction, boolean isTepDeletedOnDpn, List<Uuid> subnetList, TunnelEventProcessingMethod method, VpnInterface cfgVpnInterface) {
String rd;
String intfName = cfgVpnInterface.getName();
final BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
String destTepIp = String.valueOf(stateTunnelList.getDstInfo().getTepIp().getValue());
String srcTepIp = String.valueOf(stateTunnelList.getSrcInfo().getTepIp().getValue());
int tunTypeVal = getTunnelType(stateTunnelList);
BigInteger remoteDpnId = null;
if (tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
remoteDpnId = new BigInteger(stateTunnelList.getDstInfo().getTepDeviceId());
}
if (cfgVpnInterface.getVpnInstanceNames() == null) {
LOG.warn("handleTunnelEventForDpn: no vpnName found for interface {}", intfName);
return;
}
for (VpnInstanceNames vpnInstance : cfgVpnInterface.getVpnInstanceNames()) {
String vpnName = vpnInstance.getVpnName();
if (method == TunnelEventProcessingMethod.POPULATESUBNETS) {
Optional<VpnInterfaceOpDataEntry> opVpnInterface = VpnUtil.getVpnInterfaceOpDataEntry(dataBroker, intfName, vpnName);
if (opVpnInterface.isPresent() && !opVpnInterface.get().isScheduledForRemove()) {
VpnInterfaceOpDataEntry vpnInterface = opVpnInterface.get();
jobCoordinator.enqueueJob("VPNINTERFACE-" + intfName, new UpdateVpnInterfaceOnTunnelEvent(tunnelAction, vpnInterface, stateTunnelList, isTepDeletedOnDpn));
// Populate the List of subnets
InstanceIdentifier<PortOpDataEntry> portOpIdentifier = InstanceIdentifier.builder(PortOpData.class).child(PortOpDataEntry.class, new PortOpDataEntryKey(intfName)).build();
Optional<PortOpDataEntry> optionalPortOp = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
if (optionalPortOp.isPresent()) {
List<Uuid> subnetIdList = optionalPortOp.get().getSubnetIds();
if (subnetIdList != null) {
for (Uuid subnetId : subnetIdList) {
if (!subnetList.contains(subnetId)) {
subnetList.add(subnetId);
}
}
}
}
// Populate the map for VpnId-to-Rd
long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
rd = VpnUtil.getVpnRd(dataBroker, vpnName);
vpnIdRdMap.put(vpnId, rd);
}
} else if (method == TunnelEventProcessingMethod.MANAGEREMOTEROUTES) {
Optional<VpnInterfaceOpDataEntry> opVpnInterface = VpnUtil.getVpnInterfaceOpDataEntry(dataBroker, intfName, vpnName);
if (opVpnInterface.isPresent()) {
VpnInterfaceOpDataEntry vpnInterface = opVpnInterface.get();
AdjacenciesOp adjacencies = vpnInterface.getAugmentation(AdjacenciesOp.class);
List<Adjacency> adjList = adjacencies != null ? adjacencies.getAdjacency() : Collections.emptyList();
String prefix = null;
long vpnId = VpnUtil.getVpnId(dataBroker, vpnInterface.getVpnInstanceName());
if (vpnIdRdMap.containsKey(vpnId)) {
rd = vpnIdRdMap.get(vpnId);
LOG.info("handleTunnelEventForDPN: Remote DpnId {} VpnId {} rd {} VpnInterface {} srcTepIp " + "{} destTepIp {}", remoteDpnId, vpnId, rd, vpnInterface, srcTepIp, destTepIp);
for (Adjacency adj : adjList) {
prefix = adj.getIpAddress();
long label = adj.getLabel();
if (tunnelAction == TunnelAction.TUNNEL_EP_ADD && tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
fibManager.manageRemoteRouteOnDPN(true, srcDpnId, vpnId, rd, prefix, destTepIp, label);
}
if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
fibManager.manageRemoteRouteOnDPN(false, srcDpnId, vpnId, rd, prefix, destTepIp, label);
}
}
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class EvpnDnatFlowProgrammer method onRemoveFloatingIp.
public void onRemoveFloatingIp(final BigInteger dpnId, final String vpnName, final String externalIp, final String floatingIpInterface, final String floatingIpPortMacAddress, final long routerId, WriteTransaction removeFlowInvTx) {
/*
* 1) Remove the flow INTERNAL_TUNNEL_TABLE (table=36)-> PDNAT_TABLE (table=25) (SNAT VM on DPN1 is
* responding back to FIP VM on DPN2) {SNAT to DNAT traffic on different Hypervisor}
*
* 2) Remove the flow L3_FIB_TABLE (table=21)-> PDNAT_TABLE (table=25) (FIP VM1 to FIP VM2
* Traffic on Same Hypervisor) {DNAT to DNAT on Same Hypervisor}
*
* 3) Remove the flow L3_GW_MAC_TABLE (table=19)-> PDNAT_TABLE (table=25)
* (DC-GW is responding back to FIP VM) {DNAT Reverse traffic})
*
*/
String rd = NatUtil.getVpnRd(dataBroker, vpnName);
if (rd == null) {
LOG.error("onRemoveFloatingIp : Could not retrieve RD value from VPN Name {} ", vpnName);
return;
}
long vpnId = NatUtil.getVpnId(dataBroker, vpnName);
if (vpnId == NatConstants.INVALID_ID) {
LOG.error("onRemoveFloatingIp : Invalid Vpn Id is found for Vpn Name {}", vpnName);
return;
}
long l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
if (l3Vni == NatConstants.DEFAULT_L3VNI_VALUE) {
LOG.debug("onRemoveFloatingIp : L3VNI value is not configured in Internet VPN {} and RD {} " + "Carve-out L3VNI value from OpenDaylight VXLAN VNI Pool and continue with installing " + "DNAT flows for FloatingIp {}", vpnName, rd, externalIp);
l3Vni = NatOverVxlanUtil.getInternetVpnVni(idManager, vpnName, routerId).longValue();
}
String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp);
// Remove Prefix from BGP
NatUtil.removePrefixFromBGP(bgpManager, fibManager, rd, fibExternalIp, vpnName, LOG);
// Remove custom FIB routes flow for L3_FIB_TABLE (table=21)-> PDNAT_TABLE (table=25)
RemoveFibEntryInput input = new RemoveFibEntryInputBuilder().setVpnName(vpnName).setSourceDpid(dpnId).setIpAddress(fibExternalIp).setServiceId(l3Vni).setIpAddressSource(RemoveFibEntryInput.IpAddressSource.FloatingIP).build();
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("onRemoveFloatingIp : Error {} in custom fib routes remove process for Floating " + "IP Prefix {} on DPN {}", error, externalIp, dpnId);
}
@Override
public void onSuccess(@Nonnull RpcResult<Void> result) {
if (result.isSuccessful()) {
LOG.info("onRemoveFloatingIp : Successfully removed custom FIB routes for Floating " + "IP Prefix {} on DPN {}", externalIp, dpnId);
/* check if any floating IP information is available in vpn-to-dpn-list for given dpn id.
* If exist any floating IP then do not remove
* INTERNAL_TUNNEL_TABLE (table=36) -> PDNAT_TABLE (table=25) flow entry.
*/
if (!NatUtil.isFloatingIpPresentForDpn(dataBroker, dpnId, rd, vpnName, externalIp, false)) {
// Remove the flow for INTERNAL_TUNNEL_TABLE (table=36)-> PDNAT_TABLE (table=25)
removeTunnelTableEntry(dpnId, finalL3Vni, removeFlowInvTx);
}
// Remove the flow for L3_GW_MAC_TABLE (table=19)-> PDNAT_TABLE (table=25)
NatEvpnUtil.removeL3GwMacTableEntry(dpnId, vpnId, floatingIpPortMacAddress, mdsalManager, removeFlowInvTx);
NatUtil.waitForTransactionToComplete(removeFlowInvTx);
} else {
LOG.error("onRemoveFloatingIp : Error {} in rpc call to remove custom Fib entries for Floating " + "IP Prefix {} on DPN {}", result.getErrors(), externalIp, dpnId);
}
}
}, MoreExecutors.directExecutor());
// Read the FIP vpn-interface details from Operational l3vpn:vpn-interfaces model and delete from Operational DS
InstanceIdentifier<VpnInterface> vpnIfIdentifier = NatUtil.getVpnInterfaceIdentifier(floatingIpInterface);
Optional<VpnInterface> optionalVpnInterface = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
if (optionalVpnInterface.isPresent()) {
WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
for (VpnInstanceNames vpnInstance : optionalVpnInterface.get().getVpnInstanceNames()) {
if (!vpnName.equals(vpnInstance.getVpnName())) {
continue;
}
InstanceIdentifier<VpnInterfaceOpDataEntry> vpnOpIfIdentifier = NatUtil.getVpnInterfaceOpDataEntryIdentifier(floatingIpInterface, vpnName);
writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL, vpnOpIfIdentifier);
break;
}
ListenableFuture<Void> futures = writeOperTxn.submit();
String errorText = "onRemoveFloatingIp : Could not remove vpnInterface " + floatingIpInterface + " vpnName " + vpnName + " from Operational odl-l3vpn:vpn-interface-op-data";
ListenableFutures.addErrorLogging(futures, LOG, errorText);
LOG.debug("onRemoveFloatingIp : Remove vpnInterface {} vpnName {} " + "to Operational odl-l3vpn:vpn-interface-op-data", floatingIpInterface, vpnName);
} else {
LOG.debug("onRemoveFloatingIp : No vpnInterface {} found " + "in Operational odl-l3vpn:vpn-interface-op-data", floatingIpInterface);
}
}
Aggregations