use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink in project netvirt by opendaylight.
the class InterVpnLinkNodeListener method reinstallInterVpnLink.
private void reinstallInterVpnLink(InterVpnLinkDataComposite ivl) {
String ivlName = ivl.getInterVpnLinkName();
LOG.debug("Reinstalling InterVpnLink {} affected by node going down", ivlName);
// Lets move the InterVpnLink to some other place. Basically, remove it and create it again
InstanceIdentifier<InterVpnLink> interVpnLinkIid = InterVpnLinkUtil.getInterVpnLinkPath(ivlName);
String specificJobKey = "InterVpnLink.update." + ivlName;
InterVpnLink interVpnLink = ivl.getInterVpnLinkConfig();
jobCoordinator.enqueueJob(specificJobKey, new InterVpnLinkRemoverTask(dataBroker, interVpnLinkIid));
jobCoordinator.enqueueJob(specificJobKey, new InterVpnLinkCleanedCheckerTask(dataBroker, interVpnLink));
jobCoordinator.enqueueJob(specificJobKey, new InterVpnLinkCreatorTask(dataBroker, interVpnLink));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink in project netvirt by opendaylight.
the class InterVpnLinkUtil method leakRoute.
/**
* Leaks a route from one VPN to another. By default, the origin for this leaked route is INTERVPN.
*
* @param broker dataBroker service reference
* @param bgpManager Used to advertise routes to the BGP Router
* @param interVpnLink Reference to the object that holds the info about the link between the 2 VPNs
* @param srcVpnUuid UUID of the VPN that has the route that is going to be leaked to the other VPN
* @param dstVpnUuid UUID of the VPN that is going to receive the route
* @param prefix Prefix of the route
* @param label Label of the route in the original VPN
*/
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public static void leakRoute(DataBroker broker, IBgpManager bgpManager, InterVpnLink interVpnLink, String srcVpnUuid, String dstVpnUuid, String prefix, Long label) {
Preconditions.checkNotNull(interVpnLink);
// The source VPN must participate in the InterVpnLink
Preconditions.checkArgument(interVpnLink.getFirstEndpoint().getVpnUuid().getValue().equals(srcVpnUuid) || interVpnLink.getSecondEndpoint().getVpnUuid().getValue().equals(srcVpnUuid), "The source VPN {} does not participate in the interVpnLink {}", srcVpnUuid, interVpnLink.getName());
// The destination VPN must participate in the InterVpnLink
Preconditions.checkArgument(interVpnLink.getFirstEndpoint().getVpnUuid().getValue().equals(dstVpnUuid) || interVpnLink.getSecondEndpoint().getVpnUuid().getValue().equals(dstVpnUuid), "The destination VPN {} does not participate in the interVpnLink {}", dstVpnUuid, interVpnLink.getName());
boolean destinationIs1stEndpoint = interVpnLink.getFirstEndpoint().getVpnUuid().getValue().equals(dstVpnUuid);
String endpointIp = destinationIs1stEndpoint ? interVpnLink.getSecondEndpoint().getIpAddress().getValue() : interVpnLink.getFirstEndpoint().getIpAddress().getValue();
VrfEntry newVrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, endpointIp, RouteOrigin.INTERVPN, null).build();
String dstVpnRd = VpnUtil.getVpnRd(broker, dstVpnUuid);
InstanceIdentifier<VrfEntry> newVrfEntryIid = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(dstVpnRd)).child(VrfEntry.class, new VrfEntryKey(newVrfEntry.getDestPrefix())).build();
VpnUtil.asyncWrite(broker, LogicalDatastoreType.CONFIGURATION, newVrfEntryIid, newVrfEntry);
// Finally, route is advertised it to the DC-GW. But while in the FibEntries the nexthop is the other
// endpoint's IP, in the DC-GW the nexthop for those prefixes are the IPs of those DPNs where the target
// VPN has been instantiated
Optional<InterVpnLinkState> optVpnLinkState = getInterVpnLinkState(broker, interVpnLink.getName());
if (optVpnLinkState.isPresent()) {
InterVpnLinkState vpnLinkState = optVpnLinkState.get();
List<BigInteger> dpnIdList = destinationIs1stEndpoint ? vpnLinkState.getFirstEndpointState().getDpId() : vpnLinkState.getSecondEndpointState().getDpId();
List<String> nexthops = new ArrayList<>();
for (BigInteger dpnId : dpnIdList) {
nexthops.add(InterfaceUtils.getEndpointIpAddressForDPN(broker, dpnId));
}
try {
LOG.debug("Advertising route in VPN={} [prefix={} label={} nexthops={}] to DC-GW", dstVpnRd, newVrfEntry.getDestPrefix(), label.intValue(), nexthops);
bgpManager.advertisePrefix(dstVpnRd, null, /*macAddress*/
newVrfEntry.getDestPrefix(), nexthops, VrfEntry.EncapType.Mplsgre, label.intValue(), 0, /*l3vni*/
0, /*l2vni*/
null);
} catch (Exception ex) {
LOG.error("Could not advertise prefix {} with label {} to VPN rd={}", newVrfEntry.getDestPrefix(), label.intValue(), dstVpnRd, ex);
}
} else {
LOG.warn("Error when advertising leaked routes: Could not find State for InterVpnLink={}", interVpnLink.getName());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink in project netvirt by opendaylight.
the class InterVpnLinkUtil method installLPortDispatcherTableFlow.
/**
* Installs a Flow in LPortDispatcher table that matches on SI=2 and
* the lportTag of one InterVpnLink's endpoint and sets the vrfTag of the
* other endpoint and sends to FIB table.
*
* @param broker dataBroker service reference
* @param mdsalManager MDSAL API accessor
* @param interVpnLinkName Name of the InterVpnLink.
* @param dpnList The list of DPNs where this flow must be installed
* @param vpnUuidOtherEndpoint UUID of the other endpoint of the InterVpnLink
* @param lportTagOfOtherEndpoint Dataplane identifier of the other endpoint of the InterVpnLink
* @return the list of Futures for each and every flow that has been installed
*/
public static List<ListenableFuture<Void>> installLPortDispatcherTableFlow(DataBroker broker, IMdsalApiManager mdsalManager, String interVpnLinkName, List<BigInteger> dpnList, String vpnUuidOtherEndpoint, Long lportTagOfOtherEndpoint) {
List<ListenableFuture<Void>> result = new ArrayList<>();
long vpnId = VpnUtil.getVpnId(broker, vpnUuidOtherEndpoint);
for (BigInteger dpnId : dpnList) {
// insert into LPortDispatcher table
Flow lportDispatcherFlow = buildLPortDispatcherFlow(interVpnLinkName, vpnId, lportTagOfOtherEndpoint.intValue());
result.add(mdsalManager.installFlow(dpnId, lportDispatcherFlow));
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink in project netvirt by opendaylight.
the class VrfEntryListener method installIVpnLinkSwitchingFlows.
/*
* Installs the flows in FIB table that, for a given route, do the switching from one VPN to the other.
*/
private void installIVpnLinkSwitchingFlows(final InterVpnLinkDataComposite interVpnLink, final String vpnUuid, final VrfEntry vrfEntry, long vpnTag) {
Preconditions.checkNotNull(interVpnLink, "InterVpnLink cannot be null");
Preconditions.checkArgument(vrfEntry.getRoutePaths() != null && vrfEntry.getRoutePaths().size() == 1);
String destination = vrfEntry.getDestPrefix();
String nextHop = vrfEntry.getRoutePaths().get(0).getNexthopAddress();
String interVpnLinkName = interVpnLink.getInterVpnLinkName();
// using as metadata the LPortTag associated to that vpn in the inter-vpn-link.
if (interVpnLink.getState().or(State.Error) != State.Active) {
LOG.warn("Route to {} with nexthop={} cannot be installed because the interVpnLink {} is not active", destination, nextHop, interVpnLinkName);
return;
}
Optional<Long> optOtherEndpointLportTag = interVpnLink.getOtherEndpointLportTagByVpnName(vpnUuid);
if (!optOtherEndpointLportTag.isPresent()) {
LOG.warn("Could not find suitable LportTag for the endpoint opposite to vpn {} in interVpnLink {}", vpnUuid, interVpnLinkName);
return;
}
List<BigInteger> targetDpns = interVpnLink.getEndpointDpnsByVpnName(vpnUuid);
if (targetDpns.isEmpty()) {
LOG.warn("Could not find DPNs for endpoint opposite to vpn {} in interVpnLink {}", vpnUuid, interVpnLinkName);
return;
}
String[] values = destination.split("/");
String destPrefixIpAddress = values[0];
int prefixLength = values.length == 1 ? 0 : Integer.parseInt(values[1]);
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnTag), MetaDataUtil.METADATA_MASK_VRFID));
matches.add(MatchEthernetType.IPV4);
if (prefixLength != 0) {
matches.add(new MatchIpv4Destination(destPrefixIpAddress, Integer.toString(prefixLength)));
}
List<Instruction> instructions = Arrays.asList(new InstructionWriteMetadata(MetaDataUtil.getMetaDataForLPortDispatcher(optOtherEndpointLportTag.get().intValue(), ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)), MetaDataUtil.getMetaDataMaskForLPortDispatcher()).buildInstruction(0), new InstructionGotoTable(NwConstants.L3_INTERFACE_TABLE).buildInstruction(1));
int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
String flowRef = getInterVpnFibFlowRef(interVpnLinkName, destination, nextHop);
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, COOKIE_VM_FIB_TABLE, matches, instructions);
LOG.trace("Installing flow in FIB table for vpn {} interVpnLink {} nextHop {} key {}", vpnUuid, interVpnLink.getInterVpnLinkName(), nextHop, flowRef);
for (BigInteger dpId : targetDpns) {
LOG.debug("Installing flow: VrfEntry=[prefix={} route-paths={}] dpn {} for InterVpnLink {} in FIB", vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), dpId, interVpnLink.getInterVpnLinkName());
mdsalManager.installFlow(dpId, flowEntity);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink in project netvirt by opendaylight.
the class NeutronRouterChangeListener method handleChangedRoutes.
private void handleChangedRoutes(Uuid vpnName, List<Routes> routes, int addedOrRemoved) {
// Some routes may point to an InterVpnLink's endpoint, lets treat them differently
List<Routes> interVpnLinkRoutes = new ArrayList<>();
List<Routes> otherRoutes = new ArrayList<>();
HashMap<String, InterVpnLink> nexthopsXinterVpnLinks = new HashMap<>();
for (Routes route : routes) {
String nextHop = String.valueOf(route.getNexthop().getValue());
// Nexthop is another VPN?
Optional<InterVpnLink> interVpnLink = neutronvpnUtils.getInterVpnLinkByEndpointIp(nextHop);
if (interVpnLink.isPresent()) {
Optional<InterVpnLinkState> interVpnLinkState = neutronvpnUtils.getInterVpnLinkState(interVpnLink.get().getName());
if (interVpnLinkState.isPresent() && interVpnLinkState.get().getState() == InterVpnLinkState.State.Active) {
interVpnLinkRoutes.add(route);
nexthopsXinterVpnLinks.put(nextHop, interVpnLink.get());
} else {
LOG.error("Failed installing route to {}. Reason: InterVPNLink {} is not Active", String.valueOf(route.getDestination().getValue()), interVpnLink.get().getName());
}
} else {
otherRoutes.add(route);
}
}
if (addedOrRemoved == NwConstants.ADD_FLOW) {
nvpnManager.addInterVpnRoutes(vpnName, interVpnLinkRoutes, nexthopsXinterVpnLinks);
nvpnManager.updateVpnInterfaceWithExtraRouteAdjacency(vpnName, otherRoutes);
} else {
nvpnManager.removeAdjacencyforExtraRoute(vpnName, otherRoutes);
nvpnManager.removeInterVpnRoutes(vpnName, interVpnLinkRoutes, nexthopsXinterVpnLinks);
}
}
Aggregations