use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.NextHop in project netvirt by opendaylight.
the class EvpnMacVrfUtils method addEvpnDmacFlow.
public void addEvpnDmacFlow(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
String elanName = getElanNameByMacvrfiid(instanceIdentifier);
if (elanName == null) {
LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
return;
}
List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
if (checkEvpnAttachedToNet(elanName)) {
// TODO(Riyaz) : Check if accessing first nexthop address is right solution
String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Long elanTag = getElanTagByMacvrfiid(instanceIdentifier);
if (elanTag == null) {
return;
}
String dstMacAddress = macVrfEntry.getMac();
long vni = macVrfEntry.getL2vni();
jobCoordinator.enqueueJob(dstMacAddress, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
dpnInterfaceLists.forEach(dpnInterfaces -> {
BigInteger dpId = dpnInterfaces.getDpId();
LOG.info("ADD: Build DMAC flow with dpId {}, nexthopIP {}, elanTag {}," + "vni {}, dstMacAddress {}, elanName {} ", dpId, nexthopIP, elanTag, vni, dstMacAddress, elanName);
ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setVni(vni).setDstMacAddress(dstMacAddress).setElanName(elanName);
Flow flow = elanEvpnFlowUtils.evpnBuildDmacFlowForExternalRemoteMac(dmacFlowBuilder.build());
futures.add(mdsalManager.installFlow(dpId, flow));
});
return futures;
}, ElanConstants.JOB_MAX_RETRIES);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.NextHop in project netvirt by opendaylight.
the class EvpnMacVrfUtils method removeEvpnDmacFlow.
public void removeEvpnDmacFlow(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
String elanName = getElanNameByMacvrfiid(instanceIdentifier);
if (elanName == null) {
LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
return;
}
List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
// if (checkEvpnAttachedToNet(elanName)) {
// TODO(Riyaz) : Check if accessing first nexthop address is right
String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Long elanTag = getElanTagByMacvrfiid(instanceIdentifier);
if (elanTag == null) {
return;
}
String macToRemove = macVrfEntry.getMac();
jobCoordinator.enqueueJob(macToRemove, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
dpnInterfaceLists.forEach(dpnInterfaces -> {
BigInteger dpId = dpnInterfaces.getDpId();
ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setDstMacAddress(macToRemove);
LOG.info("REMOVE: Deleting DMAC Flows for external MAC. elanTag {}, dpId {}," + "nexthopIP {}, macToRemove {}", elanTag, dpId, nexthopIP, macToRemove);
futures.addAll(elanEvpnFlowUtils.evpnDeleteDmacFlowsToExternalMac(dmacFlowBuilder.build()));
});
return futures;
}, ElanConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.NextHop in project netvirt by opendaylight.
the class VpnInterfaceManager method handleVpnsExportingRoutes.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
void handleVpnsExportingRoutes(String vpnName, String vpnRd) {
List<VpnInstanceOpDataEntry> vpnsToExportRoute = getVpnsExportingMyRoute(vpnName);
for (VpnInstanceOpDataEntry vpn : vpnsToExportRoute) {
List<VrfEntry> vrfEntries = VpnUtil.getAllVrfEntries(dataBroker, vpn.getVrfId());
WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
if (vrfEntries != null) {
for (VrfEntry vrfEntry : vrfEntries) {
try {
if (!FibHelper.isControllerManagedNonInterVpnLinkRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
LOG.info("handleVpnsExportingRoutes: vrfEntry with rd {} prefix {}" + " is not a controller managed non intervpn link route. Ignoring.", vpn.getVrfId(), vrfEntry.getDestPrefix());
continue;
}
String prefix = vrfEntry.getDestPrefix();
String gwMac = vrfEntry.getGatewayMacAddress();
vrfEntry.getRoutePaths().forEach(routePath -> {
String nh = routePath.getNexthopAddress();
int label = routePath.getLabel().intValue();
if (FibHelper.isControllerManagedVpnInterfaceRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
LOG.info("handleVpnsExportingRoutesImporting: Importing fib entry rd {} prefix {}" + " nexthop {} label {} to vpn {} vpnRd {}", vpn.getVrfId(), prefix, nh, label, vpnName, vpnRd);
fibManager.addOrUpdateFibEntry(vpnRd, null, /*macAddress*/
prefix, Collections.singletonList(nh), VrfEntry.EncapType.Mplsgre, label, 0, /*l3vni*/
gwMac, null, /*parentVpnRd*/
RouteOrigin.SELF_IMPORTED, writeConfigTxn);
} else {
LOG.info("handleVpnsExportingRoutes: Importing subnet route fib entry rd {} prefix {}" + " nexthop {} label {} to vpn {} vpnRd {}", vpn.getVrfId(), prefix, nh, label, vpnName, vpnRd);
SubnetRoute route = vrfEntry.getAugmentation(SubnetRoute.class);
importSubnetRouteForNewVpn(vpnRd, prefix, nh, label, route, writeConfigTxn);
}
});
} catch (RuntimeException e) {
LOG.error("getNextHopAddressList: Exception occurred while importing route with rd {}" + " prefix {} routePaths {} to vpn {} vpnRd {}", vpn.getVrfId(), vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), vpnName, vpnRd);
}
}
writeConfigTxn.submit();
} else {
LOG.info("getNextHopAddressList: No vrf entries to import from vpn {} with rd {} to vpn {} with rd {}", vpn.getVpnInstanceName(), vpn.getVrfId(), vpnName, vpnRd);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.NextHop 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.params.xml.ns.yang.bgp.types.rev130919.NextHop in project netvirt by opendaylight.
the class VpnInterfaceManager method updateVpnInterfaceOnTepAdd.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void updateVpnInterfaceOnTepAdd(VpnInterfaceOpDataEntry vpnInterface, StateTunnelList stateTunnelList, WriteTransaction writeConfigTxn, WriteTransaction writeOperTxn) {
String srcTepIp = String.valueOf(stateTunnelList.getSrcInfo().getTepIp().getValue());
BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
AdjacenciesOp adjacencies = vpnInterface.getAugmentation(AdjacenciesOp.class);
List<Adjacency> adjList = adjacencies != null ? adjacencies.getAdjacency() : new ArrayList<>();
if (adjList.isEmpty()) {
LOG.trace("updateVpnInterfaceOnTepAdd: Adjacencies are empty for vpnInterface {} on dpn {}", vpnInterface, srcDpnId);
return;
}
String prefix = null;
long label = 0;
List<Adjacency> value = new ArrayList<>();
boolean isNextHopAddReqd = false;
String vpnName = vpnInterface.getVpnInstanceName();
long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
LOG.info("updateVpnInterfaceOnTepAdd: AdjacencyList for interface {} on dpn {} vpn {} is {}", vpnInterface.getName(), vpnInterface.getDpnId(), vpnInterface.getVpnInstanceName(), adjList);
for (Adjacency adj : adjList) {
String rd = adj.getVrfId();
rd = rd != null ? rd : vpnName;
prefix = adj.getIpAddress();
label = adj.getLabel();
List<String> nhList = Collections.singletonList(srcTepIp);
List<String> nextHopList = adj.getNextHopIpList();
// Secondary adj nexthop is already pointing to primary adj IP address.
if (nextHopList != null && !nextHopList.isEmpty() && nextHopList.get(0).equalsIgnoreCase(srcTepIp)) {
/* everything right already */
} else {
isNextHopAddReqd = true;
}
if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
value.add(new AdjacencyBuilder(adj).setNextHopIpList(nhList).build());
} else {
Optional<VrfEntry> vrfEntryOptional = FibHelper.getVrfEntry(dataBroker, primaryRd, prefix);
if (!vrfEntryOptional.isPresent()) {
continue;
}
nhList = FibHelper.getNextHopListFromRoutePaths(vrfEntryOptional.get());
if (!nhList.contains(srcTepIp)) {
nhList.add(srcTepIp);
isNextHopAddReqd = true;
}
value.add(adj);
}
if (isNextHopAddReqd) {
updateLabelMapper(label, nhList);
LOG.info("updateVpnInterfaceOnTepAdd: Updated label mapper : label {} dpn {} prefix {} nexthoplist {}" + " vpn {} vpnid {} rd {} interface {}", label, srcDpnId, prefix, nhList, vpnInterface.getVpnInstanceName(), vpnId, rd, vpnInterface.getName());
// Update the VRF entry with nextHop
fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp, label, true, writeConfigTxn);
// Get the list of VPN's importing this route(prefix) .
// Then update the VRF entry with nhList
List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
String vpnRd = vpn.getVrfId();
if (vpnRd != null) {
fibManager.updateRoutePathForFibEntry(vpnRd, prefix, srcTepIp, label, true, writeConfigTxn);
LOG.info("updateVpnInterfaceOnTepAdd: Exported route with rd {} prefix {} nhList {} label {}" + " interface {} dpn {} from vpn {} to VPN {} vpnRd {}", rd, prefix, nhList, label, vpnInterface.getName(), srcDpnId, vpnName, vpn.getVpnInstanceName(), vpnRd);
}
}
// since there is a nexthop change.
try {
if (!rd.equalsIgnoreCase(vpnName)) {
bgpManager.advertisePrefix(rd, null, /*macAddress*/
prefix, nhList, VrfEntry.EncapType.Mplsgre, (int) label, 0, /*evi*/
0, /*l2vni*/
null);
}
LOG.info("updateVpnInterfaceOnTepAdd: Advertised rd {} prefix {} nhList {} label {}" + " for interface {} on dpn {} vpn {}", rd, prefix, nhList, label, vpnInterface.getName(), srcDpnId, vpnName);
} catch (Exception ex) {
LOG.error("updateVpnInterfaceOnTepAdd: Exception when advertising prefix {} nh {} label {}" + " on rd {} for interface {} on dpn {} vpn {}", prefix, nhList, label, rd, vpnInterface.getName(), srcDpnId, vpnName, ex);
}
}
}
AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(value);
VpnInterfaceOpDataEntry opInterface = new VpnInterfaceOpDataEntryBuilder(vpnInterface).setKey(new VpnInterfaceOpDataEntryKey(vpnInterface.getName(), vpnName)).addAugmentation(AdjacenciesOp.class, aug).build();
InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
writeOperTxn.put(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface, WriteTransaction.CREATE_MISSING_PARENTS);
LOG.info("updateVpnInterfaceOnTepAdd: interface {} updated successully on tep add on dpn {} vpn {}", vpnInterface.getName(), srcDpnId, vpnName);
}
Aggregations