use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route in project netvirt by opendaylight.
the class L3vpnPopulator method addSubnetRouteFibEntry.
public void addSubnetRouteFibEntry(L3vpnInput input) {
String rd = input.getRd();
String vpnName = input.getVpnName();
String prefix = input.getSubnetIp();
String nextHop = input.getNextHopIp();
long label = input.getLabel();
long l3vni = input.getL3vni();
long elantag = input.getElanTag();
BigInteger dpnId = input.getDpnId();
String networkName = input.getNetworkName();
String gwMacAddress = input.getGatewayMac();
SubnetRoute route = new SubnetRouteBuilder().setElantag(elantag).build();
// Only case when a route is considered as directly connected
RouteOrigin origin = RouteOrigin.CONNECTED;
VrfEntry vrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, nextHop, origin, networkName).addAugmentation(SubnetRoute.class, route).setL3vni(l3vni).setGatewayMacAddress(gwMacAddress).build();
LOG.debug("Created vrfEntry for {} nexthop {} label {} and elantag {}", prefix, nextHop, label, elantag);
InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix)).build();
Optional<VrfEntry> entry = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
if (!entry.isPresent()) {
List<VrfEntry> vrfEntryList = Collections.singletonList(vrfEntry);
InstanceIdentifier.InstanceIdentifierBuilder<VrfTables> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
InstanceIdentifier<VrfTables> vrfTableId = idBuilder.build();
VrfTables vrfTableNew = new VrfTablesBuilder().setRouteDistinguisher(rd).setVrfEntry(vrfEntryList).build();
VpnUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vrfTableId, vrfTableNew);
LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Added vrfEntry for {} nexthop {} label {} rd {}" + " vpnName {}", prefix, nextHop, label, rd, vpnName);
} else {
// Found in MDSAL database
VpnUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry);
LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Updated vrfEntry for {} nexthop {} label {} rd {}" + " vpnName {}", prefix, nextHop, label, rd, vpnName);
}
// Will be handled appropriately with the iRT patch for EVPN
if (input.getEncapType().equals(VrfEntryBase.EncapType.Mplsgre)) {
long vpnId = VpnUtil.getVpnId(broker, vpnName);
addToLabelMapper(label, dpnId, prefix, Collections.singletonList(nextHop), vpnId, null, elantag, true, rd);
List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(broker, vpnName);
if (vpnsToImportRoute.size() > 0) {
VrfEntry importingVrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, nextHop, RouteOrigin.SELF_IMPORTED, networkName).addAugmentation(SubnetRoute.class, route).build();
List<VrfEntry> importingVrfEntryList = Collections.singletonList(importingVrfEntry);
for (VpnInstanceOpDataEntry vpnInstance : vpnsToImportRoute) {
String importingRd = vpnInstance.getVrfId();
InstanceIdentifier<VrfTables> importingVrfTableId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(importingRd)).build();
VrfTables importingVrfTable = new VrfTablesBuilder().setRouteDistinguisher(importingRd).setVrfEntry(importingVrfEntryList).build();
VpnUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, importingVrfTableId, importingVrfTable);
LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Exported route rd {} prefix {} nexthop {}" + " label {} to vpn {} importingRd {}", rd, prefix, nextHop, label, vpnInstance.getVpnInstanceName(), importingRd);
}
}
}
LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Created vrfEntry for {} nexthop {} label {} and elantag {}" + "rd {} vpnName {}", prefix, nextHop, label, elantag, rd, vpnName);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route in project netvirt by opendaylight.
the class VrfListener method programLabelInAllVpnDpns.
/**
* Adds or Removes a VPN's route in all the DPNs where the VPN has footprint.
*
* @param vpnRd Route-Distinguisher of the VPN
* @param vrfEntry The route to add or remove
* @param addOrRemove States if the route must be added or removed
*/
protected void programLabelInAllVpnDpns(String vpnRd, VrfEntry vrfEntry, int addOrRemove) {
Long vpnPseudoLPortTag = vpnPseudoPortCache.get(vpnRd);
if (vpnPseudoLPortTag == null) {
LOG.debug("Vpn with rd={} not related to any VpnPseudoPort", vpnRd);
return;
}
Optional<VpnInstanceOpDataEntry> vpnOpData = VpnServiceChainUtils.getVpnInstanceOpData(broker, vpnRd);
if (!vpnOpData.isPresent()) {
if (addOrRemove == NwConstants.ADD_FLOW) {
LOG.error("VrfEntry added: Could not find operational data for VPN with RD={}", vpnRd);
} else {
LOG.warn("VrfEntry removed: No Operational data found for VPN with RD={}. No further action", vpnRd);
}
return;
}
Collection<VpnToDpnList> vpnToDpnList = vpnOpData.get().getVpnToDpnList();
if (vpnToDpnList == null || vpnToDpnList.isEmpty()) {
LOG.warn("Empty VpnToDpnlist found in Operational for VPN with RD={}. No label will be {}", vpnRd, addOrRemove == NwConstants.ADD_FLOW ? "programmed" : "cleaned");
return;
}
for (VpnToDpnList dpnInVpn : vpnToDpnList) {
BigInteger dpnId = dpnInVpn.getDpnId();
VpnServiceChainUtils.programLFibEntriesForSCF(mdsalMgr, dpnId, Collections.singletonList(vrfEntry), (int) vpnPseudoLPortTag.longValue(), addOrRemove);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route in project netvirt by opendaylight.
the class VPNServiceChainHandler method programVpnToScfPipeline.
/**
* Programs the necessary flows in LFIB and LPortDispatcher table so that
* the packets coming from a given VPN are delivered to a given
* ServiceChain Pipeline.
*
* @param vpnName Name of the VPN. Typically the UUID
* @param tableId Table to which the LPortDispatcher table sends the packet
* to (Uplink or Downlink Subsc table)
* @param scfTag Scf tag to the SCF to which the Vpn is linked to.
* @param lportTag VpnPseudo Port lportTag
* @param addOrRemove States if the VPN2SCF Pipeline must be installed or
* removed
*/
public void programVpnToScfPipeline(String vpnName, short tableId, long scfTag, int lportTag, int addOrRemove) {
// This entries must be created in the DPN where the CGNAT is installed. Since it is not possible
// to know where CGNAT is located, this entries are installed in all the VPN footprint.
// LFIB:
// - Match: cgnatLabel Instr: lportTag=vpnPseudoPortTag + SI=SCF + GOTO 17
// LportDisp:
// - Match: vpnPseudoPortTag + SI==SCF Instr: scfTag + GOTO 70
LOG.info("programVpnToScfPipeline ({}) : Parameters VpnName:{} tableId:{} scftag:{} lportTag:{}", addOrRemove == NwConstants.ADD_FLOW ? "Creation" : "Removal", vpnName, tableId, scfTag, lportTag);
String rd = VpnServiceChainUtils.getVpnRd(dataBroker, vpnName);
LOG.debug("Router distinguisher (rd):{}", rd);
if (rd == null || rd.isEmpty()) {
LOG.warn("programVpnToScfPipeline: Could not find Router-distinguisher for VPN {}. No further actions", vpnName);
return;
}
VpnInstanceOpDataEntry vpnInstance = getVpnInstance(rd);
if (vpnInstance == null) {
LOG.warn("Could not find a suitable VpnInstance for Route-Distinguisher={}", rd);
return;
}
// Find out the set of DPNs for the given VPN ID
Collection<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
List<VrfEntry> vrfEntries = VpnServiceChainUtils.getAllVrfEntries(dataBroker, rd);
if (vrfEntries != null) {
if (addOrRemove == NwConstants.ADD_FLOW) {
AddVpnPseudoPortDataJob updateVpnToPseudoPortTask = new AddVpnPseudoPortDataJob(dataBroker, rd, lportTag, tableId, (int) scfTag);
jobCoordinator.enqueueJob(updateVpnToPseudoPortTask.getDsJobCoordinatorKey(), updateVpnToPseudoPortTask);
} else {
RemoveVpnPseudoPortDataJob removeVpnPseudoPortDataTask = new RemoveVpnPseudoPortDataJob(dataBroker, rd);
jobCoordinator.enqueueJob(removeVpnPseudoPortDataTask.getDsJobCoordinatorKey(), removeVpnPseudoPortDataTask);
}
for (VpnToDpnList dpnInVpn : vpnToDpnList) {
BigInteger dpnId = dpnInVpn.getDpnId();
programVpnToScfPipelineOnDpn(dpnId, vrfEntries, tableId, (int) scfTag, lportTag, addOrRemove);
if (dpnInVpn.getVpnInterfaces() != null) {
long vpnId = vpnInstance.getVpnId();
Flow flow = VpnServiceChainUtils.buildLPortDispFromScfToL3VpnFlow(vpnId, dpnId, lportTag, NwConstants.ADD_FLOW);
if (addOrRemove == NwConstants.ADD_FLOW) {
mdsalManager.installFlow(dpnId, flow);
} else {
mdsalManager.removeFlow(dpnId, flow);
}
dpnInVpn.getVpnInterfaces().forEach(vpnIf -> {
if (addOrRemove == NwConstants.ADD_FLOW) {
bindScfOnVpnInterface(vpnIf.getInterfaceName(), (int) scfTag);
} else {
unbindScfOnVpnInterface(vpnIf.getInterfaceName());
}
});
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route in project netvirt by opendaylight.
the class NeutronvpnManager method associateExtNetworkToVpn.
private boolean associateExtNetworkToVpn(@Nonnull Uuid vpnId, @Nonnull Network extNet) {
VpnInstanceOpDataEntry vpnOpDataEntry = neutronvpnUtils.getVpnInstanceOpDataEntryFromVpnId(vpnId.getValue());
if (vpnOpDataEntry == null) {
LOG.error("associateExtNetworkToVpn: can not find VpnOpDataEntry for VPN {}", vpnId.getValue());
return false;
}
if (!addExternalNetworkToVpn(extNet, vpnId)) {
return false;
}
if (!vpnOpDataEntry.getBgpvpnType().equals(BgpvpnType.BGPVPNInternet)) {
LOG.info("associateExtNetworkToVpn: set type {} for VPN {}", BgpvpnType.BGPVPNInternet, vpnId.getValue());
neutronvpnUtils.updateVpnInstanceOpWithType(BgpvpnType.BGPVPNInternet, vpnId);
}
for (Uuid snId : neutronvpnUtils.getPrivateSubnetsToExport(extNet)) {
Subnetmap sm = neutronvpnUtils.getSubnetmap(snId);
if (sm == null) {
LOG.error("associateExtNetworkToVpn: can not find subnet with Id {} in ConfigDS", snId.getValue());
continue;
}
updateVpnInternetForSubnet(sm, vpnId, true);
if (!(vpnOpDataEntry.isIpv6Configured()) && (NeutronvpnUtils.getIpVersionFromString(sm.getSubnetIp()) == IpVersionChoice.IPV6)) {
LOG.info("associateExtNetworkToVpn: add IPv6 Internet default route in VPN {}", vpnId.getValue());
neutronvpnUtils.updateVpnInstanceWithFallback(vpnId.getValue(), true);
}
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route in project netvirt by opendaylight.
the class NeutronvpnManager method addInterVpnRoutes.
/**
* Creates the corresponding static routes in the specified VPN. These static routes must be point to an
* InterVpnLink endpoint and the specified VPN must be the other end of the InterVpnLink. Otherwise the
* route will be ignored.
*
* @param vpnName the VPN identifier
* @param interVpnLinkRoutes The list of static routes
* @param nexthopsXinterVpnLinks A Map with the correspondence nextHop-InterVpnLink
*/
public void addInterVpnRoutes(Uuid vpnName, List<Routes> interVpnLinkRoutes, HashMap<String, InterVpnLink> nexthopsXinterVpnLinks) {
for (Routes route : interVpnLinkRoutes) {
String nexthop = String.valueOf(route.getNexthop().getValue());
String destination = String.valueOf(route.getDestination().getValue());
InterVpnLink interVpnLink = nexthopsXinterVpnLinks.get(nexthop);
if (isNexthopTheOtherVpnLinkEndpoint(nexthop, vpnName.getValue(), interVpnLink)) {
AddStaticRouteInput rpcInput = new AddStaticRouteInputBuilder().setDestination(destination).setNexthop(nexthop).setVpnInstanceName(vpnName.getValue()).build();
Future<RpcResult<AddStaticRouteOutput>> labelOuputFtr = vpnRpcService.addStaticRoute(rpcInput);
RpcResult<AddStaticRouteOutput> rpcResult;
try {
rpcResult = labelOuputFtr.get();
if (rpcResult.isSuccessful()) {
LOG.debug("Label generated for destination {} is: {}", destination, rpcResult.getResult().getLabel());
} else {
LOG.error("RPC call to add a static Route to {} with nexthop {} returned with errors {}", destination, nexthop, rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error happened while invoking addStaticRoute RPC for nexthop {} with destination {} " + "for VPN {}", nexthop, destination, vpnName.getValue(), e);
}
} else {
// Any other case is a fault.
LOG.warn("route with destination {} and nexthop {} does not apply to any InterVpnLink", String.valueOf(route.getDestination().getValue()), nexthop);
continue;
}
}
}
Aggregations