use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project netvirt by opendaylight.
the class NexthopManager method getBucketsForLocalNexthop.
private List<BucketInfo> getBucketsForLocalNexthop(Long vpnId, BigInteger dpnId, VrfEntry vrfEntry, Routes routes) {
List<BucketInfo> listBucketInfo = new CopyOnWriteArrayList<>();
routes.getNexthopIpList().parallelStream().forEach(nextHopIp -> {
String localNextHopIP;
if (isIpv4Address(nextHopIp)) {
localNextHopIP = nextHopIp + NwConstants.IPV4PREFIX;
} else {
localNextHopIP = nextHopIp + NwConstants.IPV6PREFIX;
}
Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
if (localNextHopInfo != null) {
long groupId = getLocalNextHopGroup(vpnId, localNextHopIP);
if (groupId == FibConstants.INVALID_GROUP_ID) {
LOG.error("Unable to allocate groupId for vpnId {} , prefix {} , interface {}", vpnId, vrfEntry.getDestPrefix(), localNextHopInfo.getVpnInterfaceName());
return;
}
List<ActionInfo> actionsInfos = Collections.singletonList(new ActionGroup(groupId));
BucketInfo bucket = new BucketInfo(actionsInfos);
bucket.setWeight(1);
listBucketInfo.add(bucket);
}
});
LOG.trace("LOCAL: listbucket {}, vpnId {}, dpnId {}, routes {}", listBucketInfo, vpnId, dpnId, routes);
return listBucketInfo;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project netvirt by opendaylight.
the class NexthopManager method getElanInstanceForPrefix.
private ElanInstance getElanInstanceForPrefix(long vpnId, String prefixIp) {
ElanInstance elanInstance = null;
Prefixes prefix = fibUtil.getPrefixToInterface(vpnId, prefixIp);
if (prefix != null) {
Uuid subnetId = prefix.getSubnetId();
if (subnetId != null) {
Subnetmap subnetMap = fibUtil.getSubnetMap(subnetId);
if (subnetMap != null && subnetMap.getNetworkId() != null) {
elanInstance = elanService.getElanInstance(subnetMap.getNetworkId().getValue());
}
}
}
return elanInstance;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project netvirt by opendaylight.
the class VrfEntryListener method createLocalFibEntry.
private List<BigInteger> createLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
List<BigInteger> returnLocalDpnId = new ArrayList<>();
String localNextHopIP = vrfEntry.getDestPrefix();
Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
String vpnName = fibUtil.getVpnNameFromId(vpnId);
if (localNextHopInfo == null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, localNextHopIP);
List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker, vpnName, usedRds, localNextHopIP);
boolean localNextHopSeen = false;
// Is this fib route an extra route? If yes, get the nexthop which would be an adjacency in the vpn
for (Routes vpnExtraRoute : vpnExtraRoutes) {
String ipPrefix;
if (isIpv4Address(vpnExtraRoute.getNexthopIpList().get(0))) {
ipPrefix = vpnExtraRoute.getNexthopIpList().get(0) + NwConstants.IPV4PREFIX;
} else {
ipPrefix = vpnExtraRoute.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
}
Prefixes localNextHopInfoLocal = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
if (localNextHopInfoLocal != null) {
localNextHopSeen = true;
BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfoLocal, localNextHopInfoLocal.getIpAddress(), vpnId, rd, vrfEntry, vpnId, vpnExtraRoute, vpnExtraRoutes);
returnLocalDpnId.add(dpnId);
}
}
if (!localNextHopSeen && RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.SELF_IMPORTED) {
java.util.Optional<Long> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
if (optionalLabel.isPresent()) {
Long label = optionalLabel.get();
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
synchronized (label.toString().intern()) {
LabelRouteInfo lri = getLabelRouteInfo(label);
if (isPrefixAndNextHopPresentInLri(localNextHopIP, nextHopAddressList, lri)) {
Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional = fibUtil.getVpnInstanceOpData(rd);
if (vpnInstanceOpDataEntryOptional.isPresent()) {
String vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
if (lri.getVpnInstanceList().contains(vpnInstanceName)) {
localNextHopInfo = updateVpnReferencesInLri(lri, vpnInstanceName, true);
localNextHopIP = lri.getPrefix();
} else {
localNextHopInfo = updateVpnReferencesInLri(lri, vpnInstanceName, false);
localNextHopIP = lri.getPrefix();
}
}
if (localNextHopInfo != null) {
LOG.debug("Fetched labelRouteInfo for label {} interface {} and got dpn {}", label, localNextHopInfo.getVpnInterfaceName(), lri.getDpnId());
if (vpnExtraRoutes.isEmpty()) {
BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, lri.getParentVpnid(), null, vpnExtraRoutes);
returnLocalDpnId.add(dpnId);
} else {
for (Routes extraRoutes : vpnExtraRoutes) {
BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, lri.getParentVpnid(), extraRoutes, vpnExtraRoutes);
returnLocalDpnId.add(dpnId);
}
}
}
}
}
}
}
if (returnLocalDpnId.isEmpty()) {
LOG.error("Local DPNID is empty for rd {}, vpnId {}, vrfEntry {}", rd, vpnId, vrfEntry);
}
} else {
BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, vpnId, /*routes*/
null, /*vpnExtraRoutes*/
null);
if (dpnId != null) {
returnLocalDpnId.add(dpnId);
}
}
return returnLocalDpnId;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project netvirt by opendaylight.
the class VrfEntryListener method cleanUpOpDataForFib.
protected void cleanUpOpDataForFib(Long vpnId, String primaryRd, final VrfEntry vrfEntry) {
/* Get interface info from prefix to interface mapping;
Use the interface info to get the corresponding vpn interface op DS entry,
remove the adjacency corresponding to this fib entry.
If adjacency removed is the last adjacency, clean up the following:
- vpn interface from dpntovpn list, dpn if last vpn interface on dpn
- prefix to interface entry
- vpn interface op DS
*/
LOG.debug("Cleanup of prefix {} in VPN {}", vrfEntry.getDestPrefix(), vpnId);
Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
if (prefixInfo == null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
String usedRd = usedRds.isEmpty() ? primaryRd : usedRds.get(0);
Routes extraRoute = baseVrfEntryHandler.getVpnToExtraroute(vpnId, usedRd, vrfEntry.getDestPrefix());
if (extraRoute != null) {
for (String nextHopIp : extraRoute.getNexthopIpList()) {
LOG.debug("NextHop IP for destination {} is {}", vrfEntry.getDestPrefix(), nextHopIp);
if (nextHopIp != null) {
String ipPrefix;
if (isIpv4Address(nextHopIp)) {
ipPrefix = nextHopIp + NwConstants.IPV4PREFIX;
} else {
ipPrefix = nextHopIp + NwConstants.IPV6PREFIX;
}
prefixInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, extraRoute);
}
}
}
if (prefixInfo == null) {
java.util.Optional<Long> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
if (optionalLabel.isPresent()) {
Long label = optionalLabel.get();
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
LabelRouteInfo lri = getLabelRouteInfo(label);
if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopAddressList, lri)) {
PrefixesBuilder prefixBuilder = new PrefixesBuilder();
prefixBuilder.setDpnId(lri.getDpnId());
prefixBuilder.setVpnInterfaceName(lri.getVpnInterfaceName());
prefixBuilder.setIpAddress(lri.getPrefix());
prefixInfo = prefixBuilder.build();
LOG.debug("Fetched labelRouteInfo for label {} interface {} and got dpn {}", label, prefixInfo.getVpnInterfaceName(), lri.getDpnId());
checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, extraRoute);
}
}
}
} else {
checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, null);
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project netvirt by opendaylight.
the class VrfEntryListener method updateVpnReferencesInLri.
private Prefixes updateVpnReferencesInLri(LabelRouteInfo lri, String vpnInstanceName, boolean isPresentInList) {
LOG.debug("updating LRI : for label {} vpninstancename {}", lri.getLabel(), vpnInstanceName);
PrefixesBuilder prefixBuilder = new PrefixesBuilder();
prefixBuilder.setDpnId(lri.getDpnId());
prefixBuilder.setVpnInterfaceName(lri.getVpnInterfaceName());
prefixBuilder.setIpAddress(lri.getPrefix());
// Increment the refCount here
InstanceIdentifier<LabelRouteInfo> lriId = InstanceIdentifier.builder(LabelRouteMap.class).child(LabelRouteInfo.class, new LabelRouteInfoKey(lri.getLabel())).build();
LabelRouteInfoBuilder builder = new LabelRouteInfoBuilder(lri);
if (!isPresentInList) {
LOG.debug("vpnName {} is not present in LRI with label {}..", vpnInstanceName, lri.getLabel());
List<String> vpnInstanceNames = lri.getVpnInstanceList();
vpnInstanceNames.add(vpnInstanceName);
builder.setVpnInstanceList(vpnInstanceNames);
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, lriId, builder.build());
} else {
LOG.debug("vpnName {} is present in LRI with label {}..", vpnInstanceName, lri.getLabel());
}
return prefixBuilder.build();
}
Aggregations